#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*/ scanf(char *, char *);
long strtol(char *, int /*<<< orphan*/ *, int);
void hex2dec() {
  int i, r, g, b;
  char s[10], s1[10];
  long int col;
  scanf("%s", s);
  for (i = 0; i < 7; i++) {
    s1[i] = s[i + 1];
  }
  s1[6] = '\0';
  col = strtol(s1, NULL, 16);
  b = col & 0xff;
  g = (col >> 8) & 0xff;
  r = (col >> 16) & 0xff;
  printf("rgb(%d, %d, %d)", r, g, b);
}


x86 assembly (clang, -O0):
<hex2dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x1a(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x7,-0x4(%rbp)
jge    117b <hex2dec+0x4b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x1a(%rbp,%rax,1),%cl
movslq -0x4(%rbp),%rax
mov    %cl,-0x24(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <hex2dec+0x1f>
movb   $0x0,-0x1e(%rbp)
lea    -0x24(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %eax,-0x10(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x8,%rax
and    $0xff,%rax
mov    %eax,-0xc(%rbp)
mov    -0x30(%rbp),%rax
sar    $0x10,%rax
and    $0xff,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2dec>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xf(%rsp),%eax
mov    %eax,0x4(%rsp)
movzwl 0x13(%rsp),%eax
mov    %ax,0x8(%rsp)
movb   $0x0,0xa(%rsp)
lea    0x4(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
movzbl %al,%ecx
movzbl %ah,%edx
shr    $0x10,%eax
movzbl %al,%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [16 x i8] c"rgb(%d, %d, %d)\00"
define void @hex2dec() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
store i8 0, i8* %8
%9 = call i64 @strtol(i8* nocapture %5, i32* null, i32 16)
%10 = trunc i64 %9 to i32
%11 = and i32 %10, 255
%12 = lshr i32 %10, 8
%13 = and i32 %12, 255
%14 = lshr i32 %10, 16
%15 = and i32 %14, 255
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %13, i32 %11)
ret void
}