#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 foo1();
int foo2();
int foo3();
int foo4();
int /*<<< orphan*/ printf(char *);
int main() {
  printf("[BEGIN] interpose-weak-"
         "present"
         "\n");
  if (foo1() != 1) {
    printf("[FAIL] interpose-weak-"
           "present"
           ", foo1() != 1\n");
    return 0;
  }
  if (foo2() != 12) {
    printf("[FAIL] interpose-weak-"
           "present"
           ", foo2() != 12\n");
    return 0;
  }
  if (foo3() != 3) {
    printf("[FAIL] interpose-weak-"
           "present"
           ", foo3() != 3\n");
    return 0;
  }
  if (foo4() != 14) {
    printf("[FAIL] interpose-weak-"
           "present"
           ", foo4() != 14\n");
    return 0;
  }
  printf("[PASS] interpose-weak-"
         "present"
         "\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <foo1@plt>
cmp    $0x1,%eax
je     1193 <main+0x43>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xce>
mov    $0x0,%al
call   1050 <foo2@plt>
cmp    $0xc,%eax
je     11bb <main+0x6b>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xce>
mov    $0x0,%al
call   1060 <foo3@plt>
cmp    $0x3,%eax
je     11e3 <main+0x93>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xce>
mov    $0x0,%al
call   1040 <foo4@plt>
cmp    $0xe,%eax
je     120b <main+0xbb>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xce>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <foo1@plt>
cmp    $0x1,%eax
jne    119f <main+0x4f>
xor    %eax,%eax
call   1050 <foo2@plt>
cmp    $0xc,%eax
jne    11a8 <main+0x58>
xor    %eax,%eax
call   1060 <foo3@plt>
cmp    $0x3,%eax
jne    11b1 <main+0x61>
xor    %eax,%eax
call   1040 <foo4@plt>
cmp    $0xe,%eax
lea    0xe8d(%rip),%rax
lea    0xea4(%rip),%rdi
cmove  %rax,%rdi
jmp    11b8 <main+0x68>
lea    0xf1a(%rip),%rdi
jmp    11b8 <main+0x68>
lea    0xee5(%rip),%rdi
jmp    11b8 <main+0x68>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"[BEGIN] interpose-weak-present\0A\00"
@.str.1 = [44 x i8] c"[FAIL] interpose-weak-present, foo1() != 1\0A\00"
@.str.2 = [45 x i8] c"[FAIL] interpose-weak-present, foo2() != 12\0A\00"
@.str.3 = [44 x i8] c"[FAIL] interpose-weak-present, foo3() != 3\0A\00"
@.str.4 = [45 x i8] c"[FAIL] interpose-weak-present, foo4() != 14\0A\00"
@.str.5 = [31 x i8] c"[PASS] interpose-weak-present\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @foo1()
%4 = icmp ne i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %24
7: ; preds = %0
%8 = call i32 (...) @foo2()
%9 = icmp ne i32 %8, 12
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %24
12: ; preds = %7
%13 = call i32 (...) @foo3()
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %24
17: ; preds = %12
%18 = call i32 (...) @foo4()
%19 = icmp ne i32 %18, 14
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %24
24: ; preds = %22, %20, %15, %10, %5
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@str = [31 x i8] c"[BEGIN] interpose-weak-present\00"
@str.6 = [30 x i8] c"[PASS] interpose-weak-present\00"
@str.7 = [44 x i8] c"[FAIL] interpose-weak-present, foo4() != 14\00"
@str.8 = [43 x i8] c"[FAIL] interpose-weak-present, foo3() != 3\00"
@str.9 = [44 x i8] c"[FAIL] interpose-weak-present, foo2() != 12\00"
@str.10 = [43 x i8] c"[FAIL] interpose-weak-present, foo1() != 1\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @foo1()
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %14
4: ; preds = %0
%5 = tail call i32 (...) @foo2()
%6 = icmp eq i32 %5, 12
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = tail call i32 (...) @foo3()
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 (...) @foo4()
%12 = icmp eq i32 %11, 14
%13 = select i1 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @str.7, i64 0, i64 0)
br label %14
14: ; preds = %10, %7, %4, %0
%15 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.10, i64 0, i64 0), %0 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @str.9, i64 0, i64 0), %4 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.8, i64 0, i64 0), %7 ], [ %13, %10 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret i32 0
}