#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 /*<<< orphan*/ testElfCreationError();
int /*<<< orphan*/ testSharedLibraryCloseError();
int /*<<< orphan*/ testSharedLibraryOpenError();
int /*<<< orphan*/ testSymbolLoadingError();
int /*<<< orphan*/ testTmpCreationError();
int main() {
  if (!testElfCreationError()) {
    printf("Test case failed: testElfCreationError\n");
    return -1;
  }
  if (!testTmpCreationError()) {
    printf("Test case failed: testTmpCreationError\n");
    return -2;
  }
  if (!testSharedLibraryOpenError()) {
    printf("Test case failed: testSharedLibraryOpenError\n");
    return -3;
  }
  if (!testSymbolLoadingError()) {
    printf("Test case failed: testSymbolLoadingError\n");
    return -4;
  }
  if (!testSharedLibraryCloseError()) {
    printf("Test case failed: testSharedLibraryCloseError\n");
    return -5;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <testElfCreationError@plt>
cmp    $0x0,%eax
jne    1197 <main+0x37>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123e <main+0xde>
mov    $0x0,%al
call   1080 <testTmpCreationError@plt>
cmp    $0x0,%eax
jne    11bf <main+0x5f>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    123e <main+0xde>
mov    $0x0,%al
call   1070 <testSharedLibraryOpenError@plt>
cmp    $0x0,%eax
jne    11e7 <main+0x87>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    123e <main+0xde>
mov    $0x0,%al
call   1050 <testSymbolLoadingError@plt>
cmp    $0x0,%eax
jne    120f <main+0xaf>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    123e <main+0xde>
mov    $0x0,%al
call   1040 <testSharedLibraryCloseError@plt>
cmp    $0x0,%eax
jne    1237 <main+0xd7>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    123e <main+0xde>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <testElfCreationError@plt>
test   %eax,%eax
je     11a8 <main+0x48>
xor    %eax,%eax
call   1080 <testTmpCreationError@plt>
test   %eax,%eax
je     11b6 <main+0x56>
xor    %eax,%eax
call   1070 <testSharedLibraryOpenError@plt>
test   %eax,%eax
je     11c4 <main+0x64>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <testSymbolLoadingError@plt>
test   %eax,%eax
je     11d2 <main+0x72>
xor    %eax,%eax
call   1040 <testSharedLibraryCloseError@plt>
test   %eax,%eax
jne    11e3 <main+0x83>
mov    $0xfffffffb,%ebx
lea    0xefe(%rip),%rdi
jmp    11de <main+0x7e>
mov    $0xffffffff,%ebx
lea    0xe4c(%rip),%rdi
jmp    11de <main+0x7e>
mov    $0xfffffffe,%ebx
lea    0xe65(%rip),%rdi
jmp    11de <main+0x7e>
mov    $0xfffffffd,%ebx
lea    0xe7e(%rip),%rdi
jmp    11de <main+0x7e>
mov    $0xfffffffc,%ebx
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Test case failed: testElfCreationError\0A\00"
@.str.1 = [40 x i8] c"Test case failed: testTmpCreationError\0A\00"
@.str.2 = [46 x i8] c"Test case failed: testSharedLibraryOpenError\0A\00"
@.str.3 = [42 x i8] c"Test case failed: testSymbolLoadingError\0A\00"
@.str.4 = [47 x i8] c"Test case failed: testSharedLibraryCloseError\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @testElfCreationError()
%3 = icmp ne i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
6: ; preds = %0
%7 = call i32 (...) @testTmpCreationError()
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %1
br label %27
11: ; preds = %6
%12 = call i32 (...) @testSharedLibraryOpenError()
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
store i32 -3, i32* %1
br label %27
16: ; preds = %11
%17 = call i32 (...) @testSymbolLoadingError()
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 -4, i32* %1
br label %27
21: ; preds = %16
%22 = call i32 (...) @testSharedLibraryCloseError()
%23 = icmp ne i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
store i32 -5, i32* %1
br label %27
26: ; preds = %21
store i32 0, i32* %1
br label %27
27: ; preds = %26, %24, %19, %14, %9, %4
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@str = [39 x i8] c"Test case failed: testElfCreationError\00"
@str.5 = [39 x i8] c"Test case failed: testTmpCreationError\00"
@str.6 = [45 x i8] c"Test case failed: testSharedLibraryOpenError\00"
@str.7 = [41 x i8] c"Test case failed: testSymbolLoadingError\00"
@str.8 = [46 x i8] c"Test case failed: testSharedLibraryCloseError\00"
define i32 @main() {
%1 = tail call i32 (...) @testElfCreationError()
%2 = icmp eq i32 %1, 0
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call i32 (...) @testTmpCreationError()
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = tail call i32 (...) @testSharedLibraryOpenError()
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 (...) @testSymbolLoadingError()
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 (...) @testSharedLibraryCloseError()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12, %9, %6, %3, %0
%16 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0), %3 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @str.6, i64 0, i64 0), %6 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([46 x i8], [46 x i8]* @str.8, i64 0, i64 0), %12 ]
%17 = phi i32 [ -1, %0 ], [ -2, %3 ], [ -3, %6 ], [ -4, %9 ], [ -5, %12 ]
%18 = tail call i32 @puts(i8* dereferenceable(1) %16)
br label %19
19: ; preds = %15, %12
%20 = phi i32 [ 0, %12 ], [ %17, %15 ]
ret i32 %20
}