#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pe_active(int);
int /*<<< orphan*/ pe_exit(int);
int /*<<< orphan*/ pe_idle(int);
int pe_init();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int talpa;
  if ((talpa = pe_init()) < 0) {
    fprintf(stderr, "Failed to initialize!\n");
    return -1;
  }
  pe_active(talpa);
  printf("Now we can read without being vetted!\n");
  pe_idle(talpa);
  pe_exit(talpa);
  return 0;
}


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)
mov    $0x0,%al
call   1060 <pe_init@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11aa <main+0x4a>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <main+0x75>
mov    -0x14(%rbp),%edi
call   1070 <pe_active@plt>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <pe_idle@plt>
mov    -0x14(%rbp),%edi
call   1080 <pe_exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <pe_init@plt>
test   %eax,%eax
js     1195 <main+0x35>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <pe_active@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1040 <pe_idle@plt>
mov    %ebp,%edi
call   1080 <pe_exit@plt>
jmp    11af <main+0x4f>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Failed to initialize!\0A\00"
@.str.1 = [39 x i8] c"Now we can read without being vetted!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @pe_init()
store i32 %7, i32* %6
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %20
12: ; preds = %2
%13 = load i32, i32* %6
%14 = call i32 @pe_active(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = call i32 @pe_idle(i32 %16)
%18 = load i32, i32* %6
%19 = call i32 @pe_exit(i32 %18)
store i32 0, i32* %3
br label %20
20: ; preds = %12, %9
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Failed to initialize!\0A\00"
@str = [38 x i8] c"Now we can read without being vetted!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @pe_init()
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %13
8: ; preds = %2
%9 = tail call i32 @pe_active(i32 %3)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @pe_idle(i32 %3)
%12 = tail call i32 @pe_exit(i32 %3)
br label %13
13: ; preds = %8, %5
%14 = phi i32 [ -1, %5 ], [ 0, %8 ]
ret i32 %14
}