#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 char_to_int(char);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, char *);
void hexadecimal_to_decimal(void) {
  int i = 0;
  int num1 = 0, num2 = 0;
  int dec[3];
  char hex[7];
  scanf("%s", hex);
  for (i = 6; i != 0; i -= 2) {
    num1 = char_to_int(hex[i]);
    num2 = char_to_int(hex[i - 1]);
    dec[(i / 2) - 1] = num1 * 1 + num2 * 16;
  }
  printf("rgb(%d, %d, %d)\n", dec[0], dec[1], dec[2]);
}


x86 assembly (clang, -O0):
<hexadecimal_to_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x1f(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x6,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11c4 <hexadecimal_to_decimal+0x94>
movslq -0x4(%rbp),%rax
movsbl -0x1f(%rbp,%rax,1),%edi
call   1040 <char_to_int@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x1f(%rbp,%rax,1),%edi
call   1040 <char_to_int@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
shl    $0x0,%ecx
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
add    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
sub    $0x1,%eax
cltq
mov    %ecx,-0x18(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <hexadecimal_to_decimal+0x34>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexadecimal_to_decimal>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0x9(%rsp),%rsi
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%r14d
movsbl 0xe(%rsp),%edi
call   1040 <char_to_int@plt>
shl    $0x4,%eax
add    %eax,%r14d
movsbl 0xd(%rsp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%ebp
movsbl 0xc(%rsp),%edi
call   1040 <char_to_int@plt>
shl    $0x4,%eax
add    %eax,%ebp
movsbl 0xb(%rsp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%ebx
movsbl 0xa(%rsp),%edi
call   1040 <char_to_int@plt>
shl    $0x4,%eax
add    %eax,%ebx
lea    0xe60(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
define void @hexadecimal_to_decimal() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 6
%5 = load i8, i8* %4
%6 = call i32 @char_to_int(i8 signext %5)
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 5
%8 = load i8, i8* %7
%9 = call i32 @char_to_int(i8 signext %8)
%10 = shl nsw i32 %9, 4
%11 = add nsw i32 %10, %6
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 4
%13 = load i8, i8* %12
%14 = call i32 @char_to_int(i8 signext %13)
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 3
%16 = load i8, i8* %15
%17 = call i32 @char_to_int(i8 signext %16)
%18 = shl nsw i32 %17, 4
%19 = add nsw i32 %18, %14
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 2
%21 = load i8, i8* %20
%22 = call i32 @char_to_int(i8 signext %21)
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 1
%24 = load i8, i8* %23
%25 = call i32 @char_to_int(i8 signext %24)
%26 = shl nsw i32 %25, 4
%27 = add nsw i32 %26, %22
%28 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %19, i32 %11)
ret void
}