#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*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int strtol(char *, int /*<<< orphan*/ *, int);
int main() {
  char i, d[3][3], s[8];
  int a, b, c, k, m;
  int ar[3];
  scanf("%c", &i);
  if (i == 'h') {
    scanf("%s", s);
    for (k = 1; k < 7; k += 2) {
      for (m = 0; m < 2; m++) {
        d[(k - 1) / 2][m] = s[k + m];
      }
      d[(k - 1) / 2][m] = '\0';
    }
    for (k = 0; k < 3; k++) {
      ar[k] = strtol(d[k], NULL, 16);
    }
    printf("rgb(%d, %d, %d)", ar[0], ar[1], ar[2]);
  }
  if (i == 'd') {
    scanf("%d, %d, %d", &a, &b, &c);
    printf("#%x%x%x", a, b, c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    1262 <main+0x132>
lea    -0x16(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x28(%rbp)
cmpl   $0x7,-0x28(%rbp)
jge    1207 <main+0xd7>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    11d5 <main+0xa5>
mov    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
cltq
mov    -0x16(%rbp,%rax,1),%al
mov    %al,-0x39(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x39(%rbp),%dl
movslq %eax,%rcx
lea    -0xe(%rbp),%rax
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <main+0x58>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %eax,%rcx
lea    -0xe(%rbp),%rax
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    1177 <main+0x47>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    124d <main+0x11d>
movslq -0x28(%rbp),%rax
lea    -0xe(%rbp),%rdi
imul   $0x3,%rax,%rax
add    %rax,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x38(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120e <main+0xde>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xda9(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    129e <main+0x16e>
lea    0xda0(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xd88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
lea    0x1(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x1(%rsp),%al
cmp    $0x68,%al
jne    11ea <main+0xba>
lea    0xea5(%rip),%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzwl 0x19(%rsp),%eax
movzwl 0x1b(%rsp),%ecx
mov    %ax,0x2(%rsp)
movb   $0x0,0x4(%rsp)
lea    0x5(%rsp),%rbx
mov    %cx,0x5(%rsp)
movb   $0x0,0x7(%rsp)
lea    0x8(%rsp),%r14
movzwl 0x1d(%rsp),%eax
mov    %ax,0x8(%rsp)
movb   $0x0,0xa(%rsp)
lea    0x2(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
lea    0xe2b(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    0x1(%rsp),%al
cmp    $0x64,%al
jne    1223 <main+0xf3>
lea    0xe21(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe03(%rip),%rdi
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 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"rgb(%d, %d, %d)\00"
@.str.3 = [11 x i8] c"%d, %d, %d\00"
@.str.4 = [8 x i8] c"#%x%x%x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [3 x [3 x i8]]
%4 = alloca [8 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [3 x i32]
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 104
br i1 %14, label %15, label %79
15: ; preds = %0
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 1, i32* %8
br label %18
18: ; preds = %52, %15
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 7
br i1 %20, label %21, label %55
21: ; preds = %18
store i32 0, i32* %9
br label %22
22: ; preds = %40, %21
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = sdiv i32 %33, 2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 %35
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %36, i64 0, i64 %38
store i8 %31, i8* %39
br label %40
40: ; preds = %25
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %22
43: ; preds = %22
%44 = load i32, i32* %8
%45 = sub nsw i32 %44, 1
%46 = sdiv i32 %45, 2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 %47
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x i8], [3 x i8]* %48, i64 0, i64 %50
store i8 0, i8* %51
br label %52
52: ; preds = %43
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 2
store i32 %54, i32* %8
br label %18
55: ; preds = %18
store i32 0, i32* %8
br label %56
56: ; preds = %68, %55
%57 = load i32, i32* %8
%58 = icmp slt i32 %57, 3
br i1 %58, label %59, label %71
59: ; preds = %56
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 %61
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %62, i64 0, i64 0
%64 = call i32 @strtol(i8* %63, i32* null, i32 16)
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 %66
store i32 %64, i32* %67
br label %68
68: ; preds = %59
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %56
71: ; preds = %56
%72 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%73 = load i32, i32* %72
%74 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%75 = load i32, i32* %74
%76 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%77 = load i32, i32* %76
%78 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %73, i32 %75, i32 %77)
br label %79
79: ; preds = %71, %0
%80 = load i8, i8* %2
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 100
br i1 %82, label %83, label %89
83: ; preds = %79
%84 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%85 = load i32, i32* %5
%86 = load i32, i32* %6
%87 = load i32, i32* %7
%88 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %85, i32 %86, i32 %87)
br label %89
89: ; preds = %83, %79
ret i32 0
}

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 = [11 x i8] c"%d, %d, %d\00"
@.str.4 = [8 x i8] c"#%x%x%x\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [3 x [3 x i8]]
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 0, i64 0
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 104
br i1 %14, label %15, label %39
15: ; preds = %0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
%18 = bitcast i8* %17 to i16*
%19 = bitcast [3 x [3 x i8]]* %2 to i16*
%20 = load i16, i16* %18
store i16 %20, i16* %19
%21 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 0, i64 2
store i8 0, i8* %21
%22 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 1, i64 0
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
%24 = bitcast i8* %23 to i16*
%25 = bitcast i8* %22 to i16*
%26 = load i16, i16* %24
store i16 %26, i16* %25
%27 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 1, i64 2
store i8 0, i8* %27
%28 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 2, i64 0
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
%30 = bitcast i8* %29 to i16*
%31 = bitcast i8* %28 to i16*
%32 = load i16, i16* %30
store i16 %32, i16* %31
%33 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %2, i64 0, i64 2, i64 2
store i8 0, i8* %33
%34 = call i32 @strtol(i8* nocapture %7, i32* null, i32 16)
%35 = call i32 @strtol(i8* nocapture %22, i32* null, i32 16)
%36 = call i32 @strtol(i8* nocapture %28, i32* null, i32 16)
%37 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35, i32 %36)
%38 = load i8, i8* %1
br label %39
39: ; preds = %15, %0
%40 = phi i8 [ %38, %15 ], [ %13, %0 ]
%41 = icmp eq i8 %40, 100
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
br label %48
48: ; preds = %42, %39
ret i32 0
}