#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*/ my_atoi(int, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(void) {
  int test_ints[12] = {0,       1,  2,       33, 45,  654,
                       9023845, -1, -930824, -8, -77, -87};
  char *expected[12] = {"0",       "1",  "2",       "33", "45",  "654",
                        "9023845", "-1", "-930824", "-8", "-77", "-87"};
  char test_status[12 + 1];
  printf("\n");
  for (int i = 0; i < 12; i++) {
    test_status[i] = '.';
    char buf[100];
    my_atoi(test_ints[i], buf);
    if (strcmp(buf, expected[i])) {
      test_status[i] = '!';
      printf("expected: %s , actual %s\n", expected[i], buf);
      printf("\n");
    }
  }
  printf("%s\n", test_status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0x2c4b(%rip),%rsi
mov    $0x60,%edx
call   1060 <memcpy@plt>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0xc,-0xb4(%rbp)
jge    1249 <main+0x109>
movslq -0xb4(%rbp),%rax
movb   $0x2e,-0xad(%rbp,%rax,1)
2e
movslq -0xb4(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edi
lea    -0x120(%rbp),%rsi
call   1030 <my_atoi@plt>
lea    -0x120(%rbp),%rdi
movslq -0xb4(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rsi
ff
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1230 <main+0xf0>
movslq -0xb4(%rbp),%rax
movb   $0x21,-0xad(%rbp,%rax,1)
21
movslq -0xb4(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%rsi
ff
lea    -0x120(%rbp),%rdx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1235 <main+0xf5>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1197 <main+0x57>
lea    -0xad(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x2c51(%rip),%r13
lea    0x3(%rsp),%rbx
lea    0xe85(%rip),%rbp
lea    0x10(%rsp),%r15
xor    %r14d,%r14d
jmp    11a2 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x8,%r13
add    $0x4,%r14
add    $0x1,%rbx
cmp    $0x30,%r14
je     11e8 <main+0x98>
movb   $0x2e,(%rbx)
mov    (%r14,%rbp,1),%edi
mov    %r15,%rsi
call   1030 <my_atoi@plt>
mov    0x0(%r13),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1190 <main+0x40>
movb   $0x21,(%rbx)
lea    0xe8a(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1190 <main+0x40>
lea    0x3(%rsp),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.test_ints = [12 x i32] [i32 0, i32 1, i32 2, i32 33, i32 45, i32 654, i32 9023845, i32 -1, i32 -930824, i32 -8, i32 -77, i32 -87]
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [3 x i8] c"33\00"
@.str.4 = [3 x i8] c"45\00"
@.str.5 = [4 x i8] c"654\00"
@.str.6 = [8 x i8] c"9023845\00"
@.str.7 = [3 x i8] c"-1\00"
@.str.8 = [8 x i8] c"-930824\00"
@.str.9 = [3 x i8] c"-8\00"
@.str.10 = [4 x i8] c"-77\00"
@.str.11 = [4 x i8] c"-87\00"
@__const.main.expected = [12 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [2 x i8] c"\0A\00"
@.str.13 = [26 x i8] c"expected: %s , actual %s\0A\00"
@.str.14 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca [12 x i8*]
%4 = alloca [13 x i8]
%5 = alloca i32
%6 = alloca [100 x i8]
store i32 0, i32* %1
%7 = bitcast [12 x i32]* %2 to i8*
%8 = bitcast [12 x i8*]* %3 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %42, %0
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 12
br i1 %12, label %13, label %45
13: ; preds = %10
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 %15
store i8 46, i8* %16
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = call i32 @my_atoi(i32 %20, i8* %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [12 x i8*], [12 x i8*]* %3, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %23, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %13
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 %32
store i8 33, i8* %33
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [12 x i8*], [12 x i8*]* %3, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* %37, i8* %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %41
41: ; preds = %30, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %10
45: ; preds = %10
%46 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %46)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test_ints = [12 x i32] [i32 0, i32 1, i32 2, i32 33, i32 45, i32 654, i32 9023845, i32 -1, i32 -930824, i32 -8, i32 -77, i32 -87]
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [3 x i8] c"33\00"
@.str.4 = [3 x i8] c"45\00"
@.str.5 = [4 x i8] c"654\00"
@.str.6 = [8 x i8] c"9023845\00"
@.str.7 = [3 x i8] c"-1\00"
@.str.8 = [8 x i8] c"-930824\00"
@.str.9 = [3 x i8] c"-8\00"
@.str.10 = [4 x i8] c"-77\00"
@.str.11 = [4 x i8] c"-87\00"
@__const.main.expected = [12 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)]
@.str.13 = [26 x i8] c"expected: %s , actual %s\0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @putchar(i32 10)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %8
6: ; preds = %21
%7 = call i32 @puts(i8* %3)
ret i32 0
8: ; preds = %0, %21
%9 = phi i64 [ 0, %0 ], [ %22, %21 ]
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %9
store i8 46, i8* %10
%11 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.main.test_ints, i64 0, i64 %9
%12 = load i32, i32* %11
%13 = call i32 @my_atoi(i32 %12, i8* %5)
%14 = getelementptr inbounds [12 x i8*], [12 x i8*]* @__const.main.expected, i64 0, i64 %9
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %5, i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %8
store i8 33, i8* %10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i8* %15, i8* %5)
%20 = call i32 @putchar(i32 10)
br label %21
21: ; preds = %18, %8
%22 = add nuw nsw i64 %9, 1
%23 = icmp eq i64 %22, 12
br i1 %23, label %6, label %8
}