#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*/ fill_and_sort(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ task_begin();
int /*<<< orphan*/ task_end();
scalar_t__ verify(int);
int main() {
  int failed;
  int row;
  srand(1);
  failed = 0;
  row = 0;
  while (row < 100) {
    task_begin();
    fill_and_sort(row);
    if (verify(row))
      failed = 1;
    task_end();
    row += 1;
  }
  if (failed == 1)
    printf("Failed!\n");
  else
    printf("OK!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1050 <srand@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11ce <main+0x6e>
mov    $0x0,%al
call   1080 <task_begin@plt>
mov    -0xc(%rbp),%edi
call   1030 <fill_and_sort@plt>
mov    -0xc(%rbp),%edi
call   1070 <verify@plt>
cmp    $0x0,%rax
je     11b9 <main+0x59>
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1060 <task_end@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1187 <main+0x27>
cmpl   $0x1,-0x8(%rbp)
jne    11e9 <main+0x89>
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
jmp    11f5 <main+0x95>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%r14d
mov    $0x1,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <task_begin@plt>
mov    %ebx,%edi
call   1030 <fill_and_sort@plt>
mov    %ebx,%edi
call   1070 <verify@plt>
test   %rax,%rax
cmovne %r14d,%ebp
xor    %eax,%eax
call   1060 <task_end@plt>
add    $0x1,%ebx
cmp    $0x64,%ebx
jne    1180 <main+0x20>
cmp    $0x1,%ebp
lea    0xe4f(%rip),%rax
lea    0xe44(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Failed!\0A\00"
@.str.1 = [5 x i8] c"OK!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @srand(i32 1)
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = call i32 (...) @task_begin()
%10 = load i32, i32* %3
%11 = call i32 @fill_and_sort(i32 %10)
%12 = load i32, i32* %3
%13 = call i64 @verify(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %8
store i32 1, i32* %2
br label %16
16: ; preds = %15, %8
%17 = call i32 (...) @task_end()
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %27
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@str = [4 x i8] c"OK!\00"
@str.2 = [8 x i8] c"Failed!\00"
define i32 @main() {
%1 = tail call i32 @srand(i32 1)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %11, %2 ]
%4 = phi i32 [ 0, %0 ], [ %9, %2 ]
%5 = tail call i32 (...) @task_begin()
%6 = tail call i32 @fill_and_sort(i32 %3)
%7 = tail call i64 @verify(i32 %3)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 %4, i32 1
%10 = tail call i32 (...) @task_end()
%11 = add nuw nsw i32 %3, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %2
13: ; preds = %2
%14 = icmp eq i32 %9, 1
%15 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret i32 0
}