const char *sal_uinttos(int value) {
  static char buf[64], buf2[64];
  char *tmp;
  int len = 0;
  tmp = buf;
  do {
    *tmp = '0' + (value % 10);
    len++;
    tmp++;
    value /= 10;
  } while (value);
  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)
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)
cmpl   $0x0,-0x4(%rbp)
jne    1119 <sal_uinttos+0x19>
lea    0x2f0d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jl     11a0 <sal_uinttos+0xa0>
movslq -0x14(%rbp),%rcx
lea    0x2eaa(%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    1167 <sal_uinttos+0x67>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ec2(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sal_uinttos>:
push   %rbx
mov    $0x1,%ecx
lea    0x2f23(%rip),%rbx
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,%eax
sub    %esi,%eax
add    $0x30,%al
mov    %al,-0x1(%rcx,%rbx,1)
add    $0x9,%edx
add    $0x1,%rcx
cmp    $0x12,%edx
ja     1110 <sal_uinttos+0x10>
lea    -0x2(%rcx),%r10
lea    0x2f22(%rip),%r8
mov    %r8,%rdx
cmp    $0x1e,%r10d
jb     121b <sal_uinttos+0x11b>
mov    %ecx,%r9d
and    $0xffffffe0,%r9d
mov    %rcx,%r10
sub    %r9,%r10
add    $0xfffffffffffffffe,%r10
lea    0x2efd(%rip),%rdx
add    %r9,%rdx
mov    %r9,%r11
neg    %r11
lea    0x2efd(%rip),%rdi
xor    %esi,%esi
pxor   %xmm0,%xmm0
nopl   0x0(%rax)
lea    (%rbx,%rsi,1),%rax
movdqu -0x21(%rcx,%rax,1),%xmm1
movdqu -0x11(%rcx,%rax,1),%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,-0x10(%rdi)
movdqa %xmm1,(%rdi)
add    $0x20,%rdi
add    $0xffffffffffffffe0,%rsi
cmp    %rsi,%r11
jne    1190 <sal_uinttos+0x90>
cmp    %r9,%rcx
je     1245 <sal_uinttos+0x145>
add    %r8,%rcx
add    $0xffffffffffffffff,%rcx
add    %r10,%rbx
mov    %rdx,%rsi
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
mov    %al,(%rsi)
lea    0x1(%rsi),%rdx
add    $0xffffffffffffffff,%rbx
cmp    %rsi,%rcx
mov    %rdx,%rsi
jne    1230 <sal_uinttos+0x130>
movb   $0x0,(%rdx)
lea    0x2e21(%rip),%rax
pop    %rbx
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 = %17, %1
%6 = load i32, i32* %2
%7 = srem i32 %6, 10
%8 = add nsw i32 48, %7
%9 = trunc i32 %8 to i8
%10 = load i8*, i8** %3
store i8 %9, i8* %10
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 10
store i32 %16, i32* %2
br label %17
17: ; preds = %5
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %5, label %20
20: ; preds = %17
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) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ %0, %1 ], [ %11, %2 ]
%4 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 0), %1 ], [ %10, %2 ]
%5 = phi i32 [ 0, %1 ], [ %9, %2 ]
%6 = srem i32 %3, 10
%7 = trunc i32 %6 to i8
%8 = add nsw i8 %7, 48
store i8 %8, i8* %4
%9 = add nuw nsw i32 %5, 1
%10 = getelementptr inbounds i8, i8* %4, i64 1
%11 = sdiv i32 %3, 10
%12 = add i32 %3, 9
%13 = icmp ult i32 %12, 19
br i1 %13, label %14, label %2
14: ; preds = %2
%15 = zext i32 %5 to i64
%16 = add nuw nsw i64 %15, 1
%17 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %16
%18 = add nuw nsw i64 %15, 2
%19 = icmp ult i32 %5, 30
br i1 %19, label %44, label %20
20: ; preds = %14
%21 = and i64 %18, 4294967264
%22 = sub nsw i64 %15, %21
%23 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %21
br label %24
24: ; preds = %24, %20
%25 = phi i64 [ 0, %20 ], [ %40, %24 ]
%26 = sub i64 %15, %25
%27 = getelementptr [64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 %25
%28 = getelementptr inbounds [64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 %26
%29 = getelementptr inbounds i8, i8* %28, i64 -15
%30 = bitcast i8* %29 to <16 x i8>*
%31 = load <16 x i8>, <16 x i8>* %30
%32 = shufflevector <16 x i8> %31, <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>
%33 = getelementptr inbounds i8, i8* %28, i64 -31
%34 = bitcast i8* %33 to <16 x i8>*
%35 = load <16 x i8>, <16 x i8>* %34
%36 = shufflevector <16 x i8> %35, <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>
%37 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %37
%38 = getelementptr i8, i8* %27, i64 16
%39 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %39
%40 = add nuw i64 %25, 32
%41 = icmp eq i64 %40, %21
br i1 %41, label %42, label %24
42: ; preds = %24
%43 = icmp eq i64 %18, %21
br i1 %43, label %55, label %44
44: ; preds = %14, %42
%45 = phi i64 [ %15, %14 ], [ %22, %42 ]
%46 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0), %14 ], [ %23, %42 ]
br label %47
47: ; preds = %44, %47
%48 = phi i64 [ %53, %47 ], [ %45, %44 ]
%49 = phi i8* [ %52, %47 ], [ %46, %44 ]
%50 = getelementptr inbounds [64 x i8], [64 x i8]* @sal_uinttos.buf, i64 0, i64 %48
%51 = load i8, i8* %50
store i8 %51, i8* %49
%52 = getelementptr inbounds i8, i8* %49, i64 1
%53 = add nsw i64 %48, -1
%54 = icmp eq i8* %49, %17
br i1 %54, label %55, label %47
55: ; preds = %47, %42
%56 = phi i8* [ %23, %42 ], [ %52, %47 ]
store i8 0, i8* %56
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sal_uinttos.buf2, i64 0, i64 0)
}