#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*/ memset(char *, int /*<<< orphan*/, int);
unsigned char *itoa(unsigned int in) {
  static char toreturn[32], *ptr;
  ptr = toreturn + 32 - 1;
  memset(toreturn, 0, 32);
  do {
    ptr--;
    *ptr = (in % 10) + '0';
    in /= 10;
  } while (in);
  return (ptr);
}


x86 assembly (clang, -O0):
<itoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rax
add    $0x1f,%rax
mov    %rax,0x2f33(%rip)
lea    0x2f0c(%rip),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0x2f19(%rip),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x2f0e(%rip)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    0x2ef6(%rip),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1140 <itoa+0x30>
mov    0x2ed4(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itoa>:
push   %rbx
mov    %edi,%ebx
lea    0x2f45(%rip),%rax
mov    %rax,0x2f3f(%rip)
lea    0x2f18(%rip),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0x2f25(%rip),%rax
mov    $0xcccccccd,%ecx
mov    %ebx,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %ebx,%edi
sub    %esi,%edi
or     $0x30,%dil
mov    %dil,-0x1(%rax)
add    $0xffffffffffffffff,%rax
cmp    $0x9,%ebx
mov    %edx,%ebx
ja     1140 <itoa+0x30>
mov    %rax,0x2ef2(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@itoa.toreturn = internal global [32 x i8] zeroinitializer
@itoa.ptr = internal global i8* null
define i8* @itoa(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @itoa.toreturn, i64 1, i64 -1), i8** @itoa.ptr
%3 = call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @itoa.toreturn, i64 0, i64 0), i32 0, i32 32)
br label %4
4: ; preds = %14, %1
%5 = load i8*, i8** @itoa.ptr
%6 = getelementptr inbounds i8, i8* %5, i32 -1
store i8* %6, i8** @itoa.ptr
%7 = load i32, i32* %2
%8 = urem i32 %7, 10
%9 = add i32 %8, 48
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** @itoa.ptr
store i8 %10, i8* %11
%12 = load i32, i32* %2
%13 = udiv i32 %12, 10
store i32 %13, i32* %2
br label %14
14: ; preds = %4
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = load i8*, i8** @itoa.ptr
ret i8* %18
}

LLVM IR (-O2):
@itoa.toreturn = internal global [32 x i8] zeroinitializer
@itoa.ptr = internal unnamed_addr global i8* null
define i8* @itoa(i32 %0) {
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @itoa.toreturn, i64 0, i64 31), i8** @itoa.ptr
%2 = tail call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @itoa.toreturn, i64 0, i64 0), i32 0, i32 32)
%3 = load i8*, i8** @itoa.ptr
br label %4
4: ; preds = %4, %1
%5 = phi i8* [ %3, %1 ], [ %7, %4 ]
%6 = phi i32 [ %0, %1 ], [ %11, %4 ]
%7 = getelementptr inbounds i8, i8* %5, i64 -1
%8 = urem i32 %6, 10
%9 = trunc i32 %8 to i8
%10 = or i8 %9, 48
store i8 %10, i8* %7
%11 = udiv i32 %6, 10
%12 = icmp ult i32 %6, 10
br i1 %12, label %13, label %4
13: ; preds = %4
store i8* %7, i8** @itoa.ptr
ret i8* %7
}