#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int htoi(char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  size_t i;
  char *s[] = {
      "beef", "BEEF", "0x12", "0X34", "0ead", "002a", "2345", "xead",
  };
  for (i = 0; i < sizeof(s) / sizeof(s[0]); i++) {
    printf("%d\n", htoi(s[i]));
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c96(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x8,-0x10(%rbp)
jae    1194 <main+0x64>
mov    -0x10(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1050 <htoi@plt>
mov    %eax,%esi
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115c <main+0x2c>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1040 <htoi@plt>
lea    0xef4(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
call   1040 <htoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"beef\00"
@.str.1 = [5 x i8] c"BEEF\00"
@.str.2 = [5 x i8] c"0x12\00"
@.str.3 = [5 x i8] c"0X34\00"
@.str.4 = [5 x i8] c"0ead\00"
@.str.5 = [5 x i8] c"002a\00"
@.str.6 = [5 x i8] c"2345\00"
@.str.7 = [5 x i8] c"xead\00"
@__const.main.s = [8 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0)]
@.str.8 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [8 x i8*]
store i32 0, i32* %1
%4 = bitcast [8 x i8*]* %3 to i8*
store i64 0, i64* %2
br label %5
5: ; preds = %14, %0
%6 = load i64, i64* %2
%7 = icmp ult i64 %6, 8
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i64, i64* %2
%10 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = call i32 @htoi(i8* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %8
%15 = load i64, i64* %2
%16 = add i64 %15, 1
store i64 %16, i64* %2
br label %5
17: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"beef\00"
@.str.1 = [5 x i8] c"BEEF\00"
@.str.2 = [5 x i8] c"0x12\00"
@.str.3 = [5 x i8] c"0X34\00"
@.str.4 = [5 x i8] c"0ead\00"
@.str.5 = [5 x i8] c"002a\00"
@.str.6 = [5 x i8] c"2345\00"
@.str.7 = [5 x i8] c"xead\00"
@.str.8 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %1)
%3 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %3)
%5 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %5)
%7 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %7)
%9 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %9)
%11 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %11)
%13 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %13)
%15 = tail call i32 @htoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %15)
ret i32 0
}