#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ print(char *);
void printl(unsigned long n) {
  volatile char buffer[12];
  int i = sizeof(buffer);
  buffer[--i] = '$';
  if (n == 0)
    buffer[--i] = '0';
  else
    for (; n > 0; n /= 10)
      buffer[--i] = '0' + (n % 10);
  print((char *)buffer + i);
}


x86 assembly (clang, -O0):
<printl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xc,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cltq
movb   $0x24,-0x14(%rbp,%rax,1)
cmpq   $0x0,-0x8(%rbp)
jne    1153 <printl+0x43>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cltq
movb   $0x30,-0x14(%rbp,%rax,1)
jmp    11a2 <printl+0x92>
jmp    1158 <printl+0x48>
cmpq   $0x0,-0x8(%rbp)
jbe    119d <printl+0x8d>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cltq
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
jmp    1158 <printl+0x48>
jmp    11a2 <printl+0x92>
lea    -0x14(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
call   1030 <print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printl>:
sub    $0x18,%rsp
movb   $0x24,0x17(%rsp)
test   %rdi,%rdi
je     1180 <printl+0x70>
lea    0x16(%rsp),%rsi
movabs $0xb00000000,%rcx
movabs $0xcccccccccccccccd,%r8
cc cc cc
movabs $0xffffffff00000000,%r9
ff ff ff
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %r9,%rcx
mov    %rdi,%rax
mul    %r8
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%r10d
mov    %edi,%eax
sub    %r10d,%eax
or     $0x30,%al
mov    %al,(%rsi)
add    $0xffffffffffffffff,%rsi
cmp    $0x9,%rdi
mov    %rdx,%rdi
ja     1150 <printl+0x40>
sar    $0x20,%rcx
jmp    118a <printl+0x7a>
movb   $0x30,0x16(%rsp)
mov    $0xa,%ecx
lea    (%rsp,%rcx,1),%rdi
add    $0xc,%rdi
call   1030 <print@plt>
add    $0x18,%rsp
ret

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

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