#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 */
char *strdup(char *);
char *base36enc(long unsigned int value) {
  char base36[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char buffer[14];
  unsigned int offset = sizeof(buffer);
  buffer[--offset] = '\0';
  do {
    buffer[--offset] = base36[value % 36];
  } while (value /= 36);
  return strdup(&buffer[offset]);
}


x86 assembly (clang, -O0):
<base36enc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x24,%edx
call   1030 <memcpy@plt>
movl   $0xe,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    %eax,%eax
movb   $0x0,-0x3e(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    $0x24,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x30(%rbp,%rdx,1),%cl
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    %eax,%eax
mov    %cl,-0x3e(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    $0x24,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1158 <base36enc+0x38>
mov    -0x44(%rbp),%eax
lea    -0x3e(%rbp),%rdi
add    %rax,%rdi
call   1040 <strdup@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base36enc>:
sub    $0x18,%rsp
mov    %rdi,%rsi
movb   $0x0,0x17(%rsp)
mov    $0xd,%ecx
lea    0xed8(%rip),%r8
movabs $0xe38e38e38e38e38f,%r9
38 8e e3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rsi,%rax
mul    %r9
shr    $0x5,%rdx
lea    0x0(,%rdx,4),%rax
lea    (%rax,%rax,8),%rax
mov    %rsi,%rdi
sub    %rax,%rdi
movzbl (%r8,%rdi,1),%eax
add    $0xffffffff,%ecx
mov    %al,0xa(%rsp,%rcx,1)
cmp    $0x23,%rsi
mov    %rdx,%rsi
ja     1140 <base36enc+0x30>
mov    %ecx,%eax
lea    (%rsp,%rax,1),%rdi
add    $0xa,%rdi
call   1030 <strdup@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.base36enc.base36 = [36 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
define i8* @base36enc(i64 %0) {
%2 = alloca i64
%3 = alloca [36 x i8]
%4 = alloca [14 x i8]
%5 = alloca i32
store i64 %0, i64* %2
%6 = bitcast [36 x i8]* %3 to i8*
store i32 14, i32* %5
%7 = load i32, i32* %5
%8 = add i32 %7, -1
store i32 %8, i32* %5
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 %9
store i8 0, i8* %10
br label %11
11: ; preds = %20, %1
%12 = load i64, i64* %2
%13 = urem i64 %12, 36
%14 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = load i32, i32* %5
%17 = add i32 %16, -1
store i32 %17, i32* %5
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %11
%21 = load i64, i64* %2
%22 = udiv i64 %21, 36
store i64 %22, i64* %2
%23 = icmp ne i64 %22, 0
br i1 %23, label %11, label %24
24: ; preds = %20
%25 = load i32, i32* %5
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 %26
%28 = call i8* @strdup(i8* %27)
ret i8* %28
}

LLVM IR (-O2):
@__const.base36enc.base36 = [36 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
define noalias i8* @base36enc(i64 %0) {
%2 = alloca [14 x i8]
%3 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 13
store i8 0, i8* %4
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %0, %1 ], [ %14, %5 ]
%7 = phi i32 [ 13, %1 ], [ %11, %5 ]
%8 = urem i64 %6, 36
%9 = getelementptr inbounds [36 x i8], [36 x i8]* @__const.base36enc.base36, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = add i32 %7, -1
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %12
store i8 %10, i8* %13
%14 = udiv i64 %6, 36
%15 = icmp ult i64 %6, 36
br i1 %15, label %16, label %5
16: ; preds = %5
%17 = zext i32 %11 to i64
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %17
%19 = call i8* @strdup(i8* %18)
ret i8* %19
}