#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*/ print_char(char);
void print_unint(int n) {
  int b;
  if (n < 10) {
    print_char((char)(n + 48));
    return;
  }
  b = 1;
  while (b <= (n / 10))
    b *= 10;
  while (b >= 1) {
    print_char((char)(n / b + '0'));
    n %= b;
    b /= 10;
  }
}


x86 assembly (clang, -O0):
<print_unint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1138 <print_unint+0x28>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <print_char@plt>
jmp    11a9 <print_unint+0x99>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jg     1169 <print_unint+0x59>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    113f <print_unint+0x2f>
jmp    116e <print_unint+0x5e>
cmpl   $0x1,-0x8(%rbp)
jl     11a9 <print_unint+0x99>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
add    $0x30,%eax
movsbl %al,%edi
call   1030 <print_char@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    116e <print_unint+0x5e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_unint>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
cmp    $0xa,%edi
jge    112c <print_unint+0x1c>
add    $0x30,%bpl
movsbl %bpl,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <print_char@plt>
mov    %ebp,%ecx
mov    $0xcccccccd,%eax
imul   %rcx,%rax
shr    $0x23,%rax
mov    $0x1,%ebx
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
cmp    %eax,%ebx
jbe    1140 <print_unint+0x30>
mov    $0xcccccccd,%r14d
nop
mov    %ebp,%eax
cltd
idiv   %ebx
add    $0x30,%al
movsbl %al,%edi
mov    %edx,%ebp
call   1030 <print_char@plt>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1150 <print_unint+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @print_unint(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 48
%9 = trunc i32 %8 to i8
%10 = call i32 @print_char(i8 signext %9)
br label %36
11: ; preds = %1
store i32 1, i32* %3
br label %12
12: ; preds = %17, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 10
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 10
store i32 %19, i32* %3
br label %12
20: ; preds = %12
br label %21
21: ; preds = %24, %20
%22 = load i32, i32* %3
%23 = icmp sge i32 %22, 1
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = sdiv i32 %25, %26
%28 = add nsw i32 %27, 48
%29 = trunc i32 %28 to i8
%30 = call i32 @print_char(i8 signext %29)
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = srem i32 %32, %31
store i32 %33, i32* %2
%34 = load i32, i32* %3
%35 = sdiv i32 %34, 10
store i32 %35, i32* %3
br label %21
36: ; preds = %6, %21
ret void
}

LLVM IR (-O2):
define void @print_unint(i32 %0) {
%2 = icmp slt i32 %0, 10
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = udiv i32 %0, 10
br label %9
5: ; preds = %1
%6 = trunc i32 %0 to i8
%7 = add i8 %6, 48
%8 = tail call i32 @print_char(i8 signext %7)
br label %23
9: ; preds = %3, %9
%10 = phi i32 [ %11, %9 ], [ 1, %3 ]
%11 = mul nsw i32 %10, 10
%12 = icmp ugt i32 %11, %4
br i1 %12, label %13, label %9
13: ; preds = %9, %13
%14 = phi i32 [ %21, %13 ], [ %11, %9 ]
%15 = phi i32 [ %20, %13 ], [ %0, %9 ]
%16 = sdiv i32 %15, %14
%17 = trunc i32 %16 to i8
%18 = add i8 %17, 48
%19 = tail call i32 @print_char(i8 signext %18)
%20 = srem i32 %15, %14
%21 = udiv i32 %14, 10
%22 = icmp ult i32 %14, 10
br i1 %22, label %23, label %13
23: ; preds = %13, %5
ret void
}