#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_input(int *, int *, int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ hex_input(char *, char *, char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int main() {
  char n;
  scanf("%c", &n);
  getchar();
  char num_hex_1[2], num_hex_2[2], num_hex_3[2];
  int num_dec_1 = 0, num_dec_2 = 0, num_dec_3 = 0;
  switch (n) {
  case 'h':
    hex_input(num_hex_1, num_hex_2, num_hex_3);
    num_dec_1 = strtol(num_hex_1, NULL, 16);
    num_dec_2 = strtol(num_hex_2, NULL, 16);
    num_dec_3 = strtol(num_hex_3, NULL, 16);
    printf("rgb(%d, %d, %d)", num_dec_1, num_dec_2, num_dec_3);
    break;
  case 'd':
    dec_input(&num_dec_1, &num_dec_2, &num_dec_3);
    printf("#%x%x%x", num_dec_1, num_dec_2, num_dec_3);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x64,%eax
je     122b <main+0xcb>
jmp    11b0 <main+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x68,%eax
jne    1251 <main+0xf1>
jmp    11c1 <main+0x61>
lea    -0x7(%rbp),%rdi
lea    -0x9(%rbp),%rsi
lea    -0xb(%rbp),%rdx
call   1030 <hex_input@plt>
lea    -0x7(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,-0x10(%rbp)
lea    -0x9(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
lea    -0xb(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
jmp    1251 <main+0xf1>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <dec_input@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xdc7(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe8f(%rip),%rdi
lea    0x3(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movsbl 0x3(%rsp),%eax
cmp    $0x64,%eax
je     120a <main+0xaa>
cmp    $0x68,%eax
jne    1236 <main+0xd6>
lea    0x16(%rsp),%rbx
lea    0x14(%rsp),%r14
lea    0x12(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <hex_input@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
lea    0xe01(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
jmp    1231 <main+0xd1>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1080 <dec_input@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [16 x i8] c"rgb(%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 [2 x i8]
%4 = alloca [2 x i8]
%5 = alloca [2 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = call i32 (...) @getchar()
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %34 [
i32 104, label %13
i32 100, label %28
]
13: ; preds = %0
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%17 = call i32 @hex_input(i8* %14, i8* %15, i8* %16)
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%19 = call i32 @strtol(i8* %18, i32* null, i32 16)
store i32 %19, i32* %6
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%21 = call i32 @strtol(i8* %20, i32* null, i32 16)
store i32 %21, i32* %7
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%23 = call i32 @strtol(i8* %22, i32* null, i32 16)
store i32 %23, i32* %8
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
br label %34
28: ; preds = %0
%29 = call i32 @dec_input(i32* %6, i32* %7, i32* %8)
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %0, %28, %13
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 = [8 x i8] c"#%x%x%x\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [2 x i8]
%3 = alloca [2 x i8]
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = call i32 (...) @getchar()
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%13 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%14 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%15 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
switch i32 %17, label %30 [
i32 104, label %18
i32 100, label %24
]
18: ; preds = %0
%19 = call i32 @hex_input(i8* %10, i8* %11, i8* %12)
%20 = call i32 @strtol(i8* nocapture %10, i32* null, i32 16)
%21 = call i32 @strtol(i8* nocapture %11, i32* null, i32 16)
%22 = call i32 @strtol(i8* nocapture %12, i32* null, i32 16)
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
br label %30
24: ; preds = %0
%25 = call i32 @dec_input(i32* %5, i32* %6, i32* %7)
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %0, %24, %18
ret i32 0
}