#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*/ itoa(int, char *);
scalar_t__ strcmp(char *, char *);
int test_itoa() {
  char output[10];
  int result = 1;
  itoa(0, output);
  result = result && strcmp("0", output);
  itoa(1234, output);
  result = result && strcmp("1234", output);
  itoa(-1234, output);
  result = result && strcmp("-1234", output);
  return result;
}


x86 assembly (clang, -O0):
<test_itoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x10(%rbp)
lea    -0xa(%rbp),%rsi
xor    %edi,%edi
call   1040 <itoa@plt>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1163 <test_itoa+0x43>
lea    -0xa(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
lea    -0xa(%rbp),%rsi
mov    $0x4d2,%edi
call   1040 <itoa@plt>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
je     11a5 <test_itoa+0x85>
lea    -0xa(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
lea    -0xa(%rbp),%rsi
mov    $0xfffffb2e,%edi
call   1040 <itoa@plt>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x13(%rbp)
je     11e7 <test_itoa+0xc7>
lea    -0xa(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_itoa>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
lea    0x6(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    %rax,%rbp
mov    $0x4d2,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
test   %rbp,%rbp
je     11a4 <test_itoa+0x84>
lea    0xe9e(%rip),%rdi
lea    0x6(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    %rax,%rbp
mov    $0xfffffb2e,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
test   %rbp,%rbp
je     11b3 <test_itoa+0x93>
lea    0xe74(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1030 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
jmp    11b3 <test_itoa+0x93>
lea    0x6(%rsp),%rsi
mov    $0xfffffb2e,%edi
call   1040 <itoa@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [5 x i8] c"1234\00"
@.str.2 = [6 x i8] c"-1234\00"
define i32 @test_itoa() {
%1 = alloca [10 x i8]
%2 = alloca i32
store i32 1, i32* %2
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = call i32 @itoa(i32 0, i8* %3)
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp ne i64 %9, 0
br label %11
11: ; preds = %7, %0
%12 = phi i1 [ false, %0 ], [ %10, %7 ]
%13 = zext i1 %12 to i32
store i32 %13, i32* %2
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%15 = call i32 @itoa(i32 1234, i8* %14)
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%20 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %18, %11
%23 = phi i1 [ false, %11 ], [ %21, %18 ]
%24 = zext i1 %23 to i32
store i32 %24, i32* %2
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%26 = call i32 @itoa(i32 -1234, i8* %25)
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%31 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = icmp ne i64 %31, 0
br label %33
33: ; preds = %29, %22
%34 = phi i1 [ false, %22 ], [ %32, %29 ]
%35 = zext i1 %34 to i32
store i32 %35, i32* %2
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [5 x i8] c"1234\00"
@.str.2 = [6 x i8] c"-1234\00"
define i32 @test_itoa() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @itoa(i32 0, i8* %2)
%4 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i64 %4, 0
%6 = call i32 @itoa(i32 1234, i8* %2)
br i1 %5, label %15, label %7
7: ; preds = %0
%8 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = icmp eq i64 %8, 0
%10 = call i32 @itoa(i32 -1234, i8* %2)
br i1 %9, label %17, label %11
11: ; preds = %7
%12 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %17
15: ; preds = %0
%16 = call i32 @itoa(i32 -1234, i8* %2)
br label %17
17: ; preds = %15, %11, %7
%18 = phi i32 [ 0, %7 ], [ %14, %11 ], [ 0, %15 ]
ret i32 %18
}