#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 */
struct kb {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ DPRINTF(char *, char *);
int /*<<< orphan*/ fatal(char *, char *);
int /*<<< orphan*/ kb_loadKernelKeyMap(struct kb *);
scalar_t__ kb_loadKeys(struct kb *, char *);
void kb_initKeyMap(struct kb *self, char *mapfile) {
  if (!mapfile)
    kb_loadKernelKeyMap(self);
  else if ((kb_loadKeys(self, mapfile)))
    DPRINTF("using keymap '%s'\n", mapfile);
  else
    fatal("could not load keymap '%s'\n", mapfile);
}


x86 assembly (clang, -O0):
<kb_initKeyMap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1169 <kb_initKeyMap+0x29>
mov    -0x8(%rbp),%rdi
call   1040 <kb_loadKernelKeyMap@plt>
jmp    11aa <kb_initKeyMap+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <kb_loadKeys@plt>
cmp    $0x0,%rax
je     1195 <kb_initKeyMap+0x55>
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1060 <DPRINTF@plt>
jmp    11a5 <kb_initKeyMap+0x65>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <fatal@plt>
jmp    11aa <kb_initKeyMap+0x6a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kb_initKeyMap>:
push   %rbx
test   %rsi,%rsi
je     1163 <kb_initKeyMap+0x23>
mov    %rsi,%rbx
call   1030 <kb_loadKeys@plt>
test   %rax,%rax
je     1169 <kb_initKeyMap+0x29>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1060 <DPRINTF@plt>
pop    %rbx
jmp    1040 <kb_loadKernelKeyMap@plt>
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1050 <fatal@plt>

LLVM IR (-O0):
%struct.kb = type { i32 }
@.str = [19 x i8] c"using keymap '%s'\0A\00"
@.str.1 = [28 x i8] c"could not load keymap '%s'\0A\00"
define void @kb_initKeyMap(%struct.kb* %0, i8* %1) {
%3 = alloca %struct.kb*
%4 = alloca i8*
store %struct.kb* %0, %struct.kb** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load %struct.kb*, %struct.kb** %3
%9 = call i32 @kb_loadKernelKeyMap(%struct.kb* %8)
br label %22
10: ; preds = %2
%11 = load %struct.kb*, %struct.kb** %3
%12 = load i8*, i8** %4
%13 = call i64 @kb_loadKeys(%struct.kb* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i32 @DPRINTF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %21
18: ; preds = %10
%19 = load i8*, i8** %4
%20 = call i32 @fatal(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %15
br label %22
22: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
%struct.kb = type { i32 }
@.str = [19 x i8] c"using keymap '%s'\0A\00"
@.str.1 = [28 x i8] c"could not load keymap '%s'\0A\00"
define void @kb_initKeyMap(%struct.kb* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @kb_loadKernelKeyMap(%struct.kb* %0)
br label %13
6: ; preds = %2
%7 = tail call i64 @kb_loadKeys(%struct.kb* %0, i8* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @DPRINTF(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %13
11: ; preds = %6
%12 = tail call i32 @fatal(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %13
13: ; preds = %9, %11, %4
ret void
}