#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ hex_to_rgb(char *);
int /*<<< orphan*/ rgb_to_hex(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char horb, hex[30], rgb[30];
  scanf("%c", &horb);
  getchar();
  if (horb == 'h') {
    fgets(hex, 30, stdin);
    hex_to_rgb(hex);
  }
  if (horb == 'd') {
    fgets(rgb, 30, stdin);
    rgb_to_hex(rgb);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11a3 <main+0x53>
lea    -0x30(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    $0x1e,%esi
call   1040 <fgets@plt>
lea    -0x30(%rbp),%rdi
call   1030 <hex_to_rgb@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11d0 <main+0x80>
lea    -0x50(%rbp),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    $0x1e,%esi
call   1040 <fgets@plt>
lea    -0x50(%rbp),%rdi
call   1060 <rgb_to_hex@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xea4(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xf(%rsp),%al
cmp    $0x68,%al
jne    119c <main+0x4c>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <hex_to_rgb@plt>
mov    0xf(%rsp),%al
cmp    $0x64,%al
jne    11c3 <main+0x73>
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1060 <rgb_to_hex@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i8
%2 = alloca [30 x i8]
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = call i32 (...) @getchar()
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 104
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %4, i32 30, i32 %11)
%13 = call i32 @hex_to_rgb(i8* %4)
%14 = load i8, i8* %1
br label %15
15: ; preds = %10, %0
%16 = phi i8 [ %14, %10 ], [ %8, %0 ]
%17 = icmp eq i8 %16, 100
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %5, i32 30, i32 %19)
%21 = call i32 @rgb_to_hex(i8* %5)
br label %22
22: ; preds = %18, %15
ret i32 0
}