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

/* Variables and functions */
int getsymbol(int, int);
void encode_three_bytes(uint8_t *dest, uint8_t b1, uint8_t b2, uint8_t b3,
                        bool urlsafe) {
  dest[0] = getsymbol(b1 >> 2, urlsafe);
  dest[1] = getsymbol(((b1 & 0x03) << 4) | (b2 >> 4), urlsafe);
  dest[2] = getsymbol(((b2 & 0x0f) << 2) | (b3 >> 6), urlsafe);
  dest[3] = getsymbol(b3 & 0x3f, urlsafe);
}


x86 assembly (clang, -O0):
<encode_three_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%edi
sar    $0x2,%edi
mov    -0x18(%rbp),%esi
call   1030 <getsymbol@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%edi
and    $0x3,%edi
shl    $0x4,%edi
mov    -0x10(%rbp),%eax
sar    $0x4,%eax
or     %eax,%edi
mov    -0x18(%rbp),%esi
call   1030 <getsymbol@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%edi
and    $0xf,%edi
shl    $0x2,%edi
mov    -0x14(%rbp),%eax
sar    $0x6,%eax
or     %eax,%edi
mov    -0x18(%rbp),%esi
call   1030 <getsymbol@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%edi
and    $0x3f,%edi
mov    -0x18(%rbp),%esi
call   1030 <getsymbol@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_three_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%edi
sar    $0x2,%edi
mov    %r8d,%esi
call   1030 <getsymbol@plt>
mov    %eax,(%r14)
shl    $0x4,%ebx
and    $0x30,%ebx
mov    %ebp,%edi
sar    $0x4,%edi
or     %ebx,%edi
mov    %r15d,%esi
call   1030 <getsymbol@plt>
mov    %eax,0x4(%r14)
shl    $0x2,%ebp
and    $0x3c,%ebp
mov    %r12d,%edi
sar    $0x6,%edi
or     %ebp,%edi
mov    %r15d,%esi
call   1030 <getsymbol@plt>
mov    %eax,0x8(%r14)
and    $0x3f,%r12d
mov    %r12d,%edi
mov    %r15d,%esi
call   1030 <getsymbol@plt>
mov    %eax,0xc(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @encode_three_bytes(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = ashr i32 %11, 2
%13 = load i32, i32* %10
%14 = call i32 @getsymbol(i32 %12, i32 %13)
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 0
store i32 %14, i32* %16
%17 = load i32, i32* %7
%18 = and i32 %17, 3
%19 = shl i32 %18, 4
%20 = load i32, i32* %8
%21 = ashr i32 %20, 4
%22 = or i32 %19, %21
%23 = load i32, i32* %10
%24 = call i32 @getsymbol(i32 %22, i32 %23)
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 1
store i32 %24, i32* %26
%27 = load i32, i32* %8
%28 = and i32 %27, 15
%29 = shl i32 %28, 2
%30 = load i32, i32* %9
%31 = ashr i32 %30, 6
%32 = or i32 %29, %31
%33 = load i32, i32* %10
%34 = call i32 @getsymbol(i32 %32, i32 %33)
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 2
store i32 %34, i32* %36
%37 = load i32, i32* %9
%38 = and i32 %37, 63
%39 = load i32, i32* %10
%40 = call i32 @getsymbol(i32 %38, i32 %39)
%41 = load i32*, i32** %6
%42 = getelementptr inbounds i32, i32* %41, i64 3
store i32 %40, i32* %42
ret void
}

LLVM IR (-O2):
define void @encode_three_bytes(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = ashr i32 %1, 2
%7 = tail call i32 @getsymbol(i32 %6, i32 %4)
store i32 %7, i32* %0
%8 = shl i32 %1, 4
%9 = and i32 %8, 48
%10 = ashr i32 %2, 4
%11 = or i32 %9, %10
%12 = tail call i32 @getsymbol(i32 %11, i32 %4)
%13 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %12, i32* %13
%14 = shl i32 %2, 2
%15 = and i32 %14, 60
%16 = ashr i32 %3, 6
%17 = or i32 %15, %16
%18 = tail call i32 @getsymbol(i32 %17, i32 %4)
%19 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %18, i32* %19
%20 = and i32 %3, 63
%21 = tail call i32 @getsymbol(i32 %20, i32 %4)
%22 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %21, i32* %22
ret void
}