#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*/ LoadMcds();
int LoadPlugins();
int OpenPlugins();
int /*<<< orphan*/ printf(char *);
scalar_t__ psxInit();
int EmuInit() {
  if (psxInit() != 0) {
    printf("Failed to init plugins\n");
    return -1;
  }
  if (LoadPlugins() == -1) {
    printf("Failed to init plugins\n");
    return -1;
  }
  LoadMcds();
  if (OpenPlugins() == -1) {
    printf("Failed to open plugins\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<EmuInit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <psxInit@plt>
cmp    $0x0,%rax
je     1181 <EmuInit+0x31>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <EmuInit+0x8f>
mov    $0x0,%al
call   1050 <LoadPlugins@plt>
cmp    $0xffffffff,%eax
jne    11a9 <EmuInit+0x59>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <EmuInit+0x8f>
mov    $0x0,%al
call   1070 <LoadMcds@plt>
mov    $0x0,%al
call   1030 <OpenPlugins@plt>
cmp    $0xffffffff,%eax
jne    11d8 <EmuInit+0x88>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <EmuInit+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EmuInit>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <psxInit@plt>
lea    0xeb5(%rip),%r14
test   %rax,%rax
je     117e <EmuInit+0x2e>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <LoadPlugins@plt>
cmp    $0xffffffff,%eax
je     1167 <EmuInit+0x17>
xor    %eax,%eax
call   1070 <LoadMcds@plt>
xor    %eax,%eax
call   1040 <OpenPlugins@plt>
cmp    $0xffffffff,%eax
jne    1174 <EmuInit+0x24>
lea    0xe5a(%rip),%r14
jmp    1167 <EmuInit+0x17>

LLVM IR (-O0):
@.str = [24 x i8] c"Failed to init plugins\0A\00"
@.str.1 = [24 x i8] c"Failed to open plugins\0A\00"
define i32 @EmuInit() {
%1 = alloca i32
%2 = call i64 (...) @psxInit()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %18
6: ; preds = %0
%7 = call i32 (...) @LoadPlugins()
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %18
11: ; preds = %6
%12 = call i32 (...) @LoadMcds()
%13 = call i32 (...) @OpenPlugins()
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %18
17: ; preds = %11
store i32 0, i32* %1
br label %18
18: ; preds = %17, %15, %9, %4
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@str = [23 x i8] c"Failed to open plugins\00"
@str.3 = [23 x i8] c"Failed to init plugins\00"
define i32 @EmuInit() {
%1 = tail call i64 (...) @psxInit()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i32 (...) @LoadPlugins()
%5 = icmp eq i32 %4, -1
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 (...) @LoadMcds()
%8 = tail call i32 (...) @OpenPlugins()
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %6, %3, %0
%11 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %3 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %6 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ 0, %6 ], [ -1, %10 ]
ret i32 %14
}