int main(void) {
  char hex1[] = "0x09";
  char hex2[] = "0xaf";
  char hex3[] = "0xAF";
  printf("tolower: %s %s %s\n", to_lower_str(hex1), to_lower_str(hex2),
         to_lower_str(hex3));
  printf("htoi: %d %d %d\n", htoi(hex1), htoi(hex2), htoi(hex3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xea9(%rip),%al
mov    %al,-0xa(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xe9c(%rip),%al
mov    %al,-0xf(%rbp)
lea    -0x9(%rbp),%rdi
mov    $0x0,%al
call   1040 <to_lower_str@plt>
mov    %eax,-0x24(%rbp)
lea    -0xe(%rbp),%rdi
mov    $0x0,%al
call   1040 <to_lower_str@plt>
mov    %eax,-0x20(%rbp)
lea    -0x13(%rbp),%rdi
mov    $0x0,%al
call   1040 <to_lower_str@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x9(%rbp),%rdi
mov    $0x0,%al
call   1050 <htoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xe(%rbp),%rdi
mov    $0x0,%al
call   1050 <htoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0x13(%rbp),%rdi
mov    $0x0,%al
call   1050 <htoi@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movb   $0x0,0x1c(%rsp)
movl   $0x39307830,0x18(%rsp)
39
movb   $0x0,0x14(%rsp)
movl   $0x66617830,0x10(%rsp)
66
movb   $0x0,0xc(%rsp)
movl   $0x46417830,0x8(%rsp)
46
lea    0x18(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <to_lower_str@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <to_lower_str@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <to_lower_str@plt>
lea    0xe74(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <htoi@plt>
mov    %eax,%ebx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <htoi@plt>
mov    %eax,%ebp
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <htoi@plt>
lea    0xe51(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.hex1 = [5 x i8] c"0x09\00"
@__const.main.hex2 = [5 x i8] c"0xaf\00"
@__const.main.hex3 = [5 x i8] c"0xAF\00"
@.str = [19 x i8] c"tolower: %s %s %s\0A\00"
@.str.1 = [16 x i8] c"htoi: %d %d %d\0A\00"
define i32 @main() {
%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 (i8*, ...) bitcast (i32 (...)* @to_lower_str to i32 (i8*, ...)*)(i8* %4)
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @to_lower_str to i32 (i8*, ...)*)(i8* %5)
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @to_lower_str to i32 (i8*, ...)*)(i8* %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @htoi to i32 (i8*, ...)*)(i8* %4)
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @htoi to i32 (i8*, ...)*)(i8* %5)
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @htoi to i32 (i8*, ...)*)(i8* %6)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
ret i32 0
}