#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ clock();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ *stderr;
scalar_t__ test_mio_in();
scalar_t__ test_orbel_zget(int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  if (argc > 2) {
    fputs("main.bin usage: ./main.bin [logfile]", stderr);
    exit(EXIT_FAILURE);
  }
  srand(clock());
  FILE *fp = NULL;
  if (argc == 1) {
    fp = stderr;
  } else if (argc == 2) {
    fp = fopen(argv[1], "w+");
  }
  printf("test_mio_in: %s\n", test_mio_in() ? "FAILURE" : "SUCCESS");
  printf("test_orbel_zget: %s\n",
         test_orbel_zget(stderr, 100) ? "FAILURE" : "SUCCESS");
  exit(EXIT_SUCCESS);
}


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)
cmpl   $0x2,-0x8(%rbp)
jle    11c4 <main+0x44>
mov    0x2e39(%rip),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f7 <main+0x77>
mov    0x2df5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    121e <main+0x9e>
cmpl   $0x2,-0x8(%rbp)
jne    1219 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe15(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    121e <main+0x9e>
mov    $0x0,%al
call   1070 <test_mio_in@plt>
mov    %rax,%rcx
lea    0xe12(%rip),%rsi
lea    0xe03(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%rdi
mov    $0x64,%esi
call   1080 <test_orbel_zget@plt>
mov    %rax,%rcx
lea    0xdd9(%rip),%rsi
lea    0xdca(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xdcb(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     11b6 <main+0x36>
mov    0x2e51(%rip),%rax
mov    (%rax),%rcx
lea    0xe67(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmp    $0x2,%ebp
jne    11de <main+0x5e>
mov    0x8(%rbx),%rdi
lea    0xe4c(%rip),%rsi
call   1080 <fopen@plt>
xor    %eax,%eax
call   1060 <test_mio_in@plt>
test   %rax,%rax
lea    0xe52(%rip),%rbp
lea    0xe43(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%rdi
mov    $0x64,%esi
call   1070 <test_orbel_zget@plt>
test   %rax,%rax
cmove  %rbp,%rbx
lea    0xe1e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"main.bin usage: ./main.bin [logfile]\00"
@stderr = global i32* null
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [17 x i8] c"test_mio_in: %s\0A\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [8 x i8] c"SUCCESS\00"
@.str.5 = [21 x i8] c"test_orbel_zget: %s\0A\00"
@EXIT_SUCCESS = global i32 0
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 = load i32, i32* %4
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32*, i32** @stderr
%11 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = call i32 (...) @clock()
%16 = call i32 @srand(i32 %15)
store i32* null, i32** %6
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32*, i32** @stderr
store i32* %20, i32** %6
br label %30
21: ; preds = %14
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %6
br label %29
29: ; preds = %24, %21
br label %30
30: ; preds = %29, %19
%31 = call i64 (...) @test_mio_in()
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32*, i32** @stderr
%37 = call i64 @test_orbel_zget(i32* %36, i32 100)
%38 = icmp ne i64 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%41 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_SUCCESS
%43 = call i32 @exit(i32 %42)
unreachable
}

LLVM IR (-O2):
@.str = [37 x i8] c"main.bin usage: ./main.bin [logfile]\00"
@stderr = global i32* null
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [17 x i8] c"test_mio_in: %s\0A\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [8 x i8] c"SUCCESS\00"
@.str.5 = [21 x i8] c"test_orbel_zget: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32*, i32** @stderr
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 36, i64 1, i32* %5)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = tail call i32 (...) @clock()
%11 = tail call i32 @srand(i32 %10)
%12 = icmp eq i32 %0, 2
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %9, %13
%18 = tail call i64 (...) @test_mio_in()
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** @stderr
%23 = tail call i64 @test_orbel_zget(i32* %22, i32 100)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_SUCCESS
%28 = tail call i32 @exit(i32 %27)
unreachable
}