#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 lib_efi_runtime_open();
scalar_t__ lib_load_module();
int /*<<< orphan*/ printf(char *);
int init_driver(void) {
  int fd;
  if (lib_load_module() != 0) {
    printf("Cannot load efi runtime module. Aborted.\n");
    return -1;
  }
  fd = lib_efi_runtime_open();
  if (fd == -1) {
    printf("Cannot open efi runtime driver. Aborted.\n");
    return -1;
  }
  return fd;
}


x86 assembly (clang, -O0):
<init_driver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <lib_load_module@plt>
cmp    $0x0,%rax
je     1161 <init_driver+0x31>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <init_driver+0x63>
mov    $0x0,%al
call   1050 <lib_efi_runtime_open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    118d <init_driver+0x5d>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <init_driver+0x63>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_driver>:
push   %rax
xor    %eax,%eax
call   1040 <lib_load_module@plt>
test   %rax,%rax
je     1150 <init_driver+0x20>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    115c <init_driver+0x2c>
xor    %eax,%eax
call   1050 <lib_efi_runtime_open@plt>
cmp    $0xffffffff,%eax
je     115e <init_driver+0x2e>
pop    %rcx
ret
lea    0xe9b(%rip),%rdi
jmp    1144 <init_driver+0x14>

LLVM IR (-O0):
@.str = [42 x i8] c"Cannot load efi runtime module. Aborted.\0A\00"
@.str.1 = [42 x i8] c"Cannot open efi runtime driver. Aborted.\0A\00"
define i32 @init_driver() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 (...) @lib_load_module()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %15
7: ; preds = %0
%8 = call i32 (...) @lib_efi_runtime_open()
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %15
13: ; preds = %7
%14 = load i32, i32* %2
store i32 %14, i32* %1
br label %15
15: ; preds = %13, %11, %5
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@str = [41 x i8] c"Cannot open efi runtime driver. Aborted.\00"
@str.2 = [41 x i8] c"Cannot load efi runtime module. Aborted.\00"
define i32 @init_driver() {
%1 = tail call i64 (...) @lib_load_module()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 (...) @lib_efi_runtime_open()
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %3, %0
%7 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0), %3 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ %4, %3 ], [ -1, %6 ]
ret i32 %10
}