#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ debug_data(char *, int);
void debug_uint(uint64_t n) {
  char buf[20];
  int i = sizeof buf;
  do {
    buf[--i] = '0' + (n % 10);
    n /= 10;
  } while (n);
  debug_data(buf + i, sizeof buf - i);
}


x86 assembly (clang, -O0):
<debug_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x14,-0x24(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1122 <debug_uint+0x12>
lea    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
movslq -0x24(%rbp),%rcx
mov    $0x14,%eax
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <debug_data@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_uint>:
sub    $0x18,%rsp
mov    %edi,%eax
lea    0x14(%rsp),%rdi
xor    %esi,%esi
nopl   (%rax)
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%r8d
mov    %ecx,%edx
sub    %r8d,%edx
add    $0x30,%dl
mov    %dl,-0x1(%rdi)
add    $0xffffffffffffffff,%rdi
add    $0x9,%ecx
add    $0x1,%esi
cmp    $0x12,%ecx
ja     1120 <debug_uint+0x10>
call   1030 <debug_data@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define void @debug_uint(i32 %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 = %4, %1
%5 = phi i64 [ %10, %4 ], [ 20, %1 ]
%6 = phi i32 [ %12, %4 ], [ %0, %1 ]
%7 = srem i32 %6, 10
%8 = trunc i32 %7 to i8
%9 = add nsw i8 %8, 48
%10 = add nsw i64 %5, -1
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %10
store i8 %9, i8* %11
%12 = sdiv i32 %6, 10
%13 = add i32 %6, 9
%14 = icmp ult i32 %13, 19
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %10
%17 = trunc i64 %5 to i32
%18 = sub i32 21, %17
%19 = call i32 @debug_data(i8* %16, i32 %18)
ret void
}