#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*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
scalar_t__ testone();
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  unsigned int i;
  srandom(time(NULL));
  for (i = 0; i < 131072; i++) {
    if (!(i & 1023)) {
      printf("%u\r", i);
      fflush(stdout);
    }
    if (testone())
      exit(1);
  }
  printf("OK\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20000,-0x14(%rbp)
jae    11f8 <main+0x98>
mov    -0x14(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
jne    11ca <main+0x6a>
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   1070 <testone@plt>
cmp    $0x0,%rax
je     11e5 <main+0x85>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11ea <main+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <main+0x2d>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
lea    0xe77(%rip),%r14
mov    0x2e50(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   $0x3ff,%ebp
jne    11bb <main+0x4b>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1080 <testone@plt>
test   %rax,%rax
jne    11e5 <main+0x75>
add    $0x1,%ebp
cmp    $0x20000,%ebp
jne    11a0 <main+0x30>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0D\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @time(i32* null)
%8 = call i32 @srandom(i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %6
%11 = icmp ult i32 %10, 131072
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %6
%14 = and i32 %13, 1023
%15 = icmp ne i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
br label %21
21: ; preds = %16, %12
%22 = call i64 (...) @testone()
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %21
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add i32 %28, 1
store i32 %29, i32* %6
br label %9
30: ; preds = %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0D\00"
@stdout = global i32 0
@str = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srandom(i32 %3)
br label %8
5: ; preds = %16
%6 = add nuw nsw i32 %9, 1
%7 = icmp eq i32 %6, 131072
br i1 %7, label %21, label %8
8: ; preds = %2, %5
%9 = phi i32 [ 0, %2 ], [ %6, %5 ]
%10 = and i32 %9, 1023
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
br label %16
16: ; preds = %12, %8
%17 = tail call i64 (...) @testone()
%18 = icmp eq i64 %17, 0
br i1 %18, label %5, label %19
19: ; preds = %16
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %5
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 0)
unreachable
}