#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 atoi_rec(char *, int /*<<< orphan*/);
int myatioi(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char const *argv[]) {
  int diff = 'A' - 'a';
  printf("%d\nIterative\n", diff);
  char str[] = "-1897k98";
  int intval = myatioi(str);
  printf("%d\nRecursive\n", intval);
  char str1[] = "123";
  int intval1 = atoi_rec(str1, strlen(str1));
  printf("%d\n", intval1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffe0,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    0xe9b(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xe99(%rip),%al
mov    %al,-0x15(%rbp)
lea    -0x1d(%rbp),%rdi
call   1060 <myatioi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
mov    0xe84(%rip),%eax
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1050 <atoi_rec@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
mov    $0xffffffe0,%esi
call   1040 <printf@plt>
movabs $0x38396b373938312d,%rax
6b 39 38
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rdi
call   1060 <myatioi@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movl   $0x333231,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <atoi_rec@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%d\0AIterative\0A\00"
@__const.main.str = [9 x i8] c"-1897k98\00"
@.str.1 = [14 x i8] c"%d\0ARecursive\0A\00"
@__const.main.str1 = [4 x i8] c"123\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [9 x i8]
%8 = alloca i32
%9 = alloca [4 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -32, i32* %6
%11 = load i32, i32* %6
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = bitcast [9 x i8]* %7 to i8*
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%15 = call i32 @myatioi(i8* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = bitcast [4 x i8]* %9 to i8*
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @atoi_rec(i8* %19, i32 %21)
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"%d\0AIterative\0A\00"
@__const.main.str = [9 x i8] c"-1897k98\00"
@.str.1 = [14 x i8] c"%d\0ARecursive\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x i8]
%4 = alloca i32
%5 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 -32)
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = call i32 @myatioi(i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = bitcast i32* %4 to i8*
store i32 3355185, i32* %4
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @atoi_rec(i8* %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}