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

/* Variables and functions */
scalar_t__ get_value(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int wait_key_and_grab(int, struct eeprom_table *, char *);
int magic_pc_transition_key(int device_fd,
                            struct eeprom_table *new_e2prom_tab_p) {
  printf("Direct PC transition => Which key? TV_PC[0] / PC[1] -> Use your "
         "keyboard.\n");
  if (get_value("%u", 0, 2))
    return wait_key_and_grab(device_fd, new_e2prom_tab_p, "PC");
  else
    return wait_key_and_grab(device_fd, new_e2prom_tab_p, "TV_PC");
}


x86 assembly (clang, -O0):
<magic_pc_transition_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <get_value@plt>
cmp    $0x0,%rax
je     1183 <magic_pc_transition_key+0x53>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xedb(%rip),%rdx
call   1040 <wait_key_and_grab@plt>
mov    %eax,-0x4(%rbp)
jmp    1199 <magic_pc_transition_key+0x69>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebd(%rip),%rdx
call   1040 <wait_key_and_grab@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<magic_pc_transition_key>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <get_value@plt>
test   %rax,%rax
lea    0xea2(%rip),%rax
lea    0xe9e(%rip),%rdx
cmove  %rax,%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <wait_key_and_grab@plt>

LLVM IR (-O0):
%struct.eeprom_table = type { i32 }
@.str = [75 x i8] c"Direct PC transition => Which key? TV_PC[0] / PC[1] -> Use your keyboard.\0A\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [3 x i8] c"PC\00"
@.str.3 = [6 x i8] c"TV_PC\00"
define i32 @magic_pc_transition_key(i32 %0, %struct.eeprom_table* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.eeprom_table*
store i32 %0, i32* %4
store %struct.eeprom_table* %1, %struct.eeprom_table** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @get_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load %struct.eeprom_table*, %struct.eeprom_table** %5
%12 = call i32 @wait_key_and_grab(i32 %10, %struct.eeprom_table* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %12, i32* %3
br label %17
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load %struct.eeprom_table*, %struct.eeprom_table** %5
%16 = call i32 @wait_key_and_grab(i32 %14, %struct.eeprom_table* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 %16, i32* %3
br label %17
17: ; preds = %13, %9
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
%struct.eeprom_table = type { i32 }
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [3 x i8] c"PC\00"
@.str.3 = [6 x i8] c"TV_PC\00"
@str = [74 x i8] c"Direct PC transition => Which key? TV_PC[0] / PC[1] -> Use your keyboard.\00"
define i32 @magic_pc_transition_key(i32 %0, %struct.eeprom_table* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 @get_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%7 = tail call i32 @wait_key_and_grab(i32 %0, %struct.eeprom_table* %1, i8* %6)
ret i32 %7
}