#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*/ term_putchar(unsigned long);
void term_print_decu(unsigned long x) {
  unsigned int divisor = 1;
  for (; divisor <= x; divisor *= 10)
    ;
  divisor /= 10;
  divisor = divisor == 0 ? 1 : divisor;
  for (; divisor > 0; divisor /= 10)
    term_putchar(((x / divisor) % 10) + '0');
}


x86 assembly (clang, -O0):
<term_print_decu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%rax
ja     1141 <term_print_decu+0x31>
jmp    1135 <term_print_decu+0x25>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <term_print_decu+0x13>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1167 <term_print_decu+0x57>
mov    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <term_print_decu+0x5d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jbe    11b3 <term_print_decu+0xa3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rdi
add    $0x30,%rdi
call   1030 <term_putchar@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
jmp    1173 <term_print_decu+0x63>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_print_decu>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
je     1155 <term_print_decu+0x45>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
cmp    %r14,%rcx
jbe    1130 <term_print_decu+0x20>
mov    $0x1,%eax
cmp    $0xa,%ecx
jb     11a5 <term_print_decu+0x95>
mov    %ecx,%ecx
mov    $0xcccccccd,%eax
imul   %rcx,%rax
shr    $0x23,%rax
jmp    11a5 <term_print_decu+0x95>
mov    $0x1,%eax
jmp    11a5 <term_print_decu+0x95>
nopl   0x0(%rax)
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rdi
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rdi,%rax
mul    %rcx
shr    $0x2,%rdx
and    $0xfffffffffffffffe,%rdx
lea    (%rdx,%rdx,4),%rax
sub    %rax,%rdi
or     $0x30,%rdi
call   1030 <term_putchar@plt>
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
jbe    11bb <term_print_decu+0xab>
mov    %eax,%ebx
mov    %r14,%rax
shr    $0x20,%rax
jne    1160 <term_print_decu+0x50>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
jmp    116b <term_print_decu+0x5b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @term_print_decu(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
store i32 1, i32* %3
br label %4
4: ; preds = %10, %1
%5 = load i32, i32* %3
%6 = zext i32 %5 to i64
%7 = load i64, i64* %2
%8 = icmp ule i64 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %4
br label %10
10: ; preds = %9
%11 = load i32, i32* %3
%12 = mul i32 %11, 10
store i32 %12, i32* %3
br label %4
13: ; preds = %4
%14 = load i32, i32* %3
%15 = udiv i32 %14, 10
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
br label %21
19: ; preds = %13
%20 = load i32, i32* %3
br label %21
21: ; preds = %19, %18
%22 = phi i32 [ 1, %18 ], [ %20, %19 ]
store i32 %22, i32* %3
br label %23
23: ; preds = %34, %21
%24 = load i32, i32* %3
%25 = icmp ugt i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = load i64, i64* %2
%28 = load i32, i32* %3
%29 = zext i32 %28 to i64
%30 = udiv i64 %27, %29
%31 = urem i64 %30, 10
%32 = add i64 %31, 48
%33 = call i32 @term_putchar(i64 %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %3
%36 = udiv i32 %35, 10
store i32 %36, i32* %3
br label %23
37: ; preds = %23
ret void
}

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