#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 */
const char *sal_uinttos(int value) {
  static char buf[64], buf2[64];
  char *tmp;
  int len = 0;
  tmp = buf;
  while (value) {
    *tmp = '0' + (value % 10);
    len++;
    tmp++;
    value /= 10;
  }
  tmp = buf2;
  while (len-- >= 0) {
    *tmp = buf[len];
    tmp++;
  }
  *tmp = 0;
  return (buf2);
}


x86 assembly (clang, -O0):
<sal_uinttos>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0x2f1b(%rip),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1161 <sal_uinttos+0x61>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1119 <sal_uinttos+0x19>
lea    0x2f08(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jl     11a5 <sal_uinttos+0xa5>
movslq -0x14(%rbp),%rcx
lea    0x2ea5(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116c <sal_uinttos+0x6c>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ebd(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sal_uinttos>:
xor    %eax,%eax
test   %edi,%edi
je     1144 <sal_uinttos+0x44>
lea    0x2f23(%rip),%r8
nopl   (%rax)
movslq %edi,%rdx
imul   $0x66666667,%rdx,%rdi
mov    %rdi,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdi
add    %esi,%edi
lea    (%rdi,%rdi,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%ecx
sub    %esi,%ecx
add    $0x30,%cl
mov    %cl,(%rax,%r8,1)
add    $0x9,%edx
add    $0x1,%rax
cmp    $0x13,%edx
jae    1110 <sal_uinttos+0x10>
lea    0x2f25(%rip),%r11
mov    %rax,%r9
mov    %r11,%rdx
cmp    $0x1f,%rax
jb     1224 <sal_uinttos+0x124>
lea    0x1(%rax),%r8
movabs $0x1ffffffe0,%rdi
and    %r8,%rdi
mov    %rax,%r9
sub    %rdi,%r9
lea    0x2ef7(%rip),%r10
lea    (%r10,%rdi,1),%rdx
lea    0x2eac(%rip),%rcx
lea    (%rax,%rcx,1),%rsi
add    $0xfffffffffffffff0,%rsi
xor    %ecx,%ecx
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqu -0x10(%rsi),%xmm1
movdqu (%rsi),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqa %xmm2,(%rcx,%r10,1)
movdqa %xmm1,0x10(%rcx,%r10,1)
add    $0x20,%rcx
add    $0xffffffffffffffe0,%rsi
cmp    %rcx,%rdi
jne    11a0 <sal_uinttos+0xa0>
cmp    %rdi,%r8
je     1255 <sal_uinttos+0x155>
add    %rax,%r11
lea    0x2e02(%rip),%rax
add    %r9,%rax
add    $0xffffffffffffffff,%rax
mov    %rdx,%rcx
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%edx
mov    %dl,(%rcx)
lea    0x1(%rcx),%rdx
add    $0xffffffffffffffff,%rax
cmp    %r11,%rcx
mov    %rdx,%rcx
jne    1240 <sal_uinttos+0x140>
movb   $0x0,(%rdx)
lea    0x2e11(%rip),%rax
ret

LLVM IR (-O0):
@sal_uinttos.buf = internal global [64 x i8] zeroinitializer
@sal_uinttos.buf2 = internal global [64 x i8] zeroinitializer
define i8* @sal_uinttos(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 0), i8** %3
br label %5
5: ; preds = %8, %1
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i32, i32* %2
%10 = srem i32 %9, 10
%11 = add nsw i32 48, %10
%12 = trunc i32 %11 to i8
%13 = load i8*, i8** %3
store i8 %12, i8* %13
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
%18 = load i32, i32* %2
%19 = sdiv i32 %18, 10
store i32 %19, i32* %2
br label %5
20: ; preds = %5
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0), i8** %3
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, -1
store i32 %23, i32* %4
%24 = icmp sge i32 %22, 0
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %3
store i8 %29, i8* %30
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %21
33: ; preds = %21
%34 = load i8*, i8** %3
store i8 0, i8* %34
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0)
}

LLVM IR (-O2):
@sal_uinttos.buf = internal unnamed_addr global [64 x i8] zeroinitializer
@sal_uinttos.buf2 = internal global [64 x i8] zeroinitializer
define i8* @sal_uinttos(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %5, label %38
3: ; preds = %38
%4 = zext i32 %45 to i64
br label %5
5: ; preds = %3, %1
%6 = phi i64 [ %4, %3 ], [ 0, %1 ]
%7 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %6
%8 = add nuw nsw i64 %6, 1
%9 = icmp ult i64 %6, 31
br i1 %9, label %35, label %10
10: ; preds = %5
%11 = and i64 %8, 8589934560
%12 = sub nsw i64 %6, %11
%13 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %11
br label %14
14: ; preds = %14, %10
%15 = phi i64 [ 0, %10 ], [ %31, %14 ]
%16 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %15
%17 = xor i64 %15, -1
%18 = add i64 %6, %17
%19 = getelementptr inbounds [64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -15
%21 = bitcast i8* %20 to <16 x i8>*
%22 = load <16 x i8>, <16 x i8>* %21
%23 = shufflevector <16 x i8> %22, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%24 = getelementptr inbounds i8, i8* %19, i64 -31
%25 = bitcast i8* %24 to <16 x i8>*
%26 = load <16 x i8>, <16 x i8>* %25
%27 = shufflevector <16 x i8> %26, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%28 = bitcast i8* %16 to <16 x i8>*
store <16 x i8> %23, <16 x i8>* %28
%29 = getelementptr i8, i8* %16, i64 16
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %27, <16 x i8>* %30
%31 = add nuw i64 %15, 32
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %14
33: ; preds = %14
%34 = icmp eq i64 %8, %11
br i1 %34, label %58, label %35
35: ; preds = %5, %33
%36 = phi i64 [ %6, %5 ], [ %12, %33 ]
%37 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0), %5 ], [ %13, %33 ]
br label %50
38: ; preds = %1, %38
%39 = phi i32 [ %45, %38 ], [ 0, %1 ]
%40 = phi i8* [ %46, %38 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 0), %1 ]
%41 = phi i32 [ %47, %38 ], [ %0, %1 ]
%42 = srem i32 %41, 10
%43 = trunc i32 %42 to i8
%44 = add nsw i8 %43, 48
store i8 %44, i8* %40
%45 = add nuw nsw i32 %39, 1
%46 = getelementptr inbounds i8, i8* %40, i64 1
%47 = sdiv i32 %41, 10
%48 = add i32 %41, 9
%49 = icmp ult i32 %48, 19
br i1 %49, label %3, label %38
50: ; preds = %35, %50
%51 = phi i64 [ %53, %50 ], [ %36, %35 ]
%52 = phi i8* [ %56, %50 ], [ %37, %35 ]
%53 = add nsw i64 %51, -1
%54 = getelementptr inbounds [64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 %53
%55 = load i8, i8* %54
store i8 %55, i8* %52
%56 = getelementptr inbounds i8, i8* %52, i64 1
%57 = icmp eq i8* %52, %7
br i1 %57, label %58, label %50
58: ; preds = %50, %33
%59 = phi i8* [ %13, %33 ], [ %56, %50 ]
store i8 0, i8* %59
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0)
}