#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 */
scalar_t__ foo();
int fooPlusOne();
int /*<<< orphan*/ printf(char *);
int main() {
  if (foo() != 0)
    printf("[FAIL] symbol-resolver-basic: foo() != 0\n");
  else if (fooPlusOne() != 1)
    printf("[FAIL] symbol-resolver-basic: fooPlusOne() != 1\n");
  else
    printf("[PASS] symbol-resolver-basic\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x0,%rax
je     1161 <main+0x31>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <main+0x63>
mov    $0x0,%al
call   1050 <fooPlusOne@plt>
cmp    $0x1,%eax
je     1182 <main+0x52>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    118e <main+0x5e>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <main+0x63>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <foo@plt>
test   %rax,%rax
je     1146 <main+0x16>
lea    0xf09(%rip),%rdi
jmp    1162 <main+0x32>
xor    %eax,%eax
call   1050 <fooPlusOne@plt>
cmp    $0x1,%eax
lea    0xea9(%rip),%rax
lea    0xebf(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"[FAIL] symbol-resolver-basic: foo() != 0\0A\00"
@.str.1 = [49 x i8] c"[FAIL] symbol-resolver-basic: fooPlusOne() != 1\0A\00"
@.str.2 = [30 x i8] c"[PASS] symbol-resolver-basic\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @foo()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %14
6: ; preds = %0
%7 = call i32 (...) @fooPlusOne()
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
br label %14
14: ; preds = %13, %4
ret i32 0
}

LLVM IR (-O2):
@str = [29 x i8] c"[PASS] symbol-resolver-basic\00"
@str.3 = [48 x i8] c"[FAIL] symbol-resolver-basic: fooPlusOne() != 1\00"
@str.4 = [41 x i8] c"[FAIL] symbol-resolver-basic: foo() != 0\00"
define i32 @main() {
%1 = tail call i64 (...) @foo()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 (...) @fooPlusOne()
%5 = icmp eq i32 %4, 1
%6 = select i1 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @str.3, i64 0, i64 0)
br label %7
7: ; preds = %3, %0
%8 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0), %0 ], [ %6, %3 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret i32 0
}