#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 /*<<< orphan*/ scanf(char *, ...);
int main() {
  unsigned int dec[2], hex[2];
  char system;
  scanf("%c", &system);
  if (system == 'h') {
    printf("#");
    scanf("%2x%2x%2x", &hex[0], &hex[1], &hex[2]);
    printf("rgb(%d,%d,%d)", hex[0], hex[1], hex[2]);
  }
  if (system == 'd') {
    scanf("%d,%d,%d", &dec[0], &dec[1], &dec[2]);
    printf("#");
    printf("%x%x%x", dec[0], dec[1], dec[2]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x68,%eax
jne    1195 <main+0x75>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rsi
lea    -0x14(%rbp),%rdx
add    $0x4,%rdx
lea    -0x14(%rbp),%rcx
add    $0x8,%rcx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x64,%eax
jne    11e9 <main+0xc9>
lea    -0xc(%rbp),%rsi
lea    -0xc(%rbp),%rdx
add    $0x4,%rdx
lea    -0xc(%rbp),%rcx
add    $0x8,%rcx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
cmp    $0x68,%al
jne    1194 <main+0x64>
mov    $0x23,%edi
call   1030 <putchar@plt>
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xe99(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x7(%rsp),%al
cmp    $0x64,%al
jne    11d9 <main+0xa9>
lea    0x14(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0xe72(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"#\00"
@.str.2 = [10 x i8] c"%2x%2x%2x\00"
@.str.3 = [14 x i8] c"rgb(%d,%d,%d)\00"
@.str.4 = [9 x i8] c"%d,%d,%d\00"
@.str.5 = [7 x i8] c"%x%x%x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 104
br i1 %8, label %9, label %22
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 2
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 2
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %18, i32 %20)
br label %22
22: ; preds = %9, %0
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 100
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 2
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %27, i32* %28, i32* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%33 = load i32, i32* %32
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%35 = load i32, i32* %34
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 2
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %35, i32 %37)
br label %39
39: ; preds = %26, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.2 = [10 x i8] c"%2x%2x%2x\00"
@.str.3 = [14 x i8] c"rgb(%d,%d,%d)\00"
@.str.4 = [9 x i8] c"%d,%d,%d\00"
@.str.5 = [7 x i8] c"%x%x%x\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca i8
%4 = bitcast [2 x i32]* %1 to i8*
%5 = bitcast [2 x i32]* %2 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 104
br i1 %8, label %9, label %20
9: ; preds = %0
%10 = call i32 @putchar(i32 35)
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 2
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%15 = load i32, i32* %11
%16 = load i32, i32* %12
%17 = load i32, i32* %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%19 = load i8, i8* %3
br label %20
20: ; preds = %9, %0
%21 = phi i8 [ %19, %9 ], [ %7, %0 ]
%22 = icmp eq i8 %21, 100
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 2
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %24, i32* %25, i32* %26)
%28 = call i32 @putchar(i32 35)
%29 = load i32, i32* %24
%30 = load i32, i32* %25
%31 = load i32, i32* %26
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
br label %33
33: ; preds = %23, %20
ret i32 0
}