#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 */
unsigned char digit_char(unsigned long long);
int /*<<< orphan*/ print_char(unsigned char);
void print_ull(unsigned long long l, unsigned long base) {
  unsigned char buf[sizeof(unsigned long long) * 8 + 1];
  int k = 0;
  do {
    buf[k] = digit_char(l % base);
    l = l / base;
    k++;
  } while (l > 0);
  k--;
  for (; k >= 0; k--) {
    print_char(buf[k]);
  }
}


x86 assembly (clang, -O0):
<print_ull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rdx,%rdi
call   1030 <digit_char@plt>
mov    %al,%cl
movslq -0x64(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rax,-0x8(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
cmpq   $0x0,-0x8(%rbp)
ja     1137 <print_ull+0x17>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jl     11a8 <print_ull+0x88>
movslq -0x64(%rbp),%rax
movzbl -0x60(%rbp,%rax,1),%edi
call   1040 <print_char@plt>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    1182 <print_ull+0x62>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ull>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r12d,%r12d
jmp    1163 <print_ull+0x43>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %r14
mov    %rdx,%rdi
mov    %rax,%r15
call   1030 <digit_char@plt>
mov    %al,(%rsp,%r12,1)
add    $0x1,%r12
cmp    %r14,%rbx
mov    %r15,%rbx
jb     117d <print_ull+0x5d>
mov    %rbx,%rax
or     %r14,%rax
shr    $0x20,%rax
jne    1140 <print_ull+0x20>
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%edi
mov    %eax,%r15d
jmp    114e <print_ull+0x2e>
add    $0xffffffffffffffff,%r12
mov    %r12d,%eax
lea    (%rsp,%rax,1),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%edi
call   1040 <print_char@plt>
lea    -0x1(%rbx),%rax
add    %r12d,%ebx
test   %ebx,%ebx
mov    %rax,%rbx
jg     1190 <print_ull+0x70>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @print_ull(i64 %0, i64 %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = phi i64 [ %11, %5 ], [ %0, %2 ]
%8 = urem i64 %7, %1
%9 = tail call zeroext i8 @digit_char(i64 %8)
%10 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %6
store i8 %9, i8* %10
%11 = udiv i64 %7, %1
%12 = add nuw i64 %6, 1
%13 = icmp ult i64 %7, %1
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = and i64 %6, 4294967295
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ %15, %14 ], [ %21, %16 ]
%18 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = tail call i32 @print_char(i8 zeroext %19)
%21 = add nsw i64 %17, -1
%22 = trunc i64 %17 to i32
%23 = icmp sgt i32 %22, 0
br i1 %23, label %16, label %24
24: ; preds = %16
ret void
}