#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 */
char *dec_to_hex(int);
int *get_numbers(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main() {
  char number_type;
  scanf("%c", &number_type);
  if (number_type == 'd') {
    char dec_code_color[15];
    scanf(" %[^\n]s", dec_code_color);
    int *numbers = get_numbers(dec_code_color);
    int red_dec;
    red_dec = numbers[0];
    int green_dec;
    green_dec = numbers[1];
    int blue_dec;
    blue_dec = numbers[2];
    char *red_hex;
    red_hex = dec_to_hex(red_dec);
    char *green_hex;
    green_hex = dec_to_hex(green_dec);
    char *blue_hex;
    blue_hex = dec_to_hex(blue_dec);
    printf("#%s%s%s", red_hex, green_hex, blue_hex);
  } else if (number_type == 'h') {
    char hex_code_color[9];
    scanf(" %[^\n]s", hex_code_color);
    char red_hex[] = {hex_code_color[1], hex_code_color[2]};
    char green_hex[] = {hex_code_color[3], hex_code_color[4]};
    char blue_hex[] = {hex_code_color[5], hex_code_color[6]};
    int red_dec;
    red_dec = (int)strtol(red_hex, NULL, 16);
    int green_dec;
    green_dec = (int)strtol(green_hex, NULL, 16);
    int blue_dec;
    blue_dec = (int)strtol(blue_hex, NULL, 16);
    printf("rgb(%d, %d, %d)", red_dec, green_dec, blue_dec);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11f9 <main+0xa9>
lea    -0x14(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x14(%rbp),%rdi
call   1070 <get_numbers@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <dec_to_hex@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <dec_to_hex@plt>
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <dec_to_hex@plt>
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1295 <main+0x145>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    1290 <main+0x140>
lea    -0x51(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x50(%rbp),%al
mov    %al,-0x53(%rbp)
mov    -0x4f(%rbp),%al
mov    %al,-0x52(%rbp)
mov    -0x4e(%rbp),%al
mov    %al,-0x55(%rbp)
mov    -0x4d(%rbp),%al
mov    %al,-0x54(%rbp)
mov    -0x4c(%rbp),%al
mov    %al,-0x57(%rbp)
mov    -0x4b(%rbp),%al
mov    %al,-0x56(%rbp)
lea    -0x53(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x55(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,-0x60(%rbp)
lea    -0x57(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,-0x64(%rbp)
mov    -0x5c(%rbp),%esi
mov    -0x60(%rbp),%edx
mov    -0x64(%rbp),%ecx
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1295 <main+0x145>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    0xa(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xa(%rsp),%al
cmp    $0x68,%al
je     11cf <main+0x7f>
cmp    $0x64,%al
jne    124b <main+0xfb>
lea    0xe83(%rip),%rdi
lea    0x11(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1070 <get_numbers@plt>
mov    (%rax),%edi
mov    0x4(%rax),%ebx
mov    0x8(%rax),%ebp
call   1040 <dec_to_hex@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1040 <dec_to_hex@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <dec_to_hex@plt>
lea    0xe4e(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    124b <main+0xfb>
lea    0xe2d(%rip),%rdi
lea    0x11(%rsp),%rsi
call   1060 <scanf@plt>
movzwl 0x12(%rsp),%eax
movzwl 0x14(%rsp),%ecx
mov    %ax,0xf(%rsp)
mov    %cx,0xd(%rsp)
movzwl 0x16(%rsp),%eax
mov    %ax,0xb(%rsp)
lea    0xf(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
lea    0xd(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %rax,%rbp
lea    0xb(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
lea    0xdd5(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [8 x i8] c" %[^\0A]s\00"
@.str.2 = [8 x i8] c"#%s%s%s\00"
@.str.3 = [16 x i8] c"rgb(%d, %d, %d)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [15 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [9 x i8]
%12 = alloca [2 x i8]
%13 = alloca [2 x i8]
%14 = alloca [2 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %1
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 100
br i1 %21, label %22, label %46
22: ; preds = %0
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%26 = call i32* @get_numbers(i8* %25)
store i32* %26, i32** %4
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
store i32 %29, i32* %5
%30 = load i32*, i32** %4
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
store i32 %32, i32* %6
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 2
%35 = load i32, i32* %34
store i32 %35, i32* %7
%36 = load i32, i32* %5
%37 = call i8* @dec_to_hex(i32 %36)
store i8* %37, i8** %8
%38 = load i32, i32* %6
%39 = call i8* @dec_to_hex(i32 %38)
store i8* %39, i8** %9
%40 = load i32, i32* %7
%41 = call i8* @dec_to_hex(i32 %40)
store i8* %41, i8** %10
%42 = load i8*, i8** %8
%43 = load i8*, i8** %9
%44 = load i8*, i8** %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %43, i8* %44)
br label %85
46: ; preds = %0
%47 = load i8, i8* %2
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 104
br i1 %49, label %50, label %84
50: ; preds = %46
%51 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%52 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %51)
%53 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%54 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 1
%55 = load i8, i8* %54
store i8 %55, i8* %53
%56 = getelementptr inbounds i8, i8* %53, i64 1
%57 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 2
%58 = load i8, i8* %57
store i8 %58, i8* %56
%59 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%60 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 3
%61 = load i8, i8* %60
store i8 %61, i8* %59
%62 = getelementptr inbounds i8, i8* %59, i64 1
%63 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 4
%64 = load i8, i8* %63
store i8 %64, i8* %62
%65 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%66 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 5
%67 = load i8, i8* %66
store i8 %67, i8* %65
%68 = getelementptr inbounds i8, i8* %65, i64 1
%69 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 6
%70 = load i8, i8* %69
store i8 %70, i8* %68
%71 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%72 = call i64 @strtol(i8* %71, i32* null, i32 16)
%73 = trunc i64 %72 to i32
store i32 %73, i32* %15
%74 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%75 = call i64 @strtol(i8* %74, i32* null, i32 16)
%76 = trunc i64 %75 to i32
store i32 %76, i32* %16
%77 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%78 = call i64 @strtol(i8* %77, i32* null, i32 16)
%79 = trunc i64 %78 to i32
store i32 %79, i32* %17
%80 = load i32, i32* %15
%81 = load i32, i32* %16
%82 = load i32, i32* %17
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %80, i32 %81, i32 %82)
br label %84
84: ; preds = %50, %46
br label %85
85: ; preds = %84, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [8 x i8] c" %[^\0A]s\00"
@.str.2 = [8 x i8] c"#%s%s%s\00"
@.str.3 = [16 x i8] c"rgb(%d, %d, %d)\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [15 x i8]
%3 = alloca [9 x i8]
%4 = alloca [2 x i8]
%5 = alloca [2 x i8]
%6 = alloca [2 x i8]
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
switch i8 %8, label %50 [
i8 100, label %9
i8 104, label %22
]
9: ; preds = %0
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32* @get_numbers(i8* %10)
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %12, i64 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %12, i64 2
%17 = load i32, i32* %16
%18 = call i8* @dec_to_hex(i32 %13)
%19 = call i8* @dec_to_hex(i32 %15)
%20 = call i8* @dec_to_hex(i32 %17)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i8* %20)
br label %50
22: ; preds = %0
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 1
%27 = load i8, i8* %26
store i8 %27, i8* %25
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 2
%30 = load i8, i8* %29
store i8 %30, i8* %28
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 3
%33 = load i8, i8* %32
store i8 %33, i8* %31
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%35 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 4
%36 = load i8, i8* %35
store i8 %36, i8* %34
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 5
%39 = load i8, i8* %38
store i8 %39, i8* %37
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%41 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 6
%42 = load i8, i8* %41
store i8 %42, i8* %40
%43 = call i64 @strtol(i8* nocapture %25, i32* null, i32 16)
%44 = trunc i64 %43 to i32
%45 = call i64 @strtol(i8* nocapture %31, i32* null, i32 16)
%46 = trunc i64 %45 to i32
%47 = call i64 @strtol(i8* nocapture %37, i32* null, i32 16)
%48 = trunc i64 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %46, i32 %48)
br label %50
50: ; preds = %0, %22, %9
ret i32 0
}