#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(int);
char getchar();
int /*<<< orphan*/ hex_to_dec();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  char choice;
  int r, g, b;
  choice = getchar();
  if (choice == 'h') {
    hex_to_dec();
  } else {
    if (choice == 'd') {
      scanf("%d, %d, %d", &r, &g, &b);
      printf("#");
      dec_to_hex(r);
      dec_to_hex(g);
      dec_to_hex(b);
      printf("\n");
    } else {
      return 0;
    }
  }
  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)
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    1182 <main+0x32>
mov    $0x0,%al
call   1060 <hex_to_dec@plt>
jmp    11ed <main+0x9d>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11dc <main+0x8c>
lea    0xe6a(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1070 <scanf@plt>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1040 <dec_to_hex@plt>
mov    -0x10(%rbp),%edi
call   1040 <dec_to_hex@plt>
mov    -0x14(%rbp),%edi
call   1040 <dec_to_hex@plt>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
jmp    11e8 <main+0x98>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <main+0xa4>
jmp    11ed <main+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x64,%al
je     116c <main+0x1c>
cmp    $0x68,%al
jne    11b6 <main+0x66>
xor    %eax,%eax
call   1060 <hex_to_dec@plt>
jmp    11b6 <main+0x66>
lea    0xe8d(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1070 <scanf@plt>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%edi
call   1040 <dec_to_hex@plt>
mov    0x10(%rsp),%edi
call   1040 <dec_to_hex@plt>
mov    0xc(%rsp),%edi
call   1040 <dec_to_hex@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"%d, %d, %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call signext i8 (...) @getchar()
switch i8 %7, label %20 [
i8 104, label %8
i8 100, label %10
]
8: ; preds = %0
%9 = tail call i32 (...) @hex_to_dec()
br label %20
10: ; preds = %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%12 = call i32 @putchar(i32 35)
%13 = load i32, i32* %1
%14 = call i32 @dec_to_hex(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @dec_to_hex(i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @dec_to_hex(i32 %17)
%19 = call i32 @putchar(i32 10)
br label %20
20: ; preds = %8, %10, %0
ret i32 0
}