#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*/ h(char *, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, char *);
void hexadecimal() {
  int r = 0, g = 0, b = 0;
  char color[8];
  scanf("%s", color);
  h(color, 6);
  r += (color[1] - '0') * 16 + (color[2] - '0');
  g += (color[3] - '0') * 16 + (color[4] - '0');
  b += (color[5] - '0') * 16 + (color[6] - '0');
  printf("rgb(%d, %d, %d)\n", r, g, b);
}


x86 assembly (clang, -O0):
<hexadecimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x14(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x14(%rbp),%rdi
mov    $0x6,%esi
call   1030 <h@plt>
movsbl -0x13(%rbp),%eax
sub    $0x30,%eax
shl    $0x4,%eax
movsbl -0x12(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movsbl -0x11(%rbp),%eax
sub    $0x30,%eax
shl    $0x4,%eax
movsbl -0x10(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0xf(%rbp),%eax
sub    $0x30,%eax
shl    $0x4,%eax
movsbl -0xe(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexadecimal>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <h@plt>
movsbl 0x9(%rsp),%eax
shl    $0x4,%eax
movsbl 0xa(%rsp),%ecx
lea    (%rcx,%rax,1),%esi
add    $0xfffffcd0,%esi
movsbl 0xb(%rsp),%eax
shl    $0x4,%eax
movsbl 0xc(%rsp),%ecx
lea    (%rcx,%rax,1),%edx
add    $0xfffffcd0,%edx
movsbl 0xd(%rsp),%eax
shl    $0x4,%eax
movsbl 0xe(%rsp),%ecx
add    %eax,%ecx
add    $0xfffffcd0,%ecx
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
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() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = call i32 @h(i8* %7, i32 6)
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = sub nsw i32 %11, 48
%13 = mul nsw i32 %12, 16
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = sub nsw i32 %16, 48
%18 = add nsw i32 %13, %17
%19 = load i32, i32* %1
%20 = add nsw i32 %19, %18
store i32 %20, i32* %1
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = sub nsw i32 %23, 48
%25 = mul nsw i32 %24, 16
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 48
%30 = add nsw i32 %25, %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, %30
store i32 %32, i32* %2
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 48
%37 = mul nsw i32 %36, 16
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = sub nsw i32 %40, 48
%42 = add nsw i32 %37, %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, %42
store i32 %44, i32* %3
%45 = load i32, i32* %1
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %46, i32 %47)
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() {
%1 = alloca [8 x i8]
%2 = getelementptr inbounds [8 x i8], [8 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 = call i32 @h(i8* %2, i32 6)
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = shl nsw i32 %7, 4
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = add nsw i32 %11, -816
%13 = add nsw i32 %12, %8
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = shl nsw i32 %16, 4
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, -816
%22 = add nsw i32 %21, %17
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = shl nsw i32 %25, 4
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 6
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = add nsw i32 %29, -816
%31 = add nsw i32 %30, %26
%32 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %22, i32 %31)
ret void
}