#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 test_atoi() {
  return 0 == atoi(0) && 0 == atoi("") && 0 == atoi("test") && 0 == atoi("0") &&
         12345 == atoi("12345") && 12345 == atoi("+12345") &&
         -12345 == atoi("-12345");
}


x86 assembly (clang, -O0):
<test_atoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xecd(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xeaa(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xe92(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xe78(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x3039,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xe57(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x3039,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11e4 <test_atoi+0xd4>
lea    0xe3e(%rip),%rdi
call   1030 <atoi@plt>
mov    %eax,%ecx
mov    $0xffffcfc7,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_atoi>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <atoi@plt>
test   %eax,%eax
jne    1131 <test_atoi+0x21>
lea    0xedb(%rip),%rdi
call   1030 <atoi@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [6 x i8] c"12345\00"
@.str.4 = [7 x i8] c"+12345\00"
@.str.5 = [7 x i8] c"-12345\00"
define i32 @test_atoi() {
%1 = call i32 @atoi(i8* null)
%2 = icmp eq i32 0, %1
br i1 %2, label %3, label %21
3: ; preds = %0
%4 = call i32 @atoi(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 0, %4
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = call i32 @atoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 0, %7
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = call i32 @atoi(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 0, %10
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = call i32 @atoi(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 12345, %13
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i32 @atoi(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32 12345, %16
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 @atoi(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i32 -12345, %19
br label %21
21: ; preds = %18, %15, %12, %9, %6, %3, %0
%22 = phi i1 [ false, %15 ], [ false, %12 ], [ false, %9 ], [ false, %6 ], [ false, %3 ], [ false, %0 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"test\00"
define i32 @test_atoi() {
%1 = tail call i32 @atoi(i8* null)
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 @atoi(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
br label %7
7: ; preds = %3, %0
%8 = phi i32 [ 0, %0 ], [ %6, %3 ]
ret i32 %8
}