#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 *, unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int decNum1, decNum2, decNum3;
  unsigned int hexNum1, hexNum2, hexNum3;
  char c, choice;
  scanf("%c", &choice);
  if (choice == 'd') {
    scanf("%d,%d,%d", &decNum1, &decNum2, &decNum3);
    printf("#%02x%02x%02x", decNum1, decNum2, decNum3);
  }
  if (choice == 'h') {
    scanf(" %c%02x%02x%02x", &c, &hexNum1, &hexNum2, &hexNum3);
    printf("rgb(%d, %d, %d)", hexNum1, hexNum2, hexNum3);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x1e(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x64,%eax
jne    117d <main+0x5d>
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x68,%eax
jne    11bd <main+0x9d>
lea    0xe89(%rip),%rdi
lea    -0x1d(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xed5(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xe(%rsp),%al
cmp    $0x64,%al
jne    1178 <main+0x58>
lea    0xebd(%rip),%rdi
lea    0x24(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x1c(%rsp),%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x24(%rsp),%esi
mov    0x20(%rsp),%edx
mov    0x1c(%rsp),%ecx
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    0xe(%rsp),%al
cmp    $0x68,%al
jne    11b6 <main+0x96>
lea    0xe97(%rip),%rdi
lea    0xf(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

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

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