#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ test(int, int);
scalar_t__ time(int /*<<< orphan*/ *);
void bulktester2() {
  int i;
  int testcount = 0;
  int correctcount = 0;
  int testlen = 64;
  int constant = 5;
  time_t t;
  srand((unsigned)time(&t));
  while (testlen < 8000000) {
    for (i = 0; i < 100; i++) {
      testcount++;
      if (test(i, testlen + constant)) {
        correctcount++;
        printf("Test %d on length %d correct\n", i + 1, testlen + constant);
      }
    }
    testlen <<= 1;
  }
  if (correctcount < testcount) {
    printf("Ran %d tests but only %d were correctly sorted.\n", testcount,
           correctcount);
  } else {
    printf("All %d tests were correctly sorted.\n", testcount);
  }
}


x86 assembly (clang, -O0):
<bulktester2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x40,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x7a1200,-0x10(%rbp)
jge    11f7 <bulktester2+0xb7>
movl   $0x0,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jge    11e9 <bulktester2+0xa9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
add    -0x14(%rbp),%esi
call   1060 <test@plt>
cmp    $0x0,%rax
je     11d6 <bulktester2+0x96>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
add    -0x14(%rbp),%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11db <bulktester2+0x9b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1188 <bulktester2+0x48>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1174 <bulktester2+0x34>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121c <bulktester2+0xdc>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122d <bulktester2+0xed>
mov    -0x8(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bulktester2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x40,%r12d
lea    0xe96(%rip),%r14
xor    %r15d,%r15d
jmp    117c <bulktester2+0x3c>
nop
add    %r12d,%r12d
cmp    $0x7a1200,%r12d
jge    11c2 <bulktester2+0x82>
mov    %r12d,%ebp
or     $0x5,%ebp
xor    %ebx,%ebx
jmp    11aa <bulktester2+0x6a>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x64,%ebx
je     1170 <bulktester2+0x30>
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <test@plt>
test   %rax,%rax
jne    1190 <bulktester2+0x50>
add    $0x1,%ebx
cmp    $0x64,%ebx
jne    11aa <bulktester2+0x6a>
jmp    1170 <bulktester2+0x30>
cmp    $0x6a3,%r15d
jle    11e0 <bulktester2+0xa0>
lea    0xe7d(%rip),%rdi
mov    $0x6a4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11f6 <bulktester2+0xb6>
lea    0xe37(%rip),%rdi
mov    $0x6a4,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Test %d on length %d correct\0A\00"
@.str.1 = [49 x i8] c"Ran %d tests but only %d were correctly sorted.\0A\00"
@.str.2 = [37 x i8] c"All %d tests were correctly sorted.\0A\00"
define void @bulktester2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
store i32 64, i32* %4
store i32 5, i32* %5
%7 = call i64 @time(i32* %6)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
br label %10
10: ; preds = %39, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 8000000
br i1 %12, label %13, label %42
13: ; preds = %10
store i32 0, i32* %1
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
%20 = load i32, i32* %1
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
%24 = call i64 @test(i32 %20, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = add nsw i32 %31, %32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %33)
br label %35
35: ; preds = %26, %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
br label %14
39: ; preds = %14
%40 = load i32, i32* %4
%41 = shl i32 %40, 1
store i32 %41, i32* %4
br label %10
42: ; preds = %10
%43 = load i32, i32* %3
%44 = load i32, i32* %2
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %48)
br label %53
50: ; preds = %42
%51 = load i32, i32* %2
%52 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %46
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Test %d on length %d correct\0A\00"
@.str.1 = [49 x i8] c"Ran %d tests but only %d were correctly sorted.\0A\00"
@.str.2 = [37 x i8] c"All %d tests were correctly sorted.\0A\00"
define void @bulktester2() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @time(i32* %1)
%4 = trunc i64 %3 to i32
%5 = call i32 @srand(i32 %4)
br label %6
6: ; preds = %0, %25
%7 = phi i32 [ 64, %0 ], [ %26, %25 ]
%8 = phi i32 [ 0, %0 ], [ %23, %25 ]
%9 = or i32 %7, 5
br label %10
10: ; preds = %6, %21
%11 = phi i32 [ 0, %6 ], [ %22, %21 ]
%12 = phi i32 [ %8, %6 ], [ %23, %21 ]
%13 = call i64 @test(i32 %11, i32 %9)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = add nuw nsw i32 %11, 1
br label %21
17: ; preds = %10
%18 = add nsw i32 %12, 1
%19 = add nuw nsw i32 %11, 1
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %9)
br label %21
21: ; preds = %15, %17
%22 = phi i32 [ %16, %15 ], [ %19, %17 ]
%23 = phi i32 [ %12, %15 ], [ %18, %17 ]
%24 = icmp eq i32 %22, 100
br i1 %24, label %25, label %10
25: ; preds = %21
%26 = shl i32 %7, 1
%27 = icmp slt i32 %26, 8000000
br i1 %27, label %6, label %28
28: ; preds = %25
%29 = icmp sgt i32 %23, 1699
br i1 %29, label %32, label %30
30: ; preds = %28
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 1700, i32 %23)
br label %34
32: ; preds = %28
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 1700)
br label %34
34: ; preds = %32, %30
ret void
}