#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ bench_test(char *);
int /*<<< orphan*/ exit(int);
char *memalign(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int random();
int /*<<< orphan*/ srandom(int);
int /*<<< orphan*/ test_one(char *);
int testcase(void) {
  char *s;
  unsigned long i;
  s = memalign(128, 256);
  if (!s) {
    perror("memalign");
    exit(1);
  }
  srandom(1);
  memset(s, 0, 256);
  for (i = 0; i < 256; i++) {
    char c;
    do {
      c = random() & 0x7f;
    } while (!c);
    s[i] = c;
    test_one(s);
  }
  for (i = 0; i < 1000; i++) {
    unsigned long j;
    for (j = 0; j < 256; j++) {
      char c;
      do {
        c = random() & 0x7f;
      } while (!c);
      s[j] = c;
    }
    for (j = 0; j < sizeof(long); j++) {
      s[256 - 1 - j] = 0;
      test_one(s);
    }
  }
  for (i = 0; i < 256; i++) {
    char c;
    do {
      c = random() & 0x7f;
    } while (!c);
    s[i] = c;
  }
  bench_test(s);
  s[16] = 0;
  bench_test(s);
  s[8] = 0;
  bench_test(s);
  s[4] = 0;
  bench_test(s);
  s[3] = 0;
  bench_test(s);
  s[2] = 0;
  bench_test(s);
  s[1] = 0;
  bench_test(s);
  return 0;
}


x86 assembly (clang, -O0):
<testcase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x80,%edi
mov    $0x100,%esi
call   1060 <memalign@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11bc <testcase+0x3c>
lea    0xe53(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x1,%edi
call   1030 <srandom@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x100,-0x10(%rbp)
jae    1237 <testcase+0xb7>
jmp    11f1 <testcase+0x71>
mov    $0x0,%al
call   1070 <random@plt>
and    $0x7f,%eax
mov    %al,-0x11(%rbp)
cmpb   $0x0,-0x11(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f1 <testcase+0x71>
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1080 <test_one@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11de <testcase+0x5e>
movq   $0x0,-0x10(%rbp)
cmpq   $0x3e8,-0x10(%rbp)
jae    12f9 <testcase+0x179>
movq   $0x0,-0x20(%rbp)
cmpq   $0x100,-0x20(%rbp)
jae    12a5 <testcase+0x125>
jmp    1268 <testcase+0xe8>
mov    $0x0,%al
call   1070 <random@plt>
and    $0x7f,%eax
mov    %al,-0x21(%rbp)
cmpb   $0x0,-0x21(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1268 <testcase+0xe8>
mov    -0x21(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1255 <testcase+0xd5>
movq   $0x0,-0x20(%rbp)
cmpq   $0x8,-0x20(%rbp)
jae    12e3 <testcase+0x163>
mov    -0x8(%rbp),%rax
mov    $0xff,%ecx
sub    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1080 <test_one@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12ad <testcase+0x12d>
jmp    12e8 <testcase+0x168>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    123f <testcase+0xbf>
movq   $0x0,-0x10(%rbp)
cmpq   $0x100,-0x10(%rbp)
jae    1351 <testcase+0x1d1>
jmp    1314 <testcase+0x194>
mov    $0x0,%al
call   1070 <random@plt>
and    $0x7f,%eax
mov    %al,-0x22(%rbp)
cmpb   $0x0,-0x22(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1314 <testcase+0x194>
mov    -0x22(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1301 <testcase+0x181>
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x10(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <bench_test@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcase>:
push   %r15
push   %r14
push   %rbx
mov    $0x80,%edi
mov    $0x100,%esi
call   1060 <memalign@plt>
test   %rax,%rax
je     132a <testcase+0x1aa>
mov    %rax,%r15
mov    $0x1,%edi
call   1030 <srandom@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
xor    %r14d,%r14d
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <random@plt>
and    $0x7f,%al
je     11c0 <testcase+0x40>
mov    %al,(%r15,%r14,1)
mov    %r15,%rdi
call   1080 <test_one@plt>
add    $0x1,%r14
cmp    $0x100,%r14
jne    11c0 <testcase+0x40>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <random@plt>
and    $0x7f,%al
je     1200 <testcase+0x80>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1200 <testcase+0x80>
movb   $0x0,0xff(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xfe(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xfd(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xfc(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xfb(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xfa(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xf9(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
movb   $0x0,0xf8(%r15)
mov    %r15,%rdi
call   1080 <test_one@plt>
add    $0x1,%r14
cmp    $0x3e8,%r14
jne    11f0 <testcase+0x70>
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1070 <random@plt>
and    $0x7f,%al
je     12b0 <testcase+0x130>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    12b0 <testcase+0x130>
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x10(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x8(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x4(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x3(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x2(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
movb   $0x0,0x1(%r15)
mov    %r15,%rdi
call   1050 <bench_test@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xccf(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"memalign\00"
define i32 @testcase() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8
%4 = alloca i64
%5 = alloca i8
%6 = alloca i8
%7 = call i8* @memalign(i32 128, i32 256)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = icmp ne i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = call i32 @srandom(i32 1)
%15 = load i8*, i8** %1
%16 = call i32 @memset(i8* %15, i32 0, i32 256)
store i64 0, i64* %2
br label %17
17: ; preds = %36, %13
%18 = load i64, i64* %2
%19 = icmp ult i64 %18, 256
br i1 %19, label %20, label %39
20: ; preds = %17
br label %21
21: ; preds = %25, %20
%22 = call i32 (...) @random()
%23 = and i32 %22, 127
%24 = trunc i32 %23 to i8
store i8 %24, i8* %3
br label %25
25: ; preds = %21
%26 = load i8, i8* %3
%27 = icmp ne i8 %26, 0
%28 = xor i1 %27, true
br i1 %28, label %21, label %29
29: ; preds = %25
%30 = load i8, i8* %3
%31 = load i8*, i8** %1
%32 = load i64, i64* %2
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8 %30, i8* %33
%34 = load i8*, i8** %1
%35 = call i32 @test_one(i8* %34)
br label %36
36: ; preds = %29
%37 = load i64, i64* %2
%38 = add i64 %37, 1
store i64 %38, i64* %2
br label %17
39: ; preds = %17
store i64 0, i64* %2
br label %40
40: ; preds = %79, %39
%41 = load i64, i64* %2
%42 = icmp ult i64 %41, 1000
br i1 %42, label %43, label %82
43: ; preds = %40
store i64 0, i64* %4
br label %44
44: ; preds = %61, %43
%45 = load i64, i64* %4
%46 = icmp ult i64 %45, 256
br i1 %46, label %47, label %64
47: ; preds = %44
br label %48
48: ; preds = %52, %47
%49 = call i32 (...) @random()
%50 = and i32 %49, 127
%51 = trunc i32 %50 to i8
store i8 %51, i8* %5
br label %52
52: ; preds = %48
%53 = load i8, i8* %5
%54 = icmp ne i8 %53, 0
%55 = xor i1 %54, true
br i1 %55, label %48, label %56
56: ; preds = %52
%57 = load i8, i8* %5
%58 = load i8*, i8** %1
%59 = load i64, i64* %4
%60 = getelementptr inbounds i8, i8* %58, i64 %59
store i8 %57, i8* %60
br label %61
61: ; preds = %56
%62 = load i64, i64* %4
%63 = add i64 %62, 1
store i64 %63, i64* %4
br label %44
64: ; preds = %44
store i64 0, i64* %4
br label %65
65: ; preds = %75, %64
%66 = load i64, i64* %4
%67 = icmp ult i64 %66, 8
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = load i8*, i8** %1
%70 = load i64, i64* %4
%71 = sub i64 255, %70
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 0, i8* %72
%73 = load i8*, i8** %1
%74 = call i32 @test_one(i8* %73)
br label %75
75: ; preds = %68
%76 = load i64, i64* %4
%77 = add i64 %76, 1
store i64 %77, i64* %4
br label %65
78: ; preds = %65
br label %79
79: ; preds = %78
%80 = load i64, i64* %2
%81 = add i64 %80, 1
store i64 %81, i64* %2
br label %40
82: ; preds = %40
store i64 0, i64* %2
br label %83
83: ; preds = %100, %82
%84 = load i64, i64* %2
%85 = icmp ult i64 %84, 256
br i1 %85, label %86, label %103
86: ; preds = %83
br label %87
87: ; preds = %91, %86
%88 = call i32 (...) @random()
%89 = and i32 %88, 127
%90 = trunc i32 %89 to i8
store i8 %90, i8* %6
br label %91
91: ; preds = %87
%92 = load i8, i8* %6
%93 = icmp ne i8 %92, 0
%94 = xor i1 %93, true
br i1 %94, label %87, label %95
95: ; preds = %91
%96 = load i8, i8* %6
%97 = load i8*, i8** %1
%98 = load i64, i64* %2
%99 = getelementptr inbounds i8, i8* %97, i64 %98
store i8 %96, i8* %99
br label %100
100: ; preds = %95
%101 = load i64, i64* %2
%102 = add i64 %101, 1
store i64 %102, i64* %2
br label %83
103: ; preds = %83
%104 = load i8*, i8** %1
%105 = call i32 @bench_test(i8* %104)
%106 = load i8*, i8** %1
%107 = getelementptr inbounds i8, i8* %106, i64 16
store i8 0, i8* %107
%108 = load i8*, i8** %1
%109 = call i32 @bench_test(i8* %108)
%110 = load i8*, i8** %1
%111 = getelementptr inbounds i8, i8* %110, i64 8
store i8 0, i8* %111
%112 = load i8*, i8** %1
%113 = call i32 @bench_test(i8* %112)
%114 = load i8*, i8** %1
%115 = getelementptr inbounds i8, i8* %114, i64 4
store i8 0, i8* %115
%116 = load i8*, i8** %1
%117 = call i32 @bench_test(i8* %116)
%118 = load i8*, i8** %1
%119 = getelementptr inbounds i8, i8* %118, i64 3
store i8 0, i8* %119
%120 = load i8*, i8** %1
%121 = call i32 @bench_test(i8* %120)
%122 = load i8*, i8** %1
%123 = getelementptr inbounds i8, i8* %122, i64 2
store i8 0, i8* %123
%124 = load i8*, i8** %1
%125 = call i32 @bench_test(i8* %124)
%126 = load i8*, i8** %1
%127 = getelementptr inbounds i8, i8* %126, i64 1
store i8 0, i8* %127
%128 = load i8*, i8** %1
%129 = call i32 @bench_test(i8* %128)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"memalign\00"
define i32 @testcase() {
%1 = tail call align 128 dereferenceable_or_null(256) i8* @memalign(i32 128, i32 256)
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32 @srandom(i32 1)
%8 = tail call i32 @memset(i8* %1, i32 0, i32 256)
br label %9
9: ; preds = %6, %16
%10 = phi i64 [ 0, %6 ], [ %19, %16 ]
br label %11
11: ; preds = %9, %11
%12 = tail call i32 (...) @random()
%13 = trunc i32 %12 to i8
%14 = and i8 %13, 127
%15 = icmp eq i8 %14, 0
br i1 %15, label %11, label %16
16: ; preds = %11
%17 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 %14, i8* %17
%18 = tail call i32 @test_one(i8* %1)
%19 = add nuw nsw i64 %10, 1
%20 = icmp eq i64 %19, 256
br i1 %20, label %21, label %9
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %1, i64 255
%23 = getelementptr inbounds i8, i8* %1, i64 254
%24 = getelementptr inbounds i8, i8* %1, i64 253
%25 = getelementptr inbounds i8, i8* %1, i64 252
%26 = getelementptr inbounds i8, i8* %1, i64 251
%27 = getelementptr inbounds i8, i8* %1, i64 250
%28 = getelementptr inbounds i8, i8* %1, i64 249
%29 = getelementptr inbounds i8, i8* %1, i64 248
br label %30
30: ; preds = %21, %43
%31 = phi i64 [ %52, %43 ], [ 0, %21 ]
br label %32
32: ; preds = %30, %39
%33 = phi i64 [ 0, %30 ], [ %41, %39 ]
br label %34
34: ; preds = %32, %34
%35 = tail call i32 (...) @random()
%36 = trunc i32 %35 to i8
%37 = and i8 %36, 127
%38 = icmp eq i8 %37, 0
br i1 %38, label %34, label %39
39: ; preds = %34
%40 = getelementptr inbounds i8, i8* %1, i64 %33
store i8 %37, i8* %40
%41 = add nuw nsw i64 %33, 1
%42 = icmp eq i64 %41, 256
br i1 %42, label %43, label %32
43: ; preds = %39
store i8 0, i8* %22
%44 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %23
%45 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %24
%46 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %25
%47 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %26
%48 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %27
%49 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %28
%50 = tail call i32 @test_one(i8* %1)
store i8 0, i8* %29
%51 = tail call i32 @test_one(i8* %1)
%52 = add nuw nsw i64 %31, 1
%53 = icmp eq i64 %52, 1000
br i1 %53, label %54, label %30
54: ; preds = %43, %61
%55 = phi i64 [ %63, %61 ], [ 0, %43 ]
br label %56
56: ; preds = %54, %56
%57 = tail call i32 (...) @random()
%58 = trunc i32 %57 to i8
%59 = and i8 %58, 127
%60 = icmp eq i8 %59, 0
br i1 %60, label %56, label %61
61: ; preds = %56
%62 = getelementptr inbounds i8, i8* %1, i64 %55
store i8 %59, i8* %62
%63 = add nuw nsw i64 %55, 1
%64 = icmp eq i64 %63, 256
br i1 %64, label %65, label %54
65: ; preds = %61
%66 = tail call i32 @bench_test(i8* %1)
%67 = getelementptr inbounds i8, i8* %1, i64 16
store i8 0, i8* %67
%68 = tail call i32 @bench_test(i8* %1)
%69 = getelementptr inbounds i8, i8* %1, i64 8
store i8 0, i8* %69
%70 = tail call i32 @bench_test(i8* %1)
%71 = getelementptr inbounds i8, i8* %1, i64 4
store i8 0, i8* %71
%72 = tail call i32 @bench_test(i8* %1)
%73 = getelementptr inbounds i8, i8* %1, i64 3
store i8 0, i8* %73
%74 = tail call i32 @bench_test(i8* %1)
%75 = getelementptr inbounds i8, i8* %1, i64 2
store i8 0, i8* %75
%76 = tail call i32 @bench_test(i8* %1)
%77 = getelementptr inbounds i8, i8* %1, i64 1
store i8 0, i8* %77
%78 = tail call i32 @bench_test(i8* %1)
ret i32 0
}