#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') {
    for (i = 0; i < 3; i++) {
      scanf("%d", &decimal[i]);
    }
    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    125f <main+0x11f>
movsbl -0x15(%rbp),%eax
cmp    $0x64,%eax
jne    124e <main+0x10e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11ff <main+0xbf>
movslq -0x14(%rbp),%rax
lea    -0x10(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <main+0x8a>
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    0xdea(%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    125a <main+0x11a>
movl   $0x0,-0x4(%rbp)
jmp    125f <main+0x11f>
jmp    125f <main+0x11f>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%al
cmp    $0x68,%al
je     11ef <main+0xaf>
cmp    $0x64,%al
jne    122f <main+0xef>
lea    0xea2(%rip),%rbx
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x5(%rsp),%rsi
mov    %r14,%rdi
call   1060 <make_hex@plt>
movsbl 0x5(%rsp),%esi
movsbl 0x6(%rsp),%edx
movsbl 0x7(%rsp),%ecx
movsbl 0x8(%rsp),%r8d
movsbl 0x9(%rsp),%r9d
movsbl 0xa(%rsp),%r10d
movsbl 0xb(%rsp),%ebx
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   1030 <printf@plt>
add    $0x10,%rsp
jmp    122f <main+0xef>
lea    0xe0d(%rip),%rdi
lea    0x5(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <make_decimal@plt>
movsbl 0xc(%rsp),%esi
movsbl 0x10(%rsp),%edx
movsbl 0x14(%rsp),%ecx
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
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 = [3 x i8] c"%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 %67
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 %65
30: ; preds = %26
store i32 0, i32* %3
br label %31
31: ; preds = %39, %30
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %36
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %34
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %31
42: ; preds = %31
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%44 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%45 = call i32 @make_hex(i32* %43, i8* %44)
%46 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%47 = load i8, i8* %46
%48 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 1
%49 = load i8, i8* %48
%50 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 2
%51 = load i8, i8* %50
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 3
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 4
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 5
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 6
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, i8, i8, i8, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8 signext %47, i8 signext %49, i8 signext %51, i32 %54, i32 %57, i32 %60, i32 %63)
br label %66
65: ; preds = %26
store i32 0, i32* %1
br label %67
66: ; preds = %42
br label %67
67: ; preds = %65, %66, %10
%68 = load i32, i32* %1
ret i32 %68
}

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