#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, char *, char *, char *);
char *strtok(char *, char *);
void dec2hex(void) {
  int i, j, k;
  char r[5], g[5], b[5];
  scanf("%s %s %s", r, g, b);
  i = atoi(strtok(r, ","));
  j = atoi(strtok(g, ","));
  k = atoi(b);
  printf("#%02x%02x%02x", i, j, k);
}


x86 assembly (clang, -O0):
<dec2hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x11(%rbp),%rsi
lea    -0x16(%rbp),%rdx
lea    -0x1b(%rbp),%rcx
lea    0xea5(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x11(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
lea    -0x16(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x8(%rbp)
lea    -0x1b(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2hex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xb(%rsp),%rbx
lea    0x6(%rsp),%r15
lea    0x1(%rsp),%r14
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <scanf@plt>
lea    0xe92(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <atoi@plt>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s %s %s\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [14 x i8] c"#%02x%02x%02x\00"
define void @dec2hex() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
%6 = alloca [5 x i8]
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8, i8* %9)
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %1
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %2
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %3
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s %s %s\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [14 x i8] c"#%02x%02x%02x\00"
define void @dec2hex() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
%8 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @atoi(i8* %8)
%10 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @atoi(i8* %10)
%12 = call i32 @atoi(i8* %6)
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %11, i32 %12)
ret void
}