#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 htoi(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char hex1[] = "1D9";
  char hex2[] = "DEADBEEF";
  char hex3[] = "0X123456";
  printf("%s -> %u\n\n", hex1, htoi(hex1));
  printf("%s -> %u\n\n", hex2, htoi(hex2));
  printf("%s -> %u\n\n", hex3, htoi(hex3));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x16(%rbp)
mov    0xebf(%rip),%al
mov    %al,-0xe(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <htoi@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    -0xd(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0xd(%rbp),%rdi
call   1040 <htoi@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x16(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x16(%rbp),%rdi
call   1040 <htoi@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movl   $0x394431,0x4(%rsp)
movabs $0x4645454244414544,%rax
45 45 46
mov    %rax,0x18(%rsp)
movb   $0x0,0x20(%rsp)
movabs $0x3635343332315830,%rax
34 35 36
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <htoi@plt>
lea    0xea7(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <htoi@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <htoi@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.hex1 = [4 x i8] c"1D9\00"
@__const.main.hex2 = [9 x i8] c"DEADBEEF\00"
@__const.main.hex3 = [9 x i8] c"0X123456\00"
@.str = [11 x i8] c"%s -> %u\0A\0A\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = alloca [9 x i8]
%3 = alloca [9 x i8]
%4 = bitcast [4 x i8]* %1 to i8*
%5 = bitcast [9 x i8]* %2 to i8*
%6 = bitcast [9 x i8]* %3 to i8*
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%9 = call i32 @htoi(i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9)
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%13 = call i32 @htoi(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %13)
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%17 = call i32 @htoi(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@__const.main.hex2 = [9 x i8] c"DEADBEEF\00"
@__const.main.hex3 = [9 x i8] c"0X123456\00"
@.str = [11 x i8] c"%s -> %u\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca [9 x i8]
%4 = bitcast i32* %1 to i8*
store i32 3753009, i32* %1
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = call i32 @htoi(i8* %4)
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %7)
%9 = call i32 @htoi(i8* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %9)
%11 = call i32 @htoi(i8* %6)
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %11)
ret i32 0
}