#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(char);
int my_put_nbr_uns(unsigned int nb) {
  int cmp;
  int c;
  char *base;
  base = "0123456789";
  cmp = 0;
  c = 1;
  while (nb / c >= 10)
    c *= 10;
  while (c > 0) {
    my_putchar(base[nb / c % 10]);
    cmp++;
    c /= 10;
  }
  return (cmp);
}


x86 assembly (clang, -O0):
<my_put_nbr_uns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
cmp    $0xa,%eax
jb     1151 <my_put_nbr_uns+0x41>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <my_put_nbr_uns+0x24>
jmp    1156 <my_put_nbr_uns+0x46>
cmpl   $0x0,-0xc(%rbp)
jle    11a4 <my_put_nbr_uns+0x94>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x20(%rbp),%rax
mov    %edx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1156 <my_put_nbr_uns+0x46>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_nbr_uns>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0x1,%ebx
cmp    $0xa,%edi
jb     1141 <my_put_nbr_uns+0x31>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
cmp    $0x9,%eax
ja     1130 <my_put_nbr_uns+0x20>
xor    %ebp,%ebp
mov    $0xcccccccd,%r15d
lea    0xeb0(%rip),%r12
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %rax,%rcx
imul   %r15,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
movsbl (%rax,%r12,1),%edi
call   1030 <my_putchar@plt>
add    $0x1,%ebp
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1150 <my_put_nbr_uns+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
define i32 @my_put_nbr_uns(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %5
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %11, %1
%7 = load i32, i32* %2
%8 = load i32, i32* %4
%9 = udiv i32 %7, %8
%10 = icmp uge i32 %9, 10
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 10
store i32 %13, i32* %4
br label %6
14: ; preds = %6
br label %15
15: ; preds = %18, %14
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = udiv i32 %20, %21
%23 = urem i32 %22, 10
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %19, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @my_putchar(i8 signext %26)
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
%30 = load i32, i32* %4
%31 = sdiv i32 %30, 10
store i32 %31, i32* %4
br label %15
32: ; preds = %15
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
define i32 @my_put_nbr_uns(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 [ %19, %10 ], [ 0, %8 ]
%12 = phi i32 [ %20, %10 ], [ %9, %8 ]
%13 = udiv i32 %0, %12
%14 = urem i32 %13, 10
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [11 x i8], [11 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @my_putchar(i8 signext %17)
%19 = add nuw nsw i32 %11, 1
%20 = udiv i32 %12, 10
%21 = icmp ult i32 %12, 10
br i1 %21, label %22, label %10
22: ; preds = %10
ret i32 %19
}