#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*/ hex_dec();
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char type;
  int r, g, b;
  scanf("%s", &type);
  if (type == 'd') {
    scanf("%d,%d,%d", &r, &g, &b);
    printf("#%x%x%x", r, g, b);
    return 0;
  }
  if (type == 'h') {
    hex_dec();
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    1199 <main+0x69>
lea    0xe9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <main+0x90>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11b9 <main+0x89>
mov    $0x0,%al
call   1030 <hex_dec@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <main+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xb(%rsp),%al
cmp    $0x68,%al
je     118a <main+0x5a>
cmp    $0x64,%al
jne    1191 <main+0x61>
lea    0xea9(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
jmp    1191 <main+0x61>
xor    %eax,%eax
call   1030 <hex_dec@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@.str.2 = [8 x i8] c"#%x%x%x\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 i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 100
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
store i32 0, i32* %1
br label %23
16: ; preds = %0
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 104
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @hex_dec()
store i32 0, i32* %1
br label %23
22: ; preds = %16
store i32 0, i32* %1
br label %23
23: ; preds = %22, %20, %10
%24 = load i32, i32* %1
ret i32 %24
}

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