#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(char *);
int /*<<< orphan*/ exit(int);
int main() {
  if (atoi("a") != 0) {
    exit(1);
  }
  if (atoi("") != 0) {
    exit(2);
  }
  if (atoi("0") != 0) {
    exit(3);
  }
  if (atoi("1") != 1) {
    exit(4);
  }
  if (atoi("123456") != 123456) {
    exit(5);
  }
  if (atoi("-123456") != -123456) {
    exit(6);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0x0,%eax
je     1143 <main+0x23>
mov    $0x1,%edi
call   1040 <exit@plt>
lea    0xeb9(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0x0,%eax
je     1162 <main+0x42>
mov    $0x2,%edi
call   1040 <exit@plt>
lea    0xe99(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0x0,%eax
je     1181 <main+0x61>
mov    $0x3,%edi
call   1040 <exit@plt>
lea    0xe7c(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0x1,%eax
je     11a0 <main+0x80>
mov    $0x4,%edi
call   1040 <exit@plt>
lea    0xe60(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0x1e240,%eax
je     11c1 <main+0xa1>
mov    $0x5,%edi
call   1040 <exit@plt>
lea    0xe3e(%rip),%rdi
call   1030 <atoi@plt>
cmp    $0xfffe1dc0,%eax
je     11e2 <main+0xc2>
mov    $0x6,%edi
call   1040 <exit@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <atoi@plt>
test   %eax,%eax
jne    1135 <main+0x15>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [7 x i8] c"123456\00"
@.str.5 = [8 x i8] c"-123456\00"
define i32 @main() {
%1 = call i32 @atoi(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = icmp ne i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @exit(i32 1)
unreachable
5: ; preds = %0
%6 = call i32 @atoi(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %5
%11 = call i32 @atoi(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @exit(i32 3)
unreachable
15: ; preds = %10
%16 = call i32 @atoi(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @exit(i32 4)
unreachable
20: ; preds = %15
%21 = call i32 @atoi(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp ne i32 %21, 123456
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @exit(i32 5)
unreachable
25: ; preds = %20
%26 = call i32 @atoi(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp ne i32 %26, -123456
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @exit(i32 6)
unreachable
30: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
define i32 @main() {
%1 = tail call i32 @atoi(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @exit(i32 1)
unreachable
5: ; preds = %0
ret i32 0
}