#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*/ make_decimal(char *, int *);
int /*<<< orphan*/ make_hex(int *, char *);
int /*<<< orphan*/ printf(char *, char, char, char, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int decimal[3], i;
  char n, hex[7];
  scanf("%c", &n);
  if (n == 'h') {
    scanf("%s", hex);
    make_decimal(hex, decimal);
    printf("rgb(%d, %d, %d)\n", decimal[0], decimal[1], decimal[2]);
  } else if (n == 'd') {
    scanf("%d,%d,%d", &decimal[0], &decimal[1], &decimal[3]);
    make_hex(decimal, hex);
    printf("%c%c%c%c%c%c%c \n", hex[0], hex[1], hex[2], hex[3], hex[4], hex[5],
           hex[6]);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x68,%eax
jne    11b6 <main+0x76>
lea    -0x1c(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <make_decimal@plt>
mov    -0x10(%rbp),%eax
mov    %al,%dl
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
lea    0xe65(%rip),%rdi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl %al,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1245 <main+0x105>
movsbl -0x15(%rbp),%eax
cmp    $0x64,%eax
jne    1234 <main+0xf4>
lea    -0x10(%rbp),%rsi
lea    -0x10(%rbp),%rdx
add    $0x4,%rdx
lea    -0x10(%rbp),%rcx
add    $0xc,%rcx
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <make_hex@plt>
mov    -0x1c(%rbp),%sil
mov    -0x1b(%rbp),%dl
mov    -0x1a(%rbp),%cl
movsbl -0x19(%rbp),%r8d
movsbl -0x18(%rbp),%r9d
movsbl -0x17(%rbp),%r10d
movsbl -0x16(%rbp),%eax
lea    0xe0a(%rip),%rdi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1240 <main+0x100>
movl   $0x0,-0x4(%rbp)
jmp    1245 <main+0x105>
jmp    1245 <main+0x105>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%al
cmp    $0x64,%al
je     11aa <main+0x6a>
cmp    $0x68,%al
jne    1212 <main+0xd2>
lea    0xe94(%rip),%rdi
lea    0xd(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <make_decimal@plt>
movsbl 0x14(%rsp),%esi
movsbl 0x18(%rsp),%edx
movsbl 0x1c(%rsp),%ecx
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1212 <main+0xd2>
lea    0x18(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0xe5c(%rip),%rdi
lea    0x14(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xd(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <make_hex@plt>
movsbl 0xd(%rsp),%esi
movsbl 0xe(%rsp),%edx
movsbl 0xf(%rsp),%ecx
movsbl 0x10(%rsp),%r8d
movsbl 0x11(%rsp),%r9d
movsbl 0x12(%rsp),%r10d
movsbl 0x13(%rsp),%ebx
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   1030 <printf@plt>
add    $0x10,%rsp
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
@.str.3 = [9 x i8] c"%d,%d,%d\00"
@.str.4 = [17 x i8] c"%c%c%c%c%c%c%c \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i8
%5 = alloca [7 x i8]
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* %4)
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 104
br i1 %9, label %10, label %26
10: ; preds = %0
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%15 = call i32 @make_decimal(i8* %13, i32* %14)
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%17 = load i32, i32* %16
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%20 = load i32, i32* %19
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%23 = load i32, i32* %22
%24 = trunc i32 %23 to i8
%25 = call i32 (i8*, i8, i8, i8, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8 signext %18, i8 signext %21, i8 signext %24)
br label %59
26: ; preds = %0
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 100
br i1 %29, label %30, label %57
30: ; preds = %26
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 3
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %31, i32* %32, i32* %33)
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%36 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%37 = call i32 @make_hex(i32* %35, i8* %36)
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%39 = load i8, i8* %38
%40 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 1
%41 = load i8, i8* %40
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
%43 = load i8, i8* %42
%44 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 4
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 5
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 6
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, i8, i8, i8, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8 signext %39, i8 signext %41, i8 signext %43, i32 %46, i32 %49, i32 %52, i32 %55)
br label %58
57: ; preds = %26
store i32 0, i32* %1
br label %59
58: ; preds = %30
br label %59
59: ; preds = %57, %58, %10
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
@.str.3 = [9 x i8] c"%d,%d,%d\00"
@.str.4 = [17 x i8] c"%c%c%c%c%c%c%c \0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca i8
%3 = alloca [7 x i8]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%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
switch i8 %7, label %45 [
i8 104, label %8
i8 100, label %21
]
8: ; preds = %0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%11 = call i32 @make_decimal(i8* %5, i32* %10)
%12 = load i32, i32* %10
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%15 = load i32, i32* %14
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%18 = load i32, i32* %17
%19 = trunc i32 %18 to i8
%20 = call i32 (i8*, i8, i8, i8, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8 signext %13, i8 signext %16, i8 signext %19)
br label %45
21: ; preds = %0
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 3
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %22, i32* %23, i32* %24)
%26 = call i32 @make_hex(i32* %22, i8* %5)
%27 = load i8, i8* %5
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%29 = load i8, i8* %28
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%31 = load i8, i8* %30
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, i8, i8, i8, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8 signext %27, i8 signext %29, i8 signext %31, i32 %34, i32 %37, i32 %40, i32 %43)
br label %45
45: ; preds = %8, %21, %0
ret i32 0
}