svcomp_reverse_array_unsafe.c

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:16.0
disk size 674 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
#include <stdlib.h>
extern int __VERIFIER_nondet_int(void);

int main() {
  int i, j, tmp;
  int length = __VERIFIER_nondet_int();
  if (length < 1) length = 1;
  // make sure that length is odd
  if (length % 2 == 0) length++;
  int *arr = alloca(length);
  // make sure the marker occurs only once
  for (i=0; i<length; i++) {
    if (arr[i] == '\0') arr[i]++;
  }
  // mark the middle
  arr[length / 2 + 1] = '\0';
  // runs from left to right
  int *a = arr;
  // runs from right to left
  int *b = arr + length - 1;
  // swap elements until we reach the marker
  while (*a != 0 && *b != 0) {
    tmp = *a;
    *a = *b;
    *b = tmp;
    a++;
    b--;
  }
  return 0;
}
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark