#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*/ DecToHex(int, int, int, char *);
int /*<<< orphan*/ HexToDec(char *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char choice, hRGB[8];
  int dR, dG, dB;
  scanf("%c", &choice);
  if (choice == 'h') {
    scanf("%s", hRGB);
    HexToDec(hRGB, &dR, &dG, &dB);
    printf("rgb(%d, %d, %d)", dR, dG, dB);
  } else if (choice == 'd') {
    scanf("%d, %d, %d", &dR, &dG, &dB);
    DecToHex(dR, dG, dB, hRGB);
    printf("%s", hRGB);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11b1 <main+0x71>
lea    -0xd(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0xd(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <HexToDec@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1201 <main+0xc1>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11fc <main+0xbc>
lea    0xe51(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0xd(%rbp),%rcx
call   1030 <DecToHex@plt>
lea    -0xd(%rbp),%rsi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1201 <main+0xc1>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xb(%rsp),%al
cmp    $0x64,%al
je     11b1 <main+0x71>
cmp    $0x68,%al
jne    11f8 <main+0xb8>
lea    0xe94(%rip),%rdi
lea    0x18(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1040 <HexToDec@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f8 <main+0xb8>
lea    0xe5e(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x18(%rsp),%rbx
mov    %rbx,%rcx
call   1030 <DecToHex@plt>
lea    0xe15(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 104
br i1 %10, label %11, label %20
11: ; preds = %0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%15 = call i32 @HexToDec(i8* %14, i32* %4, i32* %5, i32* %6)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
br label %34
20: ; preds = %0
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 100
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = 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)
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%30 = call i32 @DecToHex(i32 %26, i32 %27, i32 %28, i8* %29)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %24, %20
br label %34
34: ; preds = %33, %11
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"
define i32 @main() {
%1 = alloca i8
%2 = alloca [8 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%11 = load i8, i8* %1
switch i8 %11, label %26 [
i8 104, label %12
i8 100, label %19
]
12: ; preds = %0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = call i32 @HexToDec(i8* %6, i32* %3, i32* %4, i32* %5)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
br label %26
19: ; preds = %0
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @DecToHex(i32 %21, i32 %22, i32 %23, i8* %6)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %26
26: ; preds = %0, %19, %12
ret i32 0
}