#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 repl();
int run_tests();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int i = 0;
  int replMode = 0;
  int testMode = 0;
  for (i = 0; i < argc; i++) {
    if (strcmp(argv[i], "--repl") == 0)
      replMode = 1;
    else if (strcmp(argv[i], "--test") == 0)
      testMode = 1;
  }
  if (testMode != 0) {
    int testsFailed = run_tests();
    if (testsFailed != 0)
      printf("%d tests failed.\n", testsFailed);
    else
      printf("All tests passed.\n");
    return testsFailed;
  } else if (replMode != 0) {
    return repl();
  } else {
    printf("Supported command line switches:\n--repl\n--test\n");
    return 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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ed <main+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <main+0x6c>
movl   $0x1,-0x18(%rbp)
jmp    11da <main+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe48(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d5 <main+0x95>
movl   $0x1,-0x1c(%rbp)
jmp    11da <main+0x9a>
jmp    11df <main+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <main+0x32>
cmpl   $0x0,-0x1c(%rbp)
je     123a <main+0xfa>
mov    $0x0,%al
call   1060 <run_tests@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1221 <main+0xe1>
mov    -0x20(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122f <main+0xef>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1268 <main+0x128>
cmpl   $0x0,-0x18(%rbp)
je     1253 <main+0x113>
mov    $0x0,%al
call   1030 <repl@plt>
mov    %eax,-0x4(%rbp)
jmp    1268 <main+0x128>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1200 <main+0xb0>
mov    %rsi,%rbx
mov    %edi,%r12d
xor    %ebp,%ebp
lea    0xe8e(%rip),%r14
xor    %r15d,%r15d
xor    %r13d,%r13d
jmp    11a5 <main+0x55>
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    $0x1,%eax
cmove  %eax,%r15d
add    $0x1,%rbp
cmp    %rbp,%r12
je     11be <main+0x6e>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1180 <main+0x30>
mov    $0x1,%r13d
jmp    119c <main+0x4c>
test   %r15d,%r15d
je     11e6 <main+0x96>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <run_tests@plt>
test   %eax,%eax
je     1210 <main+0xc0>
mov    %eax,%ebp
lea    0xe2e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%ebx
jmp    121c <main+0xcc>
test   %r13d,%r13d
je     1200 <main+0xb0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <repl@plt>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    121c <main+0xcc>
lea    0xe31(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--repl\00"
@.str.1 = [7 x i8] c"--test\00"
@.str.2 = [18 x i8] c"%d tests failed.\0A\00"
@.str.3 = [19 x i8] c"All tests passed.\0A\00"
@.str.4 = [48 x i8] c"Supported command line switches:\0A--repl\0A--test\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %6
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 1, i32* %7
br label %33
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 1, i32* %8
br label %32
32: ; preds = %31, %23
br label %33
33: ; preds = %32, %22
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %10
37: ; preds = %10
%38 = load i32, i32* %8
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = call i32 (...) @run_tests()
store i32 %41, i32* %9
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %9
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %49
47: ; preds = %40
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = load i32, i32* %9
store i32 %50, i32* %3
br label %58
51: ; preds = %37
%52 = load i32, i32* %7
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (...) @repl()
store i32 %55, i32* %3
br label %58
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %58
58: ; preds = %56, %54, %49
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [7 x i8] c"--repl\00"
@.str.1 = [7 x i8] c"--test\00"
@.str.2 = [18 x i8] c"%d tests failed.\0A\00"
@str = [47 x i8] c"Supported command line switches:\0A--repl\0A--test\00"
@str.5 = [18 x i8] c"All tests passed.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %37
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %19
%7 = phi i64 [ 0, %4 ], [ %22, %19 ]
%8 = phi i32 [ 0, %4 ], [ %21, %19 ]
%9 = phi i32 [ 0, %4 ], [ %20, %19 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %7
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %6
%15 = load i8*, i8** %10
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i32 1, i32 %8
br label %19
19: ; preds = %14, %6
%20 = phi i32 [ 1, %6 ], [ %9, %14 ]
%21 = phi i32 [ %8, %6 ], [ %18, %14 ]
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %6
24: ; preds = %19
%25 = icmp eq i32 %21, 0
br i1 %25, label %33, label %26
26: ; preds = %24
%27 = tail call i32 (...) @run_tests()
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %39
31: ; preds = %26
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
br label %39
33: ; preds = %24
%34 = icmp eq i32 %20, 0
br i1 %34, label %37, label %35
35: ; preds = %33
%36 = tail call i32 (...) @repl()
br label %39
37: ; preds = %2, %33
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %39
39: ; preds = %29, %31, %37, %35
%40 = phi i32 [ %36, %35 ], [ 0, %37 ], [ 0, %31 ], [ %27, %29 ]
ret i32 %40
}