#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 *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ hex_to_dec(char *);
int /*<<< orphan*/ stdin;
int main() {
  char choise;
  char colour[15];
  choise = getchar();
  getchar();
  fgets(colour, 15, stdin);
  if (choise == 'h')
    hex_to_dec(colour);
  else if (choise == 'd')
    dec_to_hex(colour);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
lea    -0x14(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
mov    $0xf,%esi
call   1030 <fgets@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    1192 <main+0x52>
lea    -0x14(%rbp),%rdi
call   1060 <hex_to_dec@plt>
jmp    11ad <main+0x6d>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11a8 <main+0x68>
lea    -0x14(%rbp),%rdi
call   1040 <dec_to_hex@plt>
jmp    11ad <main+0x6d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
lea    0x1(%rsp),%rdi
mov    $0xf,%esi
call   1030 <fgets@plt>
cmp    $0x64,%bl
je     1183 <main+0x43>
cmp    $0x68,%bl
jne    118d <main+0x4d>
lea    0x1(%rsp),%rdi
call   1060 <hex_to_dec@plt>
jmp    118d <main+0x4d>
lea    0x1(%rsp),%rdi
call   1040 <dec_to_hex@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [15 x i8]
store i32 0, i32* %1
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = call signext i8 (...) @getchar()
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 15, i32 %7)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 104
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%14 = call i32 @hex_to_dec(i8* %13)
br label %23
15: ; preds = %0
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 100
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%21 = call i32 @dec_to_hex(i8* %20)
br label %22
22: ; preds = %19, %15
br label %23
23: ; preds = %22, %12
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call signext i8 (...) @getchar()
%4 = tail call signext i8 (...) @getchar()
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 15, i32 %5)
switch i8 %3, label %11 [
i8 104, label %7
i8 100, label %9
]
7: ; preds = %0
%8 = call i32 @hex_to_dec(i8* %2)
br label %11
9: ; preds = %0
%10 = call i32 @dec_to_hex(i8* %2)
br label %11
11: ; preds = %0, %9, %7
ret i32 0
}