#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 *, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
void convert_to_dec(char *hex) {
  unsigned int dec_num = 0;
  int red = 0;
  int green = 0;
  int blue = 0;
  hex = hex + 1;
  sscanf(hex, "%x", &dec_num);
  red = (dec_num >> 16) & 0xFF;
  green = (dec_num >> 8) & 0xFF;
  blue = dec_num & 0xFF;
  printf("rgb(%d, %d, %d)\n", red, green, blue);
  return;
}


x86 assembly (clang, -O0):
<convert_to_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0xc(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_to_dec>:
push   %rax
movl   $0x0,0x4(%rsp)
add    $0x1,%rdi
lea    0xecc(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0x4(%rsp),%eax
movzbl %ah,%edx
movzbl %al,%ecx
shr    $0x10,%eax
movzbl %al,%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
define void @convert_to_dec(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = lshr i32 %11, 16
%13 = and i32 %12, 255
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = lshr i32 %14, 8
%16 = and i32 %15, 255
store i32 %16, i32* %5
%17 = load i32, i32* %3
%18 = and i32 %17, 255
store i32 %18, i32* %6
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@.str.1 = [17 x i8] c"rgb(%d, %d, %d)\0A\00"
define void @convert_to_dec(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = lshr i32 %6, 16
%8 = and i32 %7, 255
%9 = lshr i32 %6, 8
%10 = and i32 %9, 255
%11 = and i32 %6, 255
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10, i32 %11)
ret void
}