#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 atoi_my(char *string) {
  int i = 0;
  int sum = 0;
  printf("\n----func_atoi_my---\n");
  while (i < 10 - 1 && *string != -1) {
    printf("In step %d sum = %8d; * string = \"%c\" in char, %d as digital and "
           "%p as pointer;\n",
           i, sum, *string, *string, &*string);
    sum = sum * 10 + (*string - '0');
    *string++;
    i++;
  };
  printf("After cycle sum = %d;\n", sum);
  printf("----end_of_func_atoi_my---\n");
  return sum;
}


x86 assembly (clang, -O0):
<atoi_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x9,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jge    1157 <atoi_my+0x47>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1167 <atoi_my+0x57>
jmp    11bb <atoi_my+0xab>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    -0x8(%rbp),%rax
movsbl (%rax),%r8d
mov    -0x8(%rbp),%r9
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0xa,-0x10(%rbp),%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <atoi_my+0x28>
mov    -0x10(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atoi_my>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xf3a(%rip),%rdi
call   1030 <puts@plt>
movsbl (%r14),%ecx
cmp    $0xffffffff,%ecx
je     131b <atoi_my+0x1fb>
lea    0xeb9(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %ecx,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%r14),%ebx
add    $0xffffffd0,%ebx
movsbl 0x1(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x1(%r14),%r9
lea    0xe88(%rip),%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x1(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x2(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x2(%r14),%r9
lea    0xe50(%rip),%rdi
mov    $0x2,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x2(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x3(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x3(%r14),%r9
lea    0xe18(%rip),%rdi
mov    $0x3,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x3(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x4(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x4(%r14),%r9
lea    0xde0(%rip),%rdi
mov    $0x4,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x4(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x5(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x5(%r14),%r9
lea    0xda8(%rip),%rdi
mov    $0x5,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x5(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x6(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x6(%r14),%r9
lea    0xd70(%rip),%rdi
mov    $0x6,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x6(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x7(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
lea    0x7(%r14),%r9
lea    0xd3c(%rip),%rdi
mov    $0x7,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl 0x7(%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
movsbl 0x8(%r14),%ecx
cmp    $0xffffffff,%ecx
je     131d <atoi_my+0x1fd>
add    $0x8,%r14
lea    0xd08(%rip),%rdi
mov    $0x8,%esi
mov    %ebx,%edx
mov    %ecx,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
movsbl (%r14),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
jmp    131d <atoi_my+0x1fd>
xor    %ebx,%ebx
lea    0xd2d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd49(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [81 x i8] c"In step %d sum = %8d; * string = \22%c\22 in char, %d as digital and %p as pointer;\0A\00"
@.str.2 = [23 x i8] c"After cycle sum = %d;\0A\00"
@str = [21 x i8] c"\0A----func_atoi_my---\00"
@str.4 = [27 x i8] c"----end_of_func_atoi_my---\00"
define i32 @atoi_my(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, -1
br i1 %4, label %99, label %5
5: ; preds = %1
%6 = sext i8 %3 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 %6, i32 %6, i8* %0)
%8 = load i8, i8* %0
%9 = sext i8 %8 to i32
%10 = add nsw i32 %9, -48
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, -1
br i1 %13, label %99, label %14
14: ; preds = %5
%15 = sext i8 %12 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %10, i32 %15, i32 %15, i8* %11)
%17 = mul nsw i32 %10, 10
%18 = load i8, i8* %11
%19 = sext i8 %18 to i32
%20 = add nsw i32 %17, -48
%21 = add nsw i32 %20, %19
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, -1
br i1 %24, label %99, label %25
25: ; preds = %14
%26 = sext i8 %23 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %21, i32 %26, i32 %26, i8* %22)
%28 = mul nsw i32 %21, 10
%29 = load i8, i8* %22
%30 = sext i8 %29 to i32
%31 = add nsw i32 %28, -48
%32 = add nsw i32 %31, %30
%33 = getelementptr inbounds i8, i8* %0, i64 3
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, -1
br i1 %35, label %99, label %36
36: ; preds = %25
%37 = sext i8 %34 to i32
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %32, i32 %37, i32 %37, i8* %33)
%39 = mul nsw i32 %32, 10
%40 = load i8, i8* %33
%41 = sext i8 %40 to i32
%42 = add nsw i32 %39, -48
%43 = add nsw i32 %42, %41
%44 = getelementptr inbounds i8, i8* %0, i64 4
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, -1
br i1 %46, label %99, label %47
47: ; preds = %36
%48 = sext i8 %45 to i32
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %43, i32 %48, i32 %48, i8* %44)
%50 = mul nsw i32 %43, 10
%51 = load i8, i8* %44
%52 = sext i8 %51 to i32
%53 = add nsw i32 %50, -48
%54 = add nsw i32 %53, %52
%55 = getelementptr inbounds i8, i8* %0, i64 5
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, -1
br i1 %57, label %99, label %58
58: ; preds = %47
%59 = sext i8 %56 to i32
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %54, i32 %59, i32 %59, i8* %55)
%61 = mul nsw i32 %54, 10
%62 = load i8, i8* %55
%63 = sext i8 %62 to i32
%64 = add nsw i32 %61, -48
%65 = add nsw i32 %64, %63
%66 = getelementptr inbounds i8, i8* %0, i64 6
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, -1
br i1 %68, label %99, label %69
69: ; preds = %58
%70 = sext i8 %67 to i32
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %65, i32 %70, i32 %70, i8* %66)
%72 = mul nsw i32 %65, 10
%73 = load i8, i8* %66
%74 = sext i8 %73 to i32
%75 = add nsw i32 %72, -48
%76 = add nsw i32 %75, %74
%77 = getelementptr inbounds i8, i8* %0, i64 7
%78 = load i8, i8* %77
%79 = icmp eq i8 %78, -1
br i1 %79, label %99, label %80
80: ; preds = %69
%81 = sext i8 %78 to i32
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %76, i32 %81, i32 %81, i8* %77)
%83 = mul nsw i32 %76, 10
%84 = load i8, i8* %77
%85 = sext i8 %84 to i32
%86 = add nsw i32 %83, -48
%87 = add nsw i32 %86, %85
%88 = getelementptr inbounds i8, i8* %0, i64 8
%89 = load i8, i8* %88
%90 = icmp eq i8 %89, -1
br i1 %90, label %99, label %91
91: ; preds = %80
%92 = sext i8 %89 to i32
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %87, i32 %92, i32 %92, i8* %88)
%94 = mul nsw i32 %87, 10
%95 = load i8, i8* %88
%96 = sext i8 %95 to i32
%97 = add i32 %94, -48
%98 = add i32 %97, %96
br label %99
99: ; preds = %91, %80, %69, %58, %47, %36, %25, %14, %5, %1
%100 = phi i32 [ 0, %1 ], [ %10, %5 ], [ %21, %14 ], [ %32, %25 ], [ %43, %36 ], [ %54, %47 ], [ %65, %58 ], [ %76, %69 ], [ %87, %80 ], [ %98, %91 ]
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %100)
%102 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
ret i32 %100
}