#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*/ nanotest_putchar(unsigned int);
void nanotest_putuint(unsigned int n) {
  unsigned int scale = 1;
  while (n / scale >= 10)
    scale *= 10;
  do {
    nanotest_putchar(n / scale + '0');
    n %= scale;
    scale /= 10;
  } while (scale >= 1);
}


x86 assembly (clang, -O0):
<nanotest_putuint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
cmp    $0xa,%eax
jb     113f <nanotest_putuint+0x2f>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <nanotest_putuint+0x12>
jmp    1144 <nanotest_putuint+0x34>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,%edi
add    $0x30,%edi
call   1030 <nanotest_putchar@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
xor    %edx,%edx
div    %ecx
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jae    1144 <nanotest_putuint+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nanotest_putuint>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x1,%ebx
cmp    $0xa,%edi
jb     1140 <nanotest_putuint+0x30>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
cmp    $0x9,%eax
ja     1130 <nanotest_putuint+0x20>
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
lea    0x30(%rax),%edi
mov    %edx,%ebp
call   1030 <nanotest_putchar@plt>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1150 <nanotest_putuint+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @nanotest_putuint(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = udiv i32 %5, %6
%8 = icmp uge i32 %7, 10
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* %3
%11 = mul i32 %10, 10
store i32 %11, i32* %3
br label %4
12: ; preds = %4
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = udiv i32 %14, %15
%17 = add i32 %16, 48
%18 = call i32 @nanotest_putchar(i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = urem i32 %20, %19
store i32 %21, i32* %2
%22 = load i32, i32* %3
%23 = udiv i32 %22, 10
store i32 %23, i32* %3
br label %24
24: ; preds = %13
%25 = load i32, i32* %3
%26 = icmp uge i32 %25, 1
br i1 %26, label %13, label %27
27: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @nanotest_putuint(i32 %0) {
%2 = icmp ugt i32 %0, 9
br i1 %2, label %3, label %8
3: ; preds = %1, %3
%4 = phi i32 [ %5, %3 ], [ 1, %1 ]
%5 = mul i32 %4, 10
%6 = udiv i32 %0, %5
%7 = icmp ugt i32 %6, 9
br i1 %7, label %3, label %8
8: ; preds = %3, %1
%9 = phi i32 [ 1, %1 ], [ %5, %3 ]
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ %16, %10 ], [ %0, %8 ]
%12 = phi i32 [ %17, %10 ], [ %9, %8 ]
%13 = udiv i32 %11, %12
%14 = add i32 %13, 48
%15 = tail call i32 @nanotest_putchar(i32 %14)
%16 = urem i32 %11, %12
%17 = udiv i32 %12, 10
%18 = icmp ult i32 %12, 10
br i1 %18, label %19, label %10
19: ; preds = %10
ret void
}