#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 */
typedef int /*<<< orphan*/ mem;

/* Variables and functions */
int /*<<< orphan*/ fputs(int, char *);
void fput_unsigned(int fd, unsigned n) {
  char mem[12], *stack = mem + (sizeof(mem) / sizeof(mem[0])) - 1;
  *stack = 0;
  do {
    *--stack = (n % 10) + '0';
  } while (n /= 10);
  fputs(fd, stack);
}


x86 assembly (clang, -O0):
<fput_unsigned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x14(%rbp),%rax
add    $0xc,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1135 <fput_unsigned+0x25>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fput_unsigned>:
sub    $0x18,%rsp
mov    %esi,%r9d
lea    0x17(%rsp),%rsi
movb   $0x0,0x17(%rsp)
mov    $0xcccccccd,%r8d
nopw   0x0(%rax,%rax,1)
mov    %r9d,%edx
imul   %r8,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %r9d,%eax
sub    %ecx,%eax
or     $0x30,%al
mov    %al,-0x1(%rsi)
add    $0xffffffffffffffff,%rsi
cmp    $0x9,%r9d
mov    %edx,%r9d
ja     1130 <fput_unsigned+0x20>
call   1030 <fputs@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @fput_unsigned(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [12 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds i8, i8* %7, i64 12
%9 = getelementptr inbounds i8, i8* %8, i64 -1
store i8* %9, i8** %6
%10 = load i8*, i8** %6
store i8 0, i8* %10
br label %11
11: ; preds = %18, %2
%12 = load i32, i32* %4
%13 = urem i32 %12, 10
%14 = add i32 %13, 48
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 -1
store i8* %17, i8** %6
store i8 %15, i8* %17
br label %18
18: ; preds = %11
%19 = load i32, i32* %4
%20 = udiv i32 %19, 10
store i32 %20, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %11, label %22
22: ; preds = %18
%23 = load i32, i32* %3
%24 = load i8*, i8** %6
%25 = call i32 @fputs(i32 %23, i8* %24)
ret void
}

LLVM IR (-O2):
define void @fput_unsigned(i32 %0, i32 %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 11
store i8 0, i8* %5
br label %6
6: ; preds = %6, %2
%7 = phi i32 [ %1, %2 ], [ %13, %6 ]
%8 = phi i8* [ %5, %2 ], [ %12, %6 ]
%9 = urem i32 %7, 10
%10 = trunc i32 %9 to i8
%11 = or i8 %10, 48
%12 = getelementptr inbounds i8, i8* %8, i64 -1
store i8 %11, i8* %12
%13 = udiv i32 %7, 10
%14 = icmp ult i32 %7, 10
br i1 %14, label %15, label %6
15: ; preds = %6
%16 = call i32 @fputs(i32 %0, i8* %12)
ret void
}