#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*/ my_putchar(unsigned int);
void my_put_uint(unsigned int nb) {
  int tall;
  tall = 1;
  while (nb / tall > 9)
    tall = tall * 10;
  while (tall != 0) {
    my_putchar(nb / tall % 10 + 48);
    tall = tall / 10;
  }
}


x86 assembly (clang, -O0):
<my_put_uint>:
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    $0x9,%eax
jbe    113f <my_put_uint+0x2f>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <my_put_uint+0x12>
jmp    1144 <my_put_uint+0x34>
cmpl   $0x0,-0x8(%rbp)
je     117c <my_put_uint+0x6c>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1144 <my_put_uint+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_uint>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x1,%ebx
cmp    $0xa,%edi
jb     1140 <my_put_uint+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 <my_put_uint+0x20>
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %rax,%rcx
imul   %r14,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%eax
mov    %eax,%edi
call   1030 <my_putchar@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
add    $0x9,%eax
cmp    $0x12,%eax
ja     1150 <my_put_uint+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @my_put_uint(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 ugt i32 %7, 9
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* %3
%11 = mul nsw i32 %10, 10
store i32 %11, i32* %3
br label %4
12: ; preds = %4
br label %13
13: ; preds = %16, %12
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = udiv i32 %17, %18
%20 = urem i32 %19, 10
%21 = add i32 %20, 48
%22 = call i32 @my_putchar(i32 %21)
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 10
store i32 %24, i32* %3
br label %13
25: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @my_put_uint(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 nuw nsw 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 ], [ %9, %8 ]
%12 = udiv i32 %0, %11
%13 = urem i32 %12, 10
%14 = or i32 %13, 48
%15 = tail call i32 @my_putchar(i32 %14)
%16 = sdiv i32 %11, 10
%17 = add i32 %11, 9
%18 = icmp ult i32 %17, 19
br i1 %18, label %19, label %10
19: ; preds = %10
ret void
}