#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 */
typedef int /*<<< orphan*/ n;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fmt_str(char *);
void fmt_ull(unsigned long long n) {
  char buf[sizeof(n) * 3 + 2];
  char *p;
  p = buf + sizeof(buf) - 1;
  *p = '\0';
  do {
    *--p = (n % 10) + '0';
    n /= 10;
  } while (n);
  fmt_str(p);
}


x86 assembly (clang, -O0):
<fmt_ull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rax
add    $0x1a,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1133 <fmt_ull+0x23>
mov    -0x38(%rbp),%rdi
call   1030 <fmt_str@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_ull>:
sub    $0x28,%rsp
mov    %rdi,%rcx
lea    0x19(%rsp),%rdi
movb   $0x0,0x19(%rsp)
movabs $0xcccccccccccccccd,%r8
cc cc cc
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
mul    %r8
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%esi
sub    %eax,%esi
or     $0x30,%sil
mov    %sil,-0x1(%rdi)
add    $0xffffffffffffffff,%rdi
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     1130 <fmt_ull+0x20>
call   1030 <fmt_str@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define void @fmt_ull(i64 %0) {
%2 = alloca i64
%3 = alloca [26 x i8]
%4 = alloca i8*
store i64 %0, i64* %2
%5 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds i8, i8* %5, i64 26
%7 = getelementptr inbounds i8, i8* %6, i64 -1
store i8* %7, i8** %4
%8 = load i8*, i8** %4
store i8 0, i8* %8
br label %9
9: ; preds = %18, %1
%10 = load i64, i64* %2
%11 = urem i64 %10, 10
%12 = add i64 %11, 48
%13 = trunc i64 %12 to i8
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 -1
store i8* %15, i8** %4
store i8 %13, i8* %15
%16 = load i64, i64* %2
%17 = udiv i64 %16, 10
store i64 %17, i64* %2
br label %18
18: ; preds = %9
%19 = load i64, i64* %2
%20 = icmp ne i64 %19, 0
br i1 %20, label %9, label %21
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i32 @fmt_str(i8* %22)
ret void
}

LLVM IR (-O2):
define void @fmt_ull(i64 %0) {
%2 = alloca [26 x i8]
%3 = getelementptr inbounds [26 x i8], [26 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [26 x i8], [26 x i8]* %2, i64 0, i64 25
store i8 0, i8* %4
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %0, %1 ], [ %12, %5 ]
%7 = phi i8* [ %4, %1 ], [ %11, %5 ]
%8 = urem i64 %6, 10
%9 = trunc i64 %8 to i8
%10 = or i8 %9, 48
%11 = getelementptr inbounds i8, i8* %7, i64 -1
store i8 %10, i8* %11
%12 = udiv i64 %6, 10
%13 = icmp ult i64 %6, 10
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = call i32 @fmt_str(i8* %11)
ret void
}