#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*/ printf(char *, int, ...);
scalar_t__ test_and_verify_permutations(int, int);
void bulktester() {
  int i, testcount, correctcount, testlen;
  testcount = correctcount = 0;
  testlen = 64;
  while (testlen < 600000) {
    for (i = 0; i < 100; i++) {
      testcount++;
      if (test_and_verify_permutations(i, testlen + 7)) {
        correctcount++;
        printf("Test %d on length %d correctly sorted and is a permutation\n",
               i + 1, testlen + 7);
      }
    }
    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):
<bulktester>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x40,-0x10(%rbp)
cmpl   $0x927c0,-0x10(%rbp)
jge    11c0 <bulktester+0xa0>
movl   $0x0,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jge    11b2 <bulktester+0x92>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
add    $0x7,%esi
call   1040 <test_and_verify_permutations@plt>
cmp    $0x0,%rax
je     119f <bulktester+0x7f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
add    $0x7,%edx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <bulktester+0x84>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1151 <bulktester+0x31>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <bulktester+0x1d>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e5 <bulktester+0xc5>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f6 <bulktester+0xd6>
mov    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bulktester>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x40,%r12d
lea    0xecb(%rip),%r14
xor    %r15d,%r15d
jmp    114c <bulktester+0x2c>
nopw   0x0(%rax,%rax,1)
add    %r12d,%r12d
cmp    $0x927c0,%r12d
jge    1192 <bulktester+0x72>
mov    %r12d,%ebp
or     $0x7,%ebp
xor    %ebx,%ebx
jmp    117a <bulktester+0x5a>
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     1140 <bulktester+0x20>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <test_and_verify_permutations@plt>
test   %rax,%rax
jne    1160 <bulktester+0x40>
add    $0x1,%ebx
cmp    $0x64,%ebx
jne    117a <bulktester+0x5a>
jmp    1140 <bulktester+0x20>
cmp    $0x577,%r15d
jle    11b6 <bulktester+0x96>
lea    0xecb(%rip),%rdi
mov    $0x578,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x578,%esi
mov    %r15d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"Test %d on length %d correctly sorted and is a permutation\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 @bulktester() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %2
store i32 64, i32* %4
br label %5
5: ; preds = %32, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 600000
br i1 %7, label %8, label %35
8: ; preds = %5
store i32 0, i32* %1
br label %9
9: ; preds = %29, %8
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = load i32, i32* %1
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 7
%18 = call i64 @test_and_verify_permutations(i32 %15, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 7
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %26)
br label %28
28: ; preds = %20, %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %1
%31 = add nsw i32 %30, 1
store i32 %31, i32* %1
br label %9
32: ; preds = %9
%33 = load i32, i32* %4
%34 = shl i32 %33, 1
store i32 %34, i32* %4
br label %5
35: ; preds = %5
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41)
br label %46
43: ; preds = %35
%44 = load i32, i32* %2
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %43, %39
ret void
}

LLVM IR (-O2):
@.str = [60 x i8] c"Test %d on length %d correctly sorted and is a permutation\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 @bulktester() {
br label %1
1: ; preds = %0, %20
%2 = phi i32 [ 64, %0 ], [ %21, %20 ]
%3 = phi i32 [ 0, %0 ], [ %18, %20 ]
%4 = or i32 %2, 7
br label %5
5: ; preds = %1, %16
%6 = phi i32 [ %3, %1 ], [ %18, %16 ]
%7 = phi i32 [ 0, %1 ], [ %17, %16 ]
%8 = tail call i64 @test_and_verify_permutations(i32 %7, i32 %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = add nuw nsw i32 %7, 1
br label %16
12: ; preds = %5
%13 = add nsw i32 %6, 1
%14 = add nuw nsw i32 %7, 1
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %4)
br label %16
16: ; preds = %10, %12
%17 = phi i32 [ %11, %10 ], [ %14, %12 ]
%18 = phi i32 [ %6, %10 ], [ %13, %12 ]
%19 = icmp eq i32 %17, 100
br i1 %19, label %20, label %5
20: ; preds = %16
%21 = shl i32 %2, 1
%22 = icmp slt i32 %21, 600000
br i1 %22, label %1, label %23
23: ; preds = %20
%24 = icmp sgt i32 %18, 1399
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 1400, i32 %18)
br label %29
27: ; preds = %23
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 1400)
br label %29
29: ; preds = %27, %25
ret void
}