#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*/ putch(int /*<<< orphan*/);
int /*<<< orphan*/ putstr(char *);
void printuint(char *before, unsigned v, char *after) {
  putstr(before);
  if (v == 0)
    putch('0');
  else {
    char buf[20], *p = &buf[20];
    *--p = 0;
    while (v != 0) {
      *--p = (v % 10) + '0';
      v /= 10;
    }
    putstr(p);
  }
  putstr(after);
}


x86 assembly (clang, -O0):
<printuint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <putstr@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1155 <printuint+0x35>
mov    $0x30,%edi
call   1040 <putch@plt>
jmp    11be <printuint+0x9e>
lea    -0x30(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,-0x1(%rax)
cmpl   $0x0,-0xc(%rbp)
je     11b5 <printuint+0x95>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,-0x1(%rax)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
jmp    1174 <printuint+0x54>
mov    -0x38(%rbp),%rdi
call   1030 <putstr@plt>
mov    -0x18(%rbp),%rdi
call   1030 <putstr@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printuint>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
call   1030 <putstr@plt>
test   %ebp,%ebp
je     117e <printuint+0x5e>
lea    0x13(%rsp),%rdi
movb   $0x0,0x13(%rsp)
mov    $0xcccccccd,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ebp,%esi
sub    %edx,%esi
or     $0x30,%sil
mov    %sil,-0x1(%rdi)
add    $0xffffffffffffffff,%rdi
cmp    $0x9,%ebp
mov    %ecx,%ebp
ja     1150 <printuint+0x30>
call   1030 <putstr@plt>
jmp    1188 <printuint+0x68>
mov    $0x30,%edi
call   1040 <putch@plt>
mov    %rbx,%rdi
call   1030 <putstr@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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