#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ fs_test_init();
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ remove_all_files();
int /*<<< orphan*/ test_append_file();
int /*<<< orphan*/ test_create_file();
int /*<<< orphan*/ test_lseek_file();
int /*<<< orphan*/ test_read_verify_all_files();
int /*<<< orphan*/ test_read_verify_file();
int /*<<< orphan*/ test_remove_file();
int /*<<< orphan*/ test_rewrite_file();
int /*<<< orphan*/ test_stat_file();
bool fs_load_test_run(int32_t iterations) {
  fs_test_init();
  for (int32_t i = 0; i < iterations; i++) {
    int op = rand() % ((10 + (10 + (10 + (10 + (10 + (20 + (20))))))));
    if (op < (20)) {
      if (!test_create_file()) {
        return false;
      }
    } else if (op < (20 + (20))) {
      if (!test_read_verify_file()) {
        return false;
      }
    } else if (op < (10 + (20 + (20)))) {
      if (!test_rewrite_file()) {
        return false;
      }
    } else if (op < (10 + (10 + (20 + (20))))) {
      if (!test_append_file()) {
        return false;
      }
    } else if (op < (10 + (10 + (10 + (20 + (20)))))) {
      if (!test_remove_file()) {
        return false;
      }
    } else if (op < (10 + (10 + (10 + (10 + (20 + (20))))))) {
      if (!test_lseek_file()) {
        return false;
      }
    } else if (op < (10 + (10 + (10 + (10 + (10 + (20 + (20)))))))) {
      if (!test_stat_file()) {
        return false;
      }
    }
    printf("Testing %d%%\n", 100 * i / iterations);
  }
  if (!test_read_verify_all_files()) {
    return false;
  }
  if (!remove_all_files()) {
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<fs_load_test_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   10b0 <fs_test_init@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1366 <fs_load_test_run+0x1a6>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x5a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    1222 <fs_load_test_run+0x62>
mov    $0x0,%al
call   1050 <test_create_file@plt>
cmp    $0x0,%eax
jne    121d <fs_load_test_run+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    1342 <fs_load_test_run+0x182>
cmpl   $0x28,-0x10(%rbp)
jge    124d <fs_load_test_run+0x8d>
mov    $0x0,%al
call   10e0 <test_read_verify_file@plt>
cmp    $0x0,%eax
jne    1248 <fs_load_test_run+0x88>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    133d <fs_load_test_run+0x17d>
cmpl   $0x32,-0x10(%rbp)
jge    1278 <fs_load_test_run+0xb8>
mov    $0x0,%al
call   1090 <test_rewrite_file@plt>
cmp    $0x0,%eax
jne    1273 <fs_load_test_run+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    1338 <fs_load_test_run+0x178>
cmpl   $0x3c,-0x10(%rbp)
jge    12a3 <fs_load_test_run+0xe3>
mov    $0x0,%al
call   1030 <test_append_file@plt>
cmp    $0x0,%eax
jne    129e <fs_load_test_run+0xde>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    1333 <fs_load_test_run+0x173>
cmpl   $0x46,-0x10(%rbp)
jge    12ce <fs_load_test_run+0x10e>
mov    $0x0,%al
call   1080 <test_remove_file@plt>
cmp    $0x0,%eax
jne    12c9 <fs_load_test_run+0x109>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    132e <fs_load_test_run+0x16e>
cmpl   $0x50,-0x10(%rbp)
jge    12f9 <fs_load_test_run+0x139>
mov    $0x0,%al
call   10a0 <test_lseek_file@plt>
cmp    $0x0,%eax
jne    12f4 <fs_load_test_run+0x134>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    1329 <fs_load_test_run+0x169>
cmpl   $0x5a,-0x10(%rbp)
jge    1324 <fs_load_test_run+0x164>
mov    $0x0,%al
call   10c0 <test_stat_file@plt>
cmp    $0x0,%eax
jne    131f <fs_load_test_run+0x15f>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
jmp    1324 <fs_load_test_run+0x164>
jmp    1329 <fs_load_test_run+0x169>
jmp    132e <fs_load_test_run+0x16e>
jmp    1333 <fs_load_test_run+0x173>
jmp    1338 <fs_load_test_run+0x178>
jmp    133d <fs_load_test_run+0x17d>
jmp    1342 <fs_load_test_run+0x182>
imul   $0x64,-0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%esi
lea    0xcad(%rip),%rdi
call   1060 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <fs_load_test_run+0x19>
mov    $0x0,%al
call   1070 <test_read_verify_all_files@plt>
cmp    $0x0,%eax
jne    1382 <fs_load_test_run+0x1c2>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
mov    $0x0,%al
call   1040 <remove_all_files@plt>
cmp    $0x0,%eax
jne    139e <fs_load_test_run+0x1de>
movl   $0x0,-0x4(%rbp)
jmp    13a5 <fs_load_test_run+0x1e5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fs_load_test_run>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
xor    %eax,%eax
call   10b0 <fs_test_init@plt>
test   %r15d,%r15d
jle    12dc <fs_load_test_run+0x11c>
lea    0xe1e(%rip),%r14
xor    %ebp,%ebp
mov    %r15d,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x5a,%ecx,%ecx
sub    %ecx,%eax
xor    %r12d,%r12d
cmp    $0x13,%eax
jg     1240 <fs_load_test_run+0x80>
xor    %eax,%eax
call   1050 <test_create_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x27,%eax
ja     1260 <fs_load_test_run+0xa0>
xor    %eax,%eax
call   10e0 <test_read_verify_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x31,%eax
ja     1275 <fs_load_test_run+0xb5>
xor    %eax,%eax
call   1090 <test_rewrite_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
cmp    $0x3b,%eax
ja     1287 <fs_load_test_run+0xc7>
xor    %eax,%eax
call   1030 <test_append_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
cmp    $0x45,%eax
ja     1299 <fs_load_test_run+0xd9>
xor    %eax,%eax
call   1080 <test_remove_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
cmp    $0x4f,%eax
ja     12ab <fs_load_test_run+0xeb>
xor    %eax,%eax
call   10a0 <test_lseek_file@plt>
test   %eax,%eax
jne    12c0 <fs_load_test_run+0x100>
jmp    12fd <fs_load_test_run+0x13d>
xor    %eax,%eax
call   10c0 <test_stat_file@plt>
test   %eax,%eax
je     12fd <fs_load_test_run+0x13d>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <printf@plt>
add    $0x64,%ebp
add    $0xffffffff,%ebx
jne    11f0 <fs_load_test_run+0x30>
xor    %eax,%eax
call   1070 <test_read_verify_all_files@plt>
mov    $0x0,%r12d
test   %eax,%eax
je     12fd <fs_load_test_run+0x13d>
xor    %eax,%eax
call   1040 <remove_all_files@plt>
xor    %r12d,%r12d
test   %eax,%eax
setne  %r12b
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Testing %d%%\0A\00"
define i32 @fs_load_test_run(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = call i32 (...) @fs_test_init()
store i32 0, i32* %4
br label %7
7: ; preds = %81, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %84
11: ; preds = %7
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 90
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 20
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = call i32 (...) @test_create_file()
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
store i32 0, i32* %2
br label %93
20: ; preds = %16
br label %75
21: ; preds = %11
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 40
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = call i32 (...) @test_read_verify_file()
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24
store i32 0, i32* %2
br label %93
28: ; preds = %24
br label %74
29: ; preds = %21
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 50
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = call i32 (...) @test_rewrite_file()
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %32
store i32 0, i32* %2
br label %93
36: ; preds = %32
br label %73
37: ; preds = %29
%38 = load i32, i32* %5
%39 = icmp slt i32 %38, 60
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = call i32 (...) @test_append_file()
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %40
store i32 0, i32* %2
br label %93
44: ; preds = %40
br label %72
45: ; preds = %37
%46 = load i32, i32* %5
%47 = icmp slt i32 %46, 70
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = call i32 (...) @test_remove_file()
%50 = icmp ne i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %48
store i32 0, i32* %2
br label %93
52: ; preds = %48
br label %71
53: ; preds = %45
%54 = load i32, i32* %5
%55 = icmp slt i32 %54, 80
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = call i32 (...) @test_lseek_file()
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %56
store i32 0, i32* %2
br label %93
60: ; preds = %56
br label %70
61: ; preds = %53
%62 = load i32, i32* %5
%63 = icmp slt i32 %62, 90
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = call i32 (...) @test_stat_file()
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %64
store i32 0, i32* %2
br label %93
68: ; preds = %64
br label %69
69: ; preds = %68, %61
br label %70
70: ; preds = %69, %60
br label %71
71: ; preds = %70, %52
br label %72
72: ; preds = %71, %44
br label %73
73: ; preds = %72, %36
br label %74
74: ; preds = %73, %28
br label %75
75: ; preds = %74, %20
%76 = load i32, i32* %4
%77 = mul nsw i32 100, %76
%78 = load i32, i32* %3
%79 = sdiv i32 %77, %78
%80 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %7
84: ; preds = %7
%85 = call i32 (...) @test_read_verify_all_files()
%86 = icmp ne i32 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %84
store i32 0, i32* %2
br label %93
88: ; preds = %84
%89 = call i32 (...) @remove_all_files()
%90 = icmp ne i32 %89, 0
br i1 %90, label %92, label %91
91: ; preds = %88
store i32 0, i32* %2
br label %93
92: ; preds = %88
store i32 1, i32* %2
br label %93
93: ; preds = %92, %91, %87, %67, %59, %51, %43, %35, %27, %19
%94 = load i32, i32* %2
ret i32 %94
}

LLVM IR (-O2):
@.str = [14 x i8] c"Testing %d%%\0A\00"
define i32 @fs_load_test_run(i32 %0) {
%2 = tail call i32 (...) @fs_test_init()
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %46
4: ; preds = %1, %40
%5 = phi i32 [ %44, %40 ], [ 0, %1 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 90
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 (...) @test_create_file()
%11 = icmp eq i32 %10, 0
br i1 %11, label %53, label %40
12: ; preds = %4
%13 = icmp ult i32 %7, 40
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 (...) @test_read_verify_file()
%16 = icmp eq i32 %15, 0
br i1 %16, label %53, label %40
17: ; preds = %12
%18 = icmp ult i32 %7, 50
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = tail call i32 (...) @test_rewrite_file()
%21 = icmp eq i32 %20, 0
br i1 %21, label %53, label %40
22: ; preds = %17
%23 = icmp ult i32 %7, 60
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = tail call i32 (...) @test_append_file()
%26 = icmp eq i32 %25, 0
br i1 %26, label %53, label %40
27: ; preds = %22
%28 = icmp ult i32 %7, 70
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = tail call i32 (...) @test_remove_file()
%31 = icmp eq i32 %30, 0
br i1 %31, label %53, label %40
32: ; preds = %27
%33 = icmp ult i32 %7, 80
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = tail call i32 (...) @test_lseek_file()
%36 = icmp eq i32 %35, 0
br i1 %36, label %53, label %40
37: ; preds = %32
%38 = tail call i32 (...) @test_stat_file()
%39 = icmp eq i32 %38, 0
br i1 %39, label %53, label %40
40: ; preds = %14, %24, %34, %37, %29, %19, %9
%41 = mul nsw i32 %5, 100
%42 = sdiv i32 %41, %0
%43 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i32 %5, 1
%45 = icmp eq i32 %44, %0
br i1 %45, label %46, label %4
46: ; preds = %40, %1
%47 = tail call i32 (...) @test_read_verify_all_files()
%48 = icmp eq i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = tail call i32 (...) @remove_all_files()
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i32
br label %53
53: ; preds = %9, %14, %19, %24, %29, %34, %37, %49, %46
%54 = phi i32 [ 0, %46 ], [ %52, %49 ], [ 0, %37 ], [ 0, %34 ], [ 0, %29 ], [ 0, %24 ], [ 0, %19 ], [ 0, %14 ], [ 0, %9 ]
ret i32 %54
}