#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 function(char);
int /*<<< orphan*/ function_2(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int i = 0, R = 0, G = 0, B = 0;
  char type[1];
  char code[7];
  scanf("%c", type);
  if (type[0] == 'h') {
    scanf("%s", code);
    if (code[i == '#'])
      i++;
    R = (R * 16) + function(code[i]);
    i++;
    R = (R * 16) + function(code[i]);
    i++;
    G = (G * 16) + function(code[i]);
    i++;
    G = (G * 16) + function(code[i]);
    i++;
    B = (B * 16) + function(code[i]);
    i++;
    B = (B * 16) + function(code[i]);
    i++;
    printf("rgb(%d, %d, %d)", R, G, B);
  } else if (type[0] == 'd') {
    scanf("%d,%d,%d", &R, &G, &B);
    printf("#");
    function_2(R);
    function_2(G);
    function_2(B);
  } else {
    printf("Wrong Input");
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x15(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x68,%eax
jne    12d6 <main+0x196>
lea    -0x1c(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x23,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
cmpb   $0x0,-0x1c(%rbp,%rax,1)
je     11be <main+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x34(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x30(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x2c(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x28(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x24(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x20(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edi
call   1050 <function@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1347 <main+0x207>
movsbl -0x15(%rbp),%eax
cmp    $0x64,%eax
jne    1328 <main+0x1e8>
lea    0xd2c(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <function_2@plt>
mov    -0x10(%rbp),%edi
call   1060 <function_2@plt>
mov    -0x14(%rbp),%edi
call   1060 <function_2@plt>
jmp    1342 <main+0x202>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1347 <main+0x207>
jmp    1347 <main+0x207>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe87(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x3(%rsp),%al
cmp    $0x64,%al
je     1220 <main+0xd0>
cmp    $0x68,%al
jne    1264 <main+0x114>
lea    0xe63(%rip),%rdi
lea    0x11(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x1,0x11(%rsp)
sbb    $0xffffffffffffffff,%rbx
movsbl (%rbx),%edi
call   1060 <function@plt>
mov    %eax,%r14d
shl    $0x4,%r14d
movsbl 0x1(%rbx),%edi
call   1060 <function@plt>
add    %eax,%r14d
movsbl 0x2(%rbx),%edi
call   1060 <function@plt>
mov    %eax,%r15d
shl    $0x4,%r15d
movsbl 0x3(%rbx),%edi
call   1060 <function@plt>
add    %eax,%r15d
movsbl 0x4(%rbx),%edi
call   1060 <function@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x5(%rbx),%edi
call   1060 <function@plt>
add    %eax,%ebp
lea    0xdf7(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1272 <main+0x122>
lea    0xdef(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%edi
call   1070 <function_2@plt>
mov    0x8(%rsp),%edi
call   1070 <function_2@plt>
mov    0x4(%rsp),%edi
call   1070 <function_2@plt>
jmp    1272 <main+0x122>
lea    0xdb4(%rip),%rdi
xor    %eax,%eax
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 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"rgb(%d, %d, %d)\00"
@.str.3 = [9 x i8] c"%d,%d,%d\00"
@.str.4 = [2 x i8] c"#\00"
@.str.5 = [12 x i8] c"Wrong Input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1 x i8]
%7 = alloca [7 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 104
br i1 %13, label %14, label %92
14: ; preds = %0
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 35
%19 = zext i1 %18 to i32
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %27
27: ; preds = %24, %14
%28 = load i32, i32* %3
%29 = mul nsw i32 %28, 16
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @function(i8 signext %33)
%35 = add nsw i32 %29, %34
store i32 %35, i32* %3
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
%38 = load i32, i32* %3
%39 = mul nsw i32 %38, 16
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @function(i8 signext %43)
%45 = add nsw i32 %39, %44
store i32 %45, i32* %3
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
%48 = load i32, i32* %4
%49 = mul nsw i32 %48, 16
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @function(i8 signext %53)
%55 = add nsw i32 %49, %54
store i32 %55, i32* %4
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
%58 = load i32, i32* %4
%59 = mul nsw i32 %58, 16
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @function(i8 signext %63)
%65 = add nsw i32 %59, %64
store i32 %65, i32* %4
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 1
store i32 %67, i32* %2
%68 = load i32, i32* %5
%69 = mul nsw i32 %68, 16
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = call i32 @function(i8 signext %73)
%75 = add nsw i32 %69, %74
store i32 %75, i32* %5
%76 = load i32, i32* %2
%77 = add nsw i32 %76, 1
store i32 %77, i32* %2
%78 = load i32, i32* %5
%79 = mul nsw i32 %78, 16
%80 = load i32, i32* %2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = call i32 @function(i8 signext %83)
%85 = add nsw i32 %79, %84
store i32 %85, i32* %5
%86 = load i32, i32* %2
%87 = add nsw i32 %86, 1
store i32 %87, i32* %2
%88 = load i32, i32* %3
%89 = load i32, i32* %4
%90 = load i32, i32* %5
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %88, i32 %89, i32 %90)
br label %109
92: ; preds = %0
%93 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 100
br i1 %96, label %97, label %106
97: ; preds = %92
%98 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%100 = load i32, i32* %3
%101 = call i32 @function_2(i32 %100)
%102 = load i32, i32* %4
%103 = call i32 @function_2(i32 %102)
%104 = load i32, i32* %5
%105 = call i32 @function_2(i32 %104)
br label %108
106: ; preds = %92
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %109
108: ; preds = %97
br label %109
109: ; preds = %106, %108, %27
%110 = load i32, i32* %1
ret i32 %110
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"rgb(%d, %d, %d)\00"
@.str.3 = [9 x i8] c"%d,%d,%d\00"
@.str.5 = [12 x i8] c"Wrong Input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1 x i8]
%5 = alloca [7 x i8]
%6 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%12 = load i8, i8* %9
switch i8 %12, label %60 [
i8 104, label %13
i8 100, label %51
]
13: ; preds = %0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%15 = load i8, i8* %10
%16 = icmp ne i8 %15, 0
%17 = zext i1 %16 to i32
%18 = zext i1 %16 to i64
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @function(i8 signext %20)
%22 = shl nsw i32 %21, 4
%23 = select i1 %16, i64 2, i64 1
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @function(i8 signext %25)
%27 = add nsw i32 %26, %22
%28 = or i32 %17, 2
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @function(i8 signext %31)
%33 = shl nsw i32 %32, 4
%34 = select i1 %16, i64 4, i64 3
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @function(i8 signext %36)
%38 = add nsw i32 %37, %33
%39 = or i32 %17, 4
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = call i32 @function(i8 signext %42)
%44 = shl nsw i32 %43, 4
%45 = select i1 %16, i64 6, i64 5
%46 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @function(i8 signext %47)
%49 = add nsw i32 %48, %44
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %38, i32 %49)
br label %62
51: ; preds = %0
%52 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%53 = call i32 @putchar(i32 35)
%54 = load i32, i32* %1
%55 = call i32 @function_2(i32 %54)
%56 = load i32, i32* %2
%57 = call i32 @function_2(i32 %56)
%58 = load i32, i32* %3
%59 = call i32 @function_2(i32 %58)
br label %62
60: ; preds = %0
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %13, %51, %60
ret i32 0
}