#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*/ com_putc(unsigned int);
int /*<<< orphan*/ com_puts(char *);
void com_putu(unsigned u) {
  char buf[1024];
  if (u < 10)
    com_putc(('0' + u));
  else {
    char *bp;
    bp = buf + 1024 - 1;
    *bp-- = '\0';
    while (u && bp >= buf) {
      *bp-- = ('0' + u % 10);
      u /= 10;
    }
    com_puts(++bp);
  }
}


x86 assembly (clang, -O0):
<com_putu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jae    1148 <com_putu+0x28>
mov    -0x4(%rbp),%edi
add    $0x30,%edi
call   1030 <com_putc@plt>
jmp    120a <com_putu+0xea>
lea    -0x410(%rbp),%rax
add    $0x400,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x418(%rbp)
movb   $0x0,(%rax)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x419(%rbp)
je     11a4 <com_putu+0x84>
mov    -0x418(%rbp),%rax
lea    -0x410(%rbp),%rcx
cmp    %rcx,%rax
setae  %al
mov    %al,-0x419(%rbp)
mov    -0x419(%rbp),%al
test   $0x1,%al
jne    11b7 <com_putu+0x97>
jmp    11f3 <com_putu+0xd3>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x418(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x418(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x4(%rbp)
jmp    1178 <com_putu+0x58>
mov    -0x418(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x418(%rbp)
call   1040 <com_puts@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<com_putu>:
sub    $0x408,%rsp
cmp    $0x9,%edi
ja     113b <com_putu+0x1b>
add    $0x30,%edi
add    $0x408,%rsp
jmp    1030 <com_putc@plt>
lea    0x3ff(%rsp),%rcx
movb   $0x0,0x3ff(%rsp)
mov    $0xcccccccd,%r8d
mov    %rsp,%r9
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edi,%eax
lea    -0x1(%rcx),%r10
mov    %edi,%edi
imul   %r8,%rdi
shr    $0x23,%rdi
lea    (%rdi,%rdi,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %eax,%edx
sub    %esi,%edx
or     $0x30,%dl
mov    %dl,-0x1(%rcx)
cmp    $0xa,%eax
jb     1191 <com_putu+0x71>
add    $0xfffffffffffffffe,%rcx
cmp    %r9,%rcx
mov    %r10,%rcx
jae    1160 <com_putu+0x40>
mov    %r10,%rdi
call   1040 <com_puts@plt>
add    $0x408,%rsp
ret

LLVM IR (-O0):
define void @com_putu(i32 %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ult i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* %2
%9 = add i32 48, %8
%10 = call i32 @com_putc(i32 %9)
br label %39
11: ; preds = %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds i8, i8* %12, i64 1024
%14 = getelementptr inbounds i8, i8* %13, i64 -1
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 -1
store i8* %16, i8** %4
store i8 0, i8* %15
br label %17
17: ; preds = %26, %11
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%23 = icmp uge i8* %21, %22
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %35
26: ; preds = %24
%27 = load i32, i32* %2
%28 = urem i32 %27, 10
%29 = add i32 48, %28
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %4
store i8 %30, i8* %31
%33 = load i32, i32* %2
%34 = udiv i32 %33, 10
store i32 %34, i32* %2
br label %17
35: ; preds = %24
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %4
%38 = call i32 @com_puts(i8* %37)
br label %39
39: ; preds = %35, %7
ret void
}

LLVM IR (-O2):
define void @com_putu(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = icmp ult i32 %0, 10
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = add nuw nsw i32 %0, 48
%7 = tail call i32 @com_putc(i32 %6)
br label %24
8: ; preds = %1
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1023
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1022
store i8 0, i8* %9
br label %11
11: ; preds = %8, %11
%12 = phi i8* [ %10, %8 ], [ %17, %11 ]
%13 = phi i32 [ %0, %8 ], [ %18, %11 ]
%14 = urem i32 %13, 10
%15 = trunc i32 %14 to i8
%16 = or i8 %15, 48
%17 = getelementptr inbounds i8, i8* %12, i64 -1
store i8 %16, i8* %12
%18 = udiv i32 %13, 10
%19 = icmp ugt i32 %13, 9
%20 = icmp uge i8* %17, %3
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %11, label %22
22: ; preds = %11
%23 = call i32 @com_puts(i8* %12)
br label %24
24: ; preds = %22, %5
ret void
}