#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_SUCCESS;
int /*<<< orphan*/ FAIL(char *);
int /*<<< orphan*/ PASS(char *);
int foo();
int fooPlusOne();
int /*<<< orphan*/ *getenv(char *);
int main() {
  if (getenv("TEN") != NULL) {
    if (foo() != 10)
      FAIL("symbol-resolver-basic: foo() != 10");
    else if (fooPlusOne() != 11)
      FAIL("symbol-resolver-basic: fooPlusOne() != 11");
    else
      PASS("symbol-resolver-basic");
  } else {
    if (foo() != 0)
      FAIL("symbol-resolver-basic: foo() != 0");
    else if (fooPlusOne() != 1)
      FAIL("symbol-resolver-basic: fooPlusOne() != 1");
    else
      PASS("symbol-resolver-basic");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11cd <main+0x7d>
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0xa,%eax
je     1196 <main+0x46>
lea    0xe78(%rip),%rdi
call   1070 <FAIL@plt>
jmp    11c8 <main+0x78>
mov    $0x0,%al
call   1050 <fooPlusOne@plt>
cmp    $0xb,%eax
je     11b7 <main+0x67>
lea    0xe7a(%rip),%rdi
call   1070 <FAIL@plt>
jmp    11c3 <main+0x73>
lea    0xe93(%rip),%rdi
call   1060 <PASS@plt>
jmp    11c8 <main+0x78>
jmp    1225 <main+0xd5>
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x0,%eax
je     11ee <main+0x9e>
lea    0xe83(%rip),%rdi
call   1070 <FAIL@plt>
jmp    1220 <main+0xd0>
mov    $0x0,%al
call   1050 <fooPlusOne@plt>
cmp    $0x1,%eax
je     120f <main+0xbf>
lea    0xe84(%rip),%rdi
call   1070 <FAIL@plt>
jmp    121b <main+0xcb>
lea    0xe3b(%rip),%rdi
call   1060 <PASS@plt>
jmp    1220 <main+0xd0>
jmp    1225 <main+0xd5>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <foo@plt>
test   %rbx,%rbx
je     1186 <main+0x36>
cmp    $0xa,%eax
jne    1193 <main+0x43>
xor    %eax,%eax
call   1050 <fooPlusOne@plt>
cmp    $0xb,%eax
je     11ad <main+0x5d>
lea    0xea3(%rip),%rdi
jmp    119a <main+0x4a>
test   %eax,%eax
je     11a1 <main+0x51>
lea    0xed6(%rip),%rdi
jmp    119a <main+0x4a>
lea    0xe6a(%rip),%rdi
call   1070 <FAIL@plt>
jmp    11b9 <main+0x69>
xor    %eax,%eax
call   1050 <fooPlusOne@plt>
cmp    $0x1,%eax
jne    11c4 <main+0x74>
lea    0xe9d(%rip),%rdi
call   1060 <PASS@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xebe(%rip),%rdi
jmp    119a <main+0x4a>

LLVM IR (-O0):
@.str = [4 x i8] c"TEN\00"
@.str.1 = [35 x i8] c"symbol-resolver-basic: foo() != 10\00"
@.str.2 = [42 x i8] c"symbol-resolver-basic: fooPlusOne() != 11\00"
@.str.3 = [22 x i8] c"symbol-resolver-basic\00"
@.str.4 = [34 x i8] c"symbol-resolver-basic: foo() != 0\00"
@.str.5 = [41 x i8] c"symbol-resolver-basic: fooPlusOne() != 1\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i32* %2, null
br i1 %3, label %4, label %18
4: ; preds = %0
%5 = call i32 (...) @foo()
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = call i32 @FAIL(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %17
9: ; preds = %4
%10 = call i32 (...) @fooPlusOne()
%11 = icmp ne i32 %10, 11
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @FAIL(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @PASS(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
br label %17
17: ; preds = %16, %7
br label %32
18: ; preds = %0
%19 = call i32 (...) @foo()
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @FAIL(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %31
23: ; preds = %18
%24 = call i32 (...) @fooPlusOne()
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @FAIL(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
br label %30
28: ; preds = %23
%29 = call i32 @PASS(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %17
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"TEN\00"
@.str.1 = [35 x i8] c"symbol-resolver-basic: foo() != 10\00"
@.str.2 = [42 x i8] c"symbol-resolver-basic: fooPlusOne() != 11\00"
@.str.3 = [22 x i8] c"symbol-resolver-basic\00"
@.str.4 = [34 x i8] c"symbol-resolver-basic: foo() != 0\00"
@.str.5 = [41 x i8] c"symbol-resolver-basic: fooPlusOne() != 1\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
%3 = tail call i32 (...) @foo()
br i1 %2, label %15, label %4
4: ; preds = %0
%5 = icmp eq i32 %3, 10
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @FAIL(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %26
8: ; preds = %4
%9 = tail call i32 (...) @fooPlusOne()
%10 = icmp eq i32 %9, 11
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @FAIL(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %26
13: ; preds = %8
%14 = tail call i32 @PASS(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %26
15: ; preds = %0
%16 = icmp eq i32 %3, 0
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 @FAIL(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %26
19: ; preds = %15
%20 = tail call i32 (...) @fooPlusOne()
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @FAIL(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = tail call i32 @PASS(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %17, %24, %22, %6, %13, %11
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}