void amatchEncodeInt(int x, char *z) {
  static const char a[] = "0123456789"
                          "ABCDEFGHIJ"
                          "KLMNOPQRST"
                          "UVWXYZ^abc"
                          "defghijklm"
                          "nopqrstuvw"
                          "xyz~";
  z[0] = a[(x >> 18) & 0x3f];
  z[1] = a[(x >> 12) & 0x3f];
  z[2] = a[(x >> 6) & 0x3f];
  z[3] = a[x & 0x3f];
}


x86 assembly (clang, -O0):
<amatchEncodeInt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x12,%eax
and    $0x3f,%eax
movslq %eax,%rcx
lea    0xee2(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
sar    $0xc,%eax
and    $0x3f,%eax
movslq %eax,%rcx
lea    0xec6(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
movslq %eax,%rcx
lea    0xea9(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
movslq %eax,%rcx
lea    0xe8f(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<amatchEncodeInt>:
mov    %edi,%eax
shr    $0x12,%eax
and    $0x3f,%eax
lea    0xef1(%rip),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,(%rsi)
mov    %edi,%eax
shr    $0xc,%eax
and    $0x3f,%eax
mov    (%rax,%rcx,1),%al
mov    %al,0x1(%rsi)
mov    %edi,%eax
shr    $0x6,%eax
and    $0x3f,%eax
mov    (%rax,%rcx,1),%al
mov    %al,0x2(%rsi)
and    $0x3f,%edi
mov    (%rdi,%rcx,1),%al
mov    %al,0x3(%rsi)
ret

LLVM IR (-O0):
@amatchEncodeInt.a = internal constant [65 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^abcdefghijklmnopqrstuvwxyz~\00"
define void @amatchEncodeInt(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = ashr i32 %5, 18
%7 = and i32 %6, 63
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 %10, i8* %12
%13 = load i32, i32* %3
%14 = ashr i32 %13, 12
%15 = and i32 %14, 63
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 %18, i8* %20
%21 = load i32, i32* %3
%22 = ashr i32 %21, 6
%23 = and i32 %22, 63
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = load i32, i32* %3
%30 = and i32 %29, 63
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 3
store i8 %33, i8* %35
ret void
}

LLVM IR (-O2):
@amatchEncodeInt.a = internal unnamed_addr constant [65 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^abcdefghijklmnopqrstuvwxyz~\00"
define void @amatchEncodeInt(i32 %0, i8* nocapture writeonly %1) {
%3 = lshr i32 %0, 18
%4 = and i32 %3, 63
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %5
%7 = load i8, i8* %6
store i8 %7, i8* %1
%8 = lshr i32 %0, 12
%9 = and i32 %8, 63
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %12, i8* %13
%14 = lshr i32 %0, 6
%15 = and i32 %14, 63
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %18, i8* %19
%20 = and i32 %0, 63
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [65 x i8], [65 x i8]* @amatchEncodeInt.a, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %23, i8* %24
ret void
}