#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*/ puts(char *);
void print_u64(unsigned long int val) {
  char str[20] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\0'};
  int i;
  for (i = 19; i >= 0; i--) {
    str[i] = '0' + val % 10;
    val /= 10;
    if (!val)
      break;
  }
  puts(str + i);
}


x86 assembly (clang, -O0):
<print_u64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x13,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     119d <print_u64+0x8d>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
add    $0x30,%rdx
mov    %dl,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118a <print_u64+0x7a>
jmp    119d <print_u64+0x8d>
jmp    118f <print_u64+0x7f>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1142 <print_u64+0x32>
lea    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_u64>:
sub    $0x18,%rsp
mov    %rdi,%rdx
movaps 0xee2(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x202020,0x10(%rsp)
mov    $0x13,%esi
movabs $0xcccccccccccccccd,%r8
cc cc cc
nopl   0x0(%rax)
mov    %rdx,%rcx
mov    %rdx,%rax
mul    %r8
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%edi
sub    %eax,%edi
or     $0x30,%dil
mov    %dil,(%rsp,%rsi,1)
cmp    $0xa,%rcx
jb     1172 <print_u64+0x62>
add    $0xffffffffffffffff,%rsi
jb     1140 <print_u64+0x30>
mov    $0xffffffffffffffff,%rsi
movslq %esi,%rax
lea    (%rsp,%rax,1),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.print_u64.str = [20 x i8] c" \00"
define void @print_u64(i64 %0) {
%2 = alloca i64
%3 = alloca [20 x i8]
%4 = alloca i32
store i64 %0, i64* %2
%5 = bitcast [20 x i8]* %3 to i8*
store i32 19, i32* %4
br label %6
6: ; preds = %23, %1
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = load i64, i64* %2
%11 = urem i64 %10, 10
%12 = add i64 48, %11
%13 = trunc i64 %12 to i8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %15
store i8 %13, i8* %16
%17 = load i64, i64* %2
%18 = udiv i64 %17, 10
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = icmp ne i64 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %9
br label %26
22: ; preds = %9
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, -1
store i32 %25, i32* %4
br label %6
26: ; preds = %21, %6
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = call i32 @puts(i8* %30)
ret void
}

LLVM IR (-O2):
@__const.print_u64.str = [20 x i8] c" \00"
define void @print_u64(i64 %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %13
%5 = phi i64 [ 19, %1 ], [ %14, %13 ]
%6 = phi i64 [ %0, %1 ], [ %8, %13 ]
%7 = urem i64 %6, 10
%8 = udiv i64 %6, 10
%9 = trunc i64 %7 to i8
%10 = or i8 %9, 48
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %5
store i8 %10, i8* %11
%12 = icmp ult i64 %6, 10
br i1 %12, label %16, label %13
13: ; preds = %4
%14 = add nsw i64 %5, -1
%15 = icmp eq i64 %5, 0
br i1 %15, label %16, label %4
16: ; preds = %4, %13
%17 = phi i64 [ %5, %4 ], [ -1, %13 ]
%18 = shl i64 %17, 32
%19 = ashr exact i64 %18, 32
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %19
%21 = call i32 @puts(i8* %20)
ret void
}