#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char const *);
scalar_t__ test1(int);
scalar_t__ test2(int);
scalar_t__ test3(int);
int main(int argc, char **argv) {
  const char *testname = NULL;
  int retval = EXIT_SUCCESS;
  if (argc > 1)
    testname = argv[1];
  if (!testname || (strcmp("test1", testname) == 0)) {
    fputs("test1"
          "... ",
          stdout);
    fflush(stdout);
    if (test1(100) == 0) {
      fputs("success\n", stdout);
    } else {
      fputs("failure\n", stdout);
      retval = EXIT_FAILURE;
    }
  }
  if (!testname || (strcmp("test2", testname) == 0)) {
    fputs("test2"
          "... ",
          stdout);
    fflush(stdout);
    if (test2(100) == 0) {
      fputs("success\n", stdout);
    } else {
      fputs("failure\n", stdout);
      retval = EXIT_FAILURE;
    }
  }
  if (!testname || (strcmp("test3", testname) == 0)) {
    fputs("test3"
          "... ",
          stdout);
    fflush(stdout);
    if (test3(100) == 0) {
      fputs("success\n", stdout);
    } else {
      fputs("failure\n", stdout);
      retval = EXIT_FAILURE;
    }
  }
  return retval;
}


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)
movq   $0x0,-0x18(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a0 <main+0x40>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c5 <main+0x65>
mov    -0x18(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <main+0xdc>
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
lea    0xe31(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1040 <test1@plt>
cmp    $0x0,%rax
jne    1216 <main+0xb6>
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
lea    0xe04(%rip),%rdi
call   1050 <fputs@plt>
jmp    1237 <main+0xd7>
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
lea    0xdf3(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    123c <main+0xdc>
cmpq   $0x0,-0x18(%rbp)
je     1261 <main+0x101>
mov    -0x18(%rbp),%rsi
lea    0xdd0(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12d8 <main+0x178>
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
lea    0xdb7(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1080 <test2@plt>
cmp    $0x0,%rax
jne    12b2 <main+0x152>
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
lea    0xd68(%rip),%rdi
call   1050 <fputs@plt>
jmp    12d3 <main+0x173>
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
lea    0xd57(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    12d8 <main+0x178>
cmpq   $0x0,-0x18(%rbp)
je     12fd <main+0x19d>
mov    -0x18(%rbp),%rsi
lea    0xd44(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1374 <main+0x214>
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
lea    0xd2b(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1030 <test3@plt>
cmp    $0x0,%rax
jne    134e <main+0x1ee>
mov    0x2c9d(%rip),%rax
mov    (%rax),%esi
lea    0xccc(%rip),%rdi
call   1050 <fputs@plt>
jmp    136f <main+0x20f>
mov    0x2c83(%rip),%rax
mov    (%rax),%esi
lea    0xcbb(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1374 <main+0x214>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e62(%rip),%rax
mov    (%rax),%r14d
mov    $0x1,%bpl
cmp    $0x2,%edi
jl     119a <main+0x3a>
mov    0x8(%rsi),%r15
test   %r15,%r15
je     119a <main+0x3a>
lea    0xe77(%rip),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11f5 <main+0x95>
xor    %ebp,%ebp
jmp    119d <main+0x3d>
xor    %r15d,%r15d
mov    0x2e34(%rip),%rbx
mov    (%rbx),%esi
lea    0xe59(%rip),%rdi
call   1050 <fputs@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1040 <test1@plt>
mov    (%rbx),%esi
test   %rax,%rax
je     11e2 <main+0x82>
lea    0xe48(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%r14d
jmp    11ee <main+0x8e>
lea    0xe27(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%bl
test   %bpl,%bpl
jne    120b <main+0xab>
lea    0xe26(%rip),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1267 <main+0x107>
xor    %ebx,%ebx
mov    0x2dc6(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1050 <fputs@plt>
mov    0x0(%rbp),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1080 <test2@plt>
mov    0x0(%rbp),%esi
test   %rax,%rax
je     1257 <main+0xf7>
lea    0xdd7(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%r14d
test   %bl,%bl
je     1267 <main+0x107>
jmp    127b <main+0x11b>
lea    0xdb2(%rip),%rdi
call   1050 <fputs@plt>
test   %bl,%bl
jne    127b <main+0x11b>
lea    0xdc4(%rip),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12cc <main+0x16c>
mov    0x2d56(%rip),%rbx
mov    (%rbx),%esi
lea    0xdad(%rip),%rdi
call   1050 <fputs@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    $0x64,%edi
call   1030 <test3@plt>
mov    (%rbx),%esi
test   %rax,%rax
je     12c0 <main+0x160>
lea    0xd6a(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%r14d
jmp    12cc <main+0x16c>
lea    0xd49(%rip),%rdi
call   1050 <fputs@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [6 x i8] c"test1\00"
@.str.1 = [10 x i8] c"test1... \00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"success\0A\00"
@.str.3 = [9 x i8] c"failure\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [6 x i8] c"test2\00"
@.str.5 = [10 x i8] c"test2... \00"
@.str.6 = [6 x i8] c"test3\00"
@.str.7 = [10 x i8] c"test3... \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%8 = load i32, i32* @EXIT_SUCCESS
store i32 %8, i32* %7
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %6
br label %15
15: ; preds = %11, %2
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %18, %15
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
%27 = call i64 @test1(i32 100)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* @stdout
%31 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %36
32: ; preds = %22
%33 = load i32, i32* @stdout
%34 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %7
br label %36
36: ; preds = %32, %29
br label %37
37: ; preds = %36, %18
%38 = load i8*, i8** %6
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i8*, i8** %6
%42 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %59
44: ; preds = %40, %37
%45 = load i32, i32* @stdout
%46 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @stdout
%48 = call i32 @fflush(i32 %47)
%49 = call i64 @test2(i32 100)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %44
%52 = load i32, i32* @stdout
%53 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %58
54: ; preds = %44
%55 = load i32, i32* @stdout
%56 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %7
br label %58
58: ; preds = %54, %51
br label %59
59: ; preds = %58, %40
%60 = load i8*, i8** %6
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i8*, i8** %6
%64 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %81
66: ; preds = %62, %59
%67 = load i32, i32* @stdout
%68 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %67)
%69 = load i32, i32* @stdout
%70 = call i32 @fflush(i32 %69)
%71 = call i64 @test3(i32 100)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = load i32, i32* @stdout
%75 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %74)
br label %80
76: ; preds = %66
%77 = load i32, i32* @stdout
%78 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %77)
%79 = load i32, i32* @EXIT_FAILURE
store i32 %79, i32* %7
br label %80
80: ; preds = %76, %73
br label %81
81: ; preds = %80, %62
%82 = load i32, i32* %7
ret i32 %82
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [6 x i8] c"test1\00"
@.str.1 = [10 x i8] c"test1... \00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"success\0A\00"
@.str.3 = [9 x i8] c"failure\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [6 x i8] c"test2\00"
@.str.5 = [10 x i8] c"test2... \00"
@.str.6 = [6 x i8] c"test3\00"
@.str.7 = [10 x i8] c"test3... \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @EXIT_SUCCESS
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %2, %9, %5
%13 = phi i1 [ false, %9 ], [ true, %5 ], [ true, %2 ]
%14 = phi i8* [ %7, %9 ], [ null, %5 ], [ null, %2 ]
%15 = load i32, i32* @stdout
%16 = tail call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @stdout
%18 = tail call i32 @fflush(i32 %17)
%19 = tail call i64 @test1(i32 100)
%20 = icmp eq i64 %19, 0
%21 = load i32, i32* @stdout
br i1 %20, label %22, label %24
22: ; preds = %12
%23 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br i1 %13, label %32, label %27
24: ; preds = %12
%25 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%26 = load i32, i32* @EXIT_FAILURE
br i1 %13, label %32, label %27
27: ; preds = %9, %22, %24
%28 = phi i32 [ %26, %24 ], [ %3, %22 ], [ %3, %9 ]
%29 = phi i8* [ %14, %24 ], [ %14, %22 ], [ %7, %9 ]
%30 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %48
32: ; preds = %22, %27, %24
%33 = phi i32 [ %28, %27 ], [ %26, %24 ], [ %3, %22 ]
%34 = phi i1 [ false, %27 ], [ true, %24 ], [ true, %22 ]
%35 = phi i8* [ %29, %27 ], [ %14, %24 ], [ %14, %22 ]
%36 = load i32, i32* @stdout
%37 = tail call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = load i32, i32* @stdout
%39 = tail call i32 @fflush(i32 %38)
%40 = tail call i64 @test2(i32 100)
%41 = icmp eq i64 %40, 0
%42 = load i32, i32* @stdout
br i1 %41, label %43, label %45
43: ; preds = %32
%44 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br i1 %34, label %53, label %48
45: ; preds = %32
%46 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%47 = load i32, i32* @EXIT_FAILURE
br i1 %34, label %53, label %48
48: ; preds = %27, %43, %45
%49 = phi i32 [ %47, %45 ], [ %33, %43 ], [ %28, %27 ]
%50 = phi i8* [ %35, %45 ], [ %35, %43 ], [ %29, %27 ]
%51 = tail call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %67
53: ; preds = %43, %48, %45
%54 = phi i32 [ %49, %48 ], [ %47, %45 ], [ %33, %43 ]
%55 = load i32, i32* @stdout
%56 = tail call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @stdout
%58 = tail call i32 @fflush(i32 %57)
%59 = tail call i64 @test3(i32 100)
%60 = icmp eq i64 %59, 0
%61 = load i32, i32* @stdout
br i1 %60, label %62, label %64
62: ; preds = %53
%63 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %61)
br label %67
64: ; preds = %53
%65 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%66 = load i32, i32* @EXIT_FAILURE
br label %67
67: ; preds = %62, %64, %48
%68 = phi i32 [ %54, %62 ], [ %66, %64 ], [ %49, %48 ]
ret i32 %68
}