#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*/ dec_to_hex();
char getchar();
int /*<<< orphan*/ hex_to_dec();
int main() {
  char a;
  do {
    a = getchar();
  } while (a != 'd' && a != 'h');
  if (a == 'd') {
    dec_to_hex();
    return 0;
  }
  if (a == 'h') {
    hex_to_dec();
    return 0;
  }
  return -666;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x64,%ecx
mov    %al,-0x6(%rbp)
je     1168 <main+0x38>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    113f <main+0xf>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    1193 <main+0x63>
mov    $0x0,%al
call   1030 <dec_to_hex@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ba <main+0x8a>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11b3 <main+0x83>
mov    $0x0,%al
call   1050 <hex_to_dec@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ba <main+0x8a>
movl   $0xfffffd66,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x68,%al
je     1158 <main+0x28>
cmp    $0x64,%al
jne    1140 <main+0x10>
xor    %eax,%eax
call   1030 <dec_to_hex@plt>
jmp    115f <main+0x2f>
xor    %eax,%eax
call   1050 <hex_to_dec@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %13, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
br label %5
5: ; preds = %3
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 100
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 104
br label %13
13: ; preds = %9, %5
%14 = phi i1 [ false, %5 ], [ %12, %9 ]
br i1 %14, label %3, label %15
15: ; preds = %13
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 100
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @dec_to_hex()
store i32 0, i32* %1
br label %28
21: ; preds = %15
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 104
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @hex_to_dec()
store i32 0, i32* %1
br label %28
27: ; preds = %21
store i32 -666, i32* %1
br label %28
28: ; preds = %27, %25, %19
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = tail call signext i8 (...) @getchar()
switch i8 %2, label %1 [
i8 100, label %3
i8 104, label %5
]
3: ; preds = %1
%4 = tail call i32 (...) @dec_to_hex()
br label %7
5: ; preds = %1
%6 = tail call i32 (...) @hex_to_dec()
br label %7
7: ; preds = %5, %3
ret i32 0
}