#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*/ chars;

/* Variables and functions */
int charToInt(char);
int /*<<< orphan*/ printf(char *, char, int);
void testCharToInt() {
  int i;
  char chars[] = {'0', '1', '2', '3', '4', '5', '6',
                  '7', '8', '9', 'a', 'b', 'c'};
  int len = sizeof(chars) / sizeof(char);
  for (i = 0; i < len; i++) {
    printf("charToInt('%c'):  %d\n", chars[i], charToInt(chars[i]));
  }
}


x86 assembly (clang, -O0):
<testCharToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0xd,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119a <testCharToInt+0x7a>
movslq -0x4(%rbp),%rax
mov    -0x11(%rbp,%rax,1),%al
mov    %al,-0x19(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%edi
call   1040 <charToInt@plt>
mov    %eax,%edx
mov    -0x19(%rbp),%al
lea    0xe89(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1153 <testCharToInt+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testCharToInt>:
push   %rbx
mov    $0x30,%edi
call   1040 <charToInt@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0x30,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x31,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x31,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x32,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x33,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x33,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x34,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x34,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x35,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x35,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x36,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x36,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x37,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x37,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x38,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x38,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x39,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x39,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x61,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x61,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x62,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x62,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x63,%edi
call   1040 <charToInt@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
mov    %eax,%edx
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.testCharToInt.chars = [13 x i8] c"0123456789abc"
@.str = [22 x i8] c"charToInt('%c'): %d\0A\00"
define void @testCharToInt() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca i32
%4 = bitcast [13 x i8]* %2 to i8*
store i32 13, i32* %3
store i32 0, i32* %1
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @charToInt(i8 signext %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext %13, i32 %18)
br label %20
20: ; preds = %9
%21 = load i32, i32* %1
%22 = add nsw i32 %21, 1
store i32 %22, i32* %1
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"charToInt('%c'): %d\0A\00"
define void @testCharToInt() {
%1 = tail call i32 @charToInt(i8 signext 48)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 48, i32 %1)
%3 = tail call i32 @charToInt(i8 signext 49)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 49, i32 %3)
%5 = tail call i32 @charToInt(i8 signext 50)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 50, i32 %5)
%7 = tail call i32 @charToInt(i8 signext 51)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 51, i32 %7)
%9 = tail call i32 @charToInt(i8 signext 52)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 52, i32 %9)
%11 = tail call i32 @charToInt(i8 signext 53)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 53, i32 %11)
%13 = tail call i32 @charToInt(i8 signext 54)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 54, i32 %13)
%15 = tail call i32 @charToInt(i8 signext 55)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 55, i32 %15)
%17 = tail call i32 @charToInt(i8 signext 56)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 56, i32 %17)
%19 = tail call i32 @charToInt(i8 signext 57)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 57, i32 %19)
%21 = tail call i32 @charToInt(i8 signext 97)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 97, i32 %21)
%23 = tail call i32 @charToInt(i8 signext 98)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 98, i32 %23)
%25 = tail call i32 @charToInt(i8 signext 99)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8 signext 99, i32 %25)
ret void
}