#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 /*<<< orphan*/ htoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  char a[10];
  for (i = 0; i < 10; i++)
    a[i] = 0;
  a[0] = 'a';
  a[1] = '0';
  a[2] = 'x';
  a[3] = '5';
  a[4] = '0';
  a[5] = 'X';
  a[6] = 'F';
  a[7] = '0';
  a[8] = 'B';
  printf("\nThe initial string is: %s:\n\n", a);
  printf("\nConverting to integers...\n\n");
  htoi(a);
  printf("\nThe converted array contains the following:\n");
  for (i = 0; i < 10; i++)
    printf("a[%d]: %d\n", i, a[i]);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1157 <main+0x37>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x12(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
movb   $0x61,-0x12(%rbp)
movb   $0x30,-0x11(%rbp)
movb   $0x78,-0x10(%rbp)
movb   $0x35,-0xf(%rbp)
movb   $0x30,-0xe(%rbp)
movb   $0x58,-0xd(%rbp)
movb   $0x46,-0xc(%rbp)
movb   $0x30,-0xb(%rbp)
movb   $0x42,-0xa(%rbp)
lea    -0x12(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x12(%rbp),%rdi
call   1040 <htoi@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11eb <main+0xcb>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b9 <main+0x99>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x3046583035783061,%rax
58 46 30
mov    %rax,0x6(%rsp)
movw   $0x42,0xe(%rsp)
lea    0xeae(%rip),%rdi
lea    0x6(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <htoi@plt>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
movsbl 0x6(%rsp),%edx
lea    0xe91(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x7(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x9(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xa(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xb(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xd(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xe(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xf(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0AThe initial string is: %s:\0A\0A\00"
@.str.1 = [29 x i8] c"\0AConverting to integers...\0A\0A\00"
@.str.2 = [46 x i8] c"\0AThe converted array contains the following:\0A\00"
@.str.3 = [11 x i8] c"a[%d]: %d\0A\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %11, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %9
store i8 0, i8* %10
br label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %4
14: ; preds = %4
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 97, i8* %15
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 48, i8* %16
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 120, i8* %17
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 53, i8* %18
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
store i8 48, i8* %19
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
store i8 88, i8* %20
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 6
store i8 70, i8* %21
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 7
store i8 48, i8* %22
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
store i8 66, i8* %23
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%28 = call i32 @htoi(i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %30
30: ; preds = %41, %14
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load i32, i32* %2
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %39)
br label %41
41: ; preds = %33
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %30
44: ; preds = %30
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0AThe initial string is: %s:\0A\0A\00"
@.str.3 = [11 x i8] c"a[%d]: %d\0A\00"
@str = [28 x i8] c"\0AConverting to integers...\0A\00"
@str.5 = [45 x i8] c"\0AThe converted array contains the following:\00"
@str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 9
store i8 0, i8* %3
store i8 97, i8* %2
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 48, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
store i8 120, i8* %5
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
store i8 53, i8* %6
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
store i8 48, i8* %7
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
store i8 88, i8* %8
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
store i8 70, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 7
store i8 48, i8* %10
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 8
store i8 66, i8* %11
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %2)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%14 = call i32 @htoi(i8* %2)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.5, i64 0, i64 0))
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %17)
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %20)
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %23)
%25 = load i8, i8* %6
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %26)
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %29)
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %32)
%34 = load i8, i8* %9
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %35)
%37 = load i8, i8* %10
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %38)
%40 = load i8, i8* %11
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 %41)
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 9
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 9, i32 %45)
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}