#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*/ hex_to_dec(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char var;
  int dec[3] = {0};
  char hex[6];
  scanf("%c", &var);
  if (var == 'h') {
    hex_to_dec(dec);
    printf("rgb(%d, %d, %d)", dec[0], dec[1], dec[2]);
  }
  if (var == 'd') {
    dec_to_hex(hex);
    printf("#%s", hex);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
lea    0xe8a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11ac <main+0x5c>
lea    -0x14(%rbp),%rdi
call   1060 <hex_to_dec@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11d4 <main+0x84>
lea    -0x1a(%rbp),%rdi
call   1050 <dec_to_hex@plt>
lea    -0x1a(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xea3(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x7(%rsp),%al
cmp    $0x68,%al
jne    1197 <main+0x57>
lea    0x8(%rsp),%rdi
call   1050 <hex_to_dec@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x7(%rsp),%al
cmp    $0x64,%al
jne    11b9 <main+0x79>
lea    0x1a(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <dec_to_hex@plt>
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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