#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int my_atoi_ltr(char *);
int my_atoi_rtl(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int n;
  if (argc < 2 || !argv[1]) {
    printf("%s <number>\n", argv[0]);
    printf("Convert an number represented in ASCII to an integer\n");
    printf("\tnumber: A number to convert\n");
    exit(EXIT_FAILURE);
  }
  n = my_atoi_rtl(argv[1]);
  printf("[RTL] The number was: %d (hex: 0x%x)\n", n, n);
  n = my_atoi_ltr(argv[1]);
  printf("[LTR] The number was: %d (hex: 0x%x)\n", n, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     116f <main+0x2f>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11ae <main+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <my_atoi_rtl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <my_atoi_ltr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe98(%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
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1198 <main+0x48>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1198 <main+0x48>
call   1050 <my_atoi_rtl@plt>
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
call   1060 <my_atoi_ltr@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%rsi
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%s <number>\0A\00"
@.str.1 = [54 x i8] c"Convert an number represented in ASCII to an integer\0A\00"
@.str.2 = [30 x i8] c"\09number: A number to convert\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [38 x i8] c"[RTL] The number was: %d (hex: 0x%x)\0A\00"
@.str.4 = [38 x i8] c"[LTR] The number was: %d (hex: 0x%x)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %23, label %14
14: ; preds = %9, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @my_atoi_rtl(i8* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @my_atoi_ltr(i8* %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i32, i32* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s <number>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [38 x i8] c"[RTL] The number was: %d (hex: 0x%x)\0A\00"
@.str.4 = [38 x i8] c"[LTR] The number was: %d (hex: 0x%x)\0A\00"
@str = [53 x i8] c"Convert an number represented in ASCII to an integer\00"
@str.5 = [29 x i8] c"\09number: A number to convert\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %4, %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %4
%16 = tail call i32 @my_atoi_rtl(i8* %6)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %16)
%18 = load i8*, i8** %5
%19 = tail call i32 @my_atoi_ltr(i8* %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %19)
ret i32 0
}