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

/* Variables and functions */
int l64a_r(long value, char *buffer, int buflen) {
  static const char chars[] =
      "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  uint32_t v;
  v = value;
  while (buflen-- > 0) {
    if (v == 0) {
      *buffer = '\0';
      return (0);
    }
    *buffer++ = chars[v & 0x3f];
    v >>= 6;
  }
  return (-1);
}


x86 assembly (clang, -O0):
<l64a_r>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1179 <l64a_r+0x79>
cmpl   $0x0,-0x20(%rbp)
jne    1147 <l64a_r+0x47>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1180 <l64a_r+0x80>
mov    -0x20(%rbp),%eax
and    $0x3f,%eax
movslq %eax,%rcx
lea    0xea9(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
sar    $0x6,%eax
mov    %eax,-0x20(%rbp)
jmp    1116 <l64a_r+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<l64a_r>:
mov    $0xffffffff,%eax
test   %edx,%edx
jle    113f <l64a_r+0x3f>
add    $0x1,%edx
lea    0xeed(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %edi,%edi
je     1140 <l64a_r+0x40>
mov    %edi,%ecx
and    $0x3f,%ecx
movzbl (%rcx,%r8,1),%ecx
mov    %cl,(%rsi)
add    $0x1,%rsi
sar    $0x6,%edi
add    $0xffffffff,%edx
cmp    $0x1,%edx
jg     1120 <l64a_r+0x20>
ret
movb   $0x0,(%rsi)
xor    %eax,%eax
ret

LLVM IR (-O0):
@l64a_r.chars = internal constant [65 x i8] c"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define i32 @l64a_r(i64 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i64, i64* %5
%10 = trunc i64 %9 to i32
store i32 %10, i32* %8
br label %11
11: ; preds = %20, %3
%12 = load i32, i32* %7
%13 = add nsw i32 %12, -1
store i32 %13, i32* %7
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i8*, i8** %6
store i8 0, i8* %19
store i32 0, i32* %4
br label %31
20: ; preds = %15
%21 = load i32, i32* %8
%22 = and i32 %21, 63
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [65 x i8], [65 x i8]* @l64a_r.chars, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
store i8 %25, i8* %26
%28 = load i32, i32* %8
%29 = ashr i32 %28, 6
store i32 %29, i32* %8
br label %11
30: ; preds = %11
store i32 -1, i32* %4
br label %31
31: ; preds = %30, %18
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@l64a_r.chars = internal unnamed_addr constant [65 x i8] c"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define i32 @l64a_r(i64 %0, i8* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = trunc i64 %0 to i32
br label %7
7: ; preds = %5, %13
%8 = phi i32 [ %14, %13 ], [ %2, %5 ]
%9 = phi i32 [ %20, %13 ], [ %6, %5 ]
%10 = phi i8* [ %19, %13 ], [ %1, %5 ]
%11 = icmp eq i32 %9, 0
br i1 %11, label %12, label %13
12: ; preds = %7
store i8 0, i8* %10
br label %22
13: ; preds = %7
%14 = add nsw i32 %8, -1
%15 = and i32 %9, 63
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [65 x i8], [65 x i8]* @l64a_r.chars, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %18, i8* %10
%20 = ashr i32 %9, 6
%21 = icmp sgt i32 %8, 1
br i1 %21, label %7, label %22
22: ; preds = %13, %3, %12
%23 = phi i32 [ 0, %12 ], [ -1, %3 ], [ -1, %13 ]
ret i32 %23
}