#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*/ printf(char *, int, ...);
int atoi_my(char *line) {
  int i = 0;
  while (*line != '\0' && *line != '\n') {
    if (*line == '-') {
      ;
    } else {
      printf("* line = '%c' and %d;i = %d;\n", *line, *line, i);
      i = *line - '0' + i * 10;
      printf("i = %d;\n", i);
    }
    *line++;
  }
  return i;
}


x86 assembly (clang, -O0):
<atoi_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     1148 <atoi_my+0x38>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1158 <atoi_my+0x48>
jmp    11c1 <atoi_my+0xb1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    116d <atoi_my+0x5d>
jmp    11b0 <atoi_my+0xa0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    -0xc(%rbp),%ecx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,-0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <atoi_my+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atoi_my>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xede(%rip),%r14
lea    0xeec(%rip),%r15
xor    %r12d,%r12d
jmp    1134 <atoi_my+0x24>
xchg   %ax,%ax
add    $0x1,%rbx
movsbl (%rbx),%edx
cmp    $0x2d,%edx
je     1130 <atoi_my+0x20>
test   %dl,%dl
je     1172 <atoi_my+0x62>
cmp    $0xa,%dl
je     1172 <atoi_my+0x62>
mov    %r14,%rdi
mov    %edx,%esi
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
movsbl (%rbx),%eax
lea    (%r12,%r12,4),%ecx
lea    (%rax,%rcx,2),%r12d
add    $0xffffffd0,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1130 <atoi_my+0x20>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"* line = '%c' and %d;i = %d;\0A\00"
@.str.1 = [9 x i8] c"i = %d;\0A\00"
define i32 @atoi_my(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %40, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br label %14
14: ; preds = %9, %4
%15 = phi i1 [ false, %4 ], [ %13, %9 ]
br i1 %15, label %16, label %44
16: ; preds = %14
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %22
21: ; preds = %16
br label %40
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i32, i32* %3
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28, i32 %29)
%31 = load i8*, i8** %2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = load i32, i32* %3
%36 = mul nsw i32 %35, 10
%37 = add nsw i32 %34, %36
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %22, %21
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %2
%43 = load i8, i8* %41
br label %4
44: ; preds = %14
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [30 x i8] c"* line = '%c' and %d;i = %d;\0A\00"
@.str.1 = [9 x i8] c"i = %d;\0A\00"
define i32 @atoi_my(i8* nocapture %0) {
br label %2
2: ; preds = %15, %1
%3 = phi i8* [ %0, %1 ], [ %17, %15 ]
%4 = phi i32 [ 0, %1 ], [ %16, %15 ]
%5 = load i8, i8* %3
switch i8 %5, label %6 [
i8 0, label %18
i8 10, label %18
i8 45, label %15
]
6: ; preds = %2
%7 = sext i8 %5 to i32
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %7, i32 %4)
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = mul nsw i32 %4, 10
%12 = add i32 %11, -48
%13 = add i32 %12, %10
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %2, %6
%16 = phi i32 [ %13, %6 ], [ %4, %2 ]
%17 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
18: ; preds = %2, %2
ret i32 %4
}