#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 kbd_map {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ device_info(int);
int /*<<< orphan*/ kbd_map_print(int /*<<< orphan*/, struct kbd_map *,
                                 int /*<<< orphan*/);
struct kbd_map *kbd_map_read(int, unsigned int);
int /*<<< orphan*/ kbd_print_bits(int);
int /*<<< orphan*/ stdout;
void show_kbd(int fd, unsigned int protocol_version) {
  struct kbd_map *map;
  device_info(fd);
  map = kbd_map_read(fd, protocol_version);
  if (map)
    kbd_map_print(stdout, map, 0);
  else
    kbd_print_bits(fd);
}


x86 assembly (clang, -O0):
<show_kbd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <device_info@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <kbd_map_read@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1189 <show_kbd+0x49>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <kbd_map_print@plt>
jmp    1191 <show_kbd+0x51>
mov    -0x4(%rbp),%edi
call   1060 <kbd_print_bits@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_kbd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <device_info@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <kbd_map_read@plt>
test   %rax,%rax
je     1173 <show_kbd+0x33>
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%edi
mov    %rax,%rsi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <kbd_map_print@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <kbd_print_bits@plt>

LLVM IR (-O0):
%struct.kbd_map = type { i32 }
@stdout = global i32 0
define void @show_kbd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.kbd_map*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = call i32 @device_info(i32 %6)
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call %struct.kbd_map* @kbd_map_read(i32 %8, i32 %9)
store %struct.kbd_map* %10, %struct.kbd_map** %5
%11 = load %struct.kbd_map*, %struct.kbd_map** %5
%12 = icmp ne %struct.kbd_map* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stdout
%15 = load %struct.kbd_map*, %struct.kbd_map** %5
%16 = call i32 @kbd_map_print(i32 %14, %struct.kbd_map* %15, i32 0)
br label %20
17: ; preds = %2
%18 = load i32, i32* %3
%19 = call i32 @kbd_print_bits(i32 %18)
br label %20
20: ; preds = %17, %13
ret void
}

LLVM IR (-O2):
%struct.kbd_map = type { i32 }
@stdout = global i32 0
define void @show_kbd(i32 %0, i32 %1) {
%3 = tail call i32 @device_info(i32 %0)
%4 = tail call %struct.kbd_map* @kbd_map_read(i32 %0, i32 %1)
%5 = icmp eq %struct.kbd_map* %4, null
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stdout
%8 = tail call i32 @kbd_map_print(i32 %7, %struct.kbd_map* %4, i32 0)
br label %11
9: ; preds = %2
%10 = tail call i32 @kbd_print_bits(i32 %0)
br label %11
11: ; preds = %9, %6
ret void
}