#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_put_char(unsigned int);
void my_put_unsigned(unsigned int num) {
  int div = 1;
  while (num / div > 9)
    div = div * 10;
  while (div >= 1) {
    if (num > 0)
      my_put_char('0' + (num / div) % 10);
    div = div / 10;
  }
}


x86 assembly (clang, -O0):
<my_put_unsigned>:
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_unsigned+0x2f>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <my_put_unsigned+0x12>
jmp    1144 <my_put_unsigned+0x34>
cmpl   $0x1,-0x8(%rbp)
jl     1186 <my_put_unsigned+0x76>
cmpl   $0x0,-0x4(%rbp)
jbe    1173 <my_put_unsigned+0x63>
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_put_char@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1144 <my_put_unsigned+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_unsigned>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    $0x1,%ebx
cmp    $0xa,%edi
jb     1140 <my_put_unsigned+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_unsigned+0x20>
mov    $0xcccccccd,%r14d
jmp    1161 <my_put_unsigned+0x51>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
jbe    1189 <my_put_unsigned+0x79>
test   %ebp,%ebp
je     1150 <my_put_unsigned+0x40>
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_put_char@plt>
jmp    1150 <my_put_unsigned+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @my_put_unsigned(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 = %26, %12
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 1
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp ugt i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = udiv i32 %20, %21
%23 = urem i32 %22, 10
%24 = add i32 48, %23
%25 = call i32 @my_put_char(i32 %24)
br label %26
26: ; preds = %19, %16
%27 = load i32, i32* %3
%28 = sdiv i32 %27, 10
store i32 %28, i32* %3
br label %13
29: ; preds = %13
ret void
}

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