#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 dec(int);
int hex(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char counting_system, color[7];
  int red, green, blue;
  char comma;
  scanf(" %c\n", &counting_system);
  switch (counting_system) {
  case 'h':
    scanf("%[^\n]s", color);
    if (color[0] = '#') {
      printf("rgb(%d, %d, %d)\n", hex(color[1]) * 16 + hex(color[2]),
             hex(color[3]) * 16 + hex(color[4]),
             hex(color[5]) * 16 + hex(color[6]));
      break;
    }
  case 'd':
    scanf("%d", &red);
    scanf("%c", &comma);
    scanf("%d", &green);
    scanf("%c", &comma);
    scanf("%d", &blue);
    printf("#%c%c%c%c%c%c \n", dec(red / 16), dec(red % 16), dec(green / 16),
           dec(green % 16), dec(blue / 16), dec(blue % 16));
    break;
  default:
    printf("Error in the input");
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x64,%eax
je     122b <main+0xeb>
jmp    1176 <main+0x36>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
jne    1327 <main+0x1e7>
jmp    1187 <main+0x47>
lea    -0xc(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movb   $0x23,-0xc(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    11ac <main+0x6c>
jmp    1226 <main+0xe6>
movsbl -0xb(%rbp),%edi
call   1060 <hex@plt>
shl    $0x4,%eax
mov    %eax,-0x34(%rbp)
movsbl -0xa(%rbp),%edi
call   1060 <hex@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
movsbl -0x9(%rbp),%edi
call   1060 <hex@plt>
shl    $0x4,%eax
mov    %eax,-0x30(%rbp)
movsbl -0x8(%rbp),%edi
call   1060 <hex@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
movsbl -0x7(%rbp),%edi
call   1060 <hex@plt>
shl    $0x4,%eax
mov    %eax,-0x2c(%rbp)
movsbl -0x6(%rbp),%edi
call   1060 <hex@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
add    %eax,%ecx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133c <main+0x1fc>
jmp    122b <main+0xeb>
lea    0xdeb(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xddc(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xdc7(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xdb8(%rip),%rdi
lea    -0x19(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xda3(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <dec@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <dec@plt>
mov    %eax,-0x44(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <dec@plt>
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <dec@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <dec@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <dec@plt>
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
lea    0xd0b(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133c <main+0x1fc>
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xead(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%eax
cmp    $0x64,%eax
je     11fc <main+0xbc>
cmp    $0x68,%eax
jne    1303 <main+0x1c3>
lea    0xe88(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movb   $0x23,0x10(%rsp)
movsbl 0x11(%rsp),%edi
call   1060 <hex@plt>
mov    %eax,%r14d
shl    $0x4,%r14d
movsbl 0x12(%rsp),%edi
call   1060 <hex@plt>
add    %eax,%r14d
movsbl 0x13(%rsp),%edi
call   1060 <hex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x14(%rsp),%edi
call   1060 <hex@plt>
add    %eax,%ebp
movsbl 0x15(%rsp),%edi
call   1060 <hex@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x16(%rsp),%edi
call   1060 <hex@plt>
add    %eax,%ebx
lea    0xe23(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1311 <main+0x1d1>
lea    0xe1a(%rip),%r14
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe07(%rip),%rbp
lea    0x17(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
lea    0xf(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x4,%edi
call   1030 <dec@plt>
mov    %eax,%r14d
mov    0x10(%rsp),%edi
lea    0xf(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff0,%eax
sub    %eax,%edi
call   1030 <dec@plt>
mov    %eax,%r15d
mov    0x1c(%rsp),%eax
lea    0xf(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x4,%edi
call   1030 <dec@plt>
mov    %eax,%r12d
mov    0x1c(%rsp),%edi
lea    0xf(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff0,%eax
sub    %eax,%edi
call   1030 <dec@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%eax
lea    0xf(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x4,%edi
call   1030 <dec@plt>
mov    %eax,%ebx
mov    0x18(%rsp),%edi
lea    0xf(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff0,%eax
sub    %eax,%edi
call   1030 <dec@plt>
mov    %eax,(%rsp)
lea    0xd38(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1311 <main+0x1d1>
lea    0xd29(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" %c\0A\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [16 x i8] c"#%c%c%c%c%c%c \0A\00"
@.str.6 = [19 x i8] c"Error in the input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [7 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
switch i32 %10, label %67 [
i32 104, label %11
i32 100, label %42
]
11: ; preds = %0
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
store i8 35, i8* %14
br i1 true, label %15, label %41
15: ; preds = %11
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%17 = load i8, i8* %16
%18 = call i32 @hex(i8 signext %17)
%19 = mul nsw i32 %18, 16
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%21 = load i8, i8* %20
%22 = call i32 @hex(i8 signext %21)
%23 = add nsw i32 %19, %22
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%25 = load i8, i8* %24
%26 = call i32 @hex(i8 signext %25)
%27 = mul nsw i32 %26, 16
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%29 = load i8, i8* %28
%30 = call i32 @hex(i8 signext %29)
%31 = add nsw i32 %27, %30
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%33 = load i8, i8* %32
%34 = call i32 @hex(i8 signext %33)
%35 = mul nsw i32 %34, 16
%36 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
%37 = load i8, i8* %36
%38 = call i32 @hex(i8 signext %37)
%39 = add nsw i32 %35, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %31, i32 %39)
br label %69
41: ; preds = %11
br label %42
42: ; preds = %0, %41
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%48 = load i32, i32* %4
%49 = sdiv i32 %48, 16
%50 = call i32 @dec(i32 %49)
%51 = load i32, i32* %4
%52 = srem i32 %51, 16
%53 = call i32 @dec(i32 %52)
%54 = load i32, i32* %5
%55 = sdiv i32 %54, 16
%56 = call i32 @dec(i32 %55)
%57 = load i32, i32* %5
%58 = srem i32 %57, 16
%59 = call i32 @dec(i32 %58)
%60 = load i32, i32* %6
%61 = sdiv i32 %60, 16
%62 = call i32 @dec(i32 %61)
%63 = load i32, i32* %6
%64 = srem i32 %63, 16
%65 = call i32 @dec(i32 %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %50, i32 %53, i32 %56, i32 %59, i32 %62, i32 %65)
br label %69
67: ; preds = %0
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %69
69: ; preds = %67, %42, %15
%70 = load i32, i32* %1
ret i32 %70
}

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