#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*/ d_to_h(int, int, int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char type, chara;
  unsigned int r, g, b;
  scanf("%s", &type);
  if (type == 'd') {
    int r, g, b;
    scanf("%d, %d, %d", &r, &g, &b);
    d_to_h(r, g, b);
  }
  if (type == 'h') {
    scanf(" %c%02x%02x%02x", &chara, &r, &g, &b);
    printf("rgb(%d, %d, %d) \n\n", r, g, b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    $0x64,%eax
jne    1186 <main+0x56>
lea    0xe9e(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <d_to_h@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11c6 <main+0x96>
lea    0xe74(%rip),%rdi
lea    -0x6(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe5d(%rip),%rdi
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    $0x64,%al
jne    1181 <main+0x51>
lea    0xead(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1040 <d_to_h@plt>
mov    0x7(%rsp),%al
cmp    $0x68,%al
jne    11bf <main+0x8f>
lea    0xe82(%rip),%rdi
lea    0x17(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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