int gator_write_packed_int64(char *buffer, unsigned long long x) {
  if ((x & 0xffffffffffffff80LL) == 0) {
    buffer[0] = x & 0x7f;
    return 1;
  } else if ((x & 0xffffffffffffc000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) & 0x7f;
    return 2;
  } else if ((x & 0xffffffffffe00000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) & 0x7f;
    return 3;
  } else if ((x & 0xfffffffff0000000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) & 0x7f;
    return 4;
  } else if ((x & 0xfffffff800000000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) | 0x80;
    buffer[4] = (x >> 28) & 0x7f;
    return 5;
  } else if ((x & 0xfffffc0000000000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) | 0x80;
    buffer[4] = (x >> 28) | 0x80;
    buffer[5] = (x >> 35) & 0x7f;
    return 6;
  } else if ((x & 0xfffe000000000000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) | 0x80;
    buffer[4] = (x >> 28) | 0x80;
    buffer[5] = (x >> 35) | 0x80;
    buffer[6] = (x >> 42) & 0x7f;
    return 7;
  } else if ((x & 0xff00000000000000LL) == 0) {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) | 0x80;
    buffer[4] = (x >> 28) | 0x80;
    buffer[5] = (x >> 35) | 0x80;
    buffer[6] = (x >> 42) | 0x80;
    buffer[7] = (x >> 49) & 0x7f;
    return 8;
  } else {
    buffer[0] = x | 0x80;
    buffer[1] = (x >> 7) | 0x80;
    buffer[2] = (x >> 14) | 0x80;
    buffer[3] = (x >> 21) | 0x80;
    buffer[4] = (x >> 28) | 0x80;
    buffer[5] = (x >> 35) | 0x80;
    buffer[6] = (x >> 42) | 0x80;
    buffer[7] = (x >> 49) | 0x80;
    buffer[8] = (x >> 56) & 0xff;
    return 9;
  }
}


x86 assembly (clang, -O0):
<gator_write_packed_int64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xffffffffffffff80,%rax
cmp    $0x0,%rax
jne    113a <gator_write_packed_int64+0x3a>
mov    -0x18(%rbp),%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
mov    -0x18(%rbp),%rax
and    $0xffffffffffffc000,%rax
cmp    $0x0,%rax
jne    1181 <gator_write_packed_int64+0x81>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
movl   $0x2,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
mov    -0x18(%rbp),%rax
and    $0xffffffffffe00000,%rax
cmp    $0x0,%rax
jne    11df <gator_write_packed_int64+0xdf>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
movl   $0x3,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
mov    -0x18(%rbp),%rax
and    $0xfffffffff0000000,%rax
cmp    $0x0,%rax
jne    1254 <gator_write_packed_int64+0x154>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
movl   $0x4,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
movabs $0xfffffff800000000,%rax
ff ff ff
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    12e4 <gator_write_packed_int64+0x1e4>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1c,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
movl   $0x5,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
movabs $0xfffffc0000000000,%rax
fc ff ff
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    138b <gator_write_packed_int64+0x28b>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1c,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
shr    $0x23,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
movl   $0x6,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
movabs $0xfffe000000000000,%rax
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    1449 <gator_write_packed_int64+0x349>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1c,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
shr    $0x23,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
shr    $0x2a,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
movl   $0x7,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
movabs $0xff00000000000000,%rax
and    -0x18(%rbp),%rax
cmp    $0x0,%rax
jne    151e <gator_write_packed_int64+0x41e>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1c,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
shr    $0x23,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
shr    $0x2a,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x18(%rbp),%rax
shr    $0x31,%rax
and    $0x7f,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
movl   $0x8,-0x4(%rbp)
jmp    15ef <gator_write_packed_int64+0x4ef>
mov    -0x18(%rbp),%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
shr    $0x7,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
shr    $0xe,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
shr    $0x15,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1c,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
shr    $0x23,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
shr    $0x2a,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x18(%rbp),%rax
shr    $0x31,%rax
or     $0x80,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x18(%rbp),%rax
shr    $0x38,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
movl   $0x9,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gator_write_packed_int64>:
push   %rbx
cmp    $0x7f,%rsi
ja     1111 <gator_write_packed_int64+0x11>
mov    %sil,(%rdi)
mov    $0x1,%eax
pop    %rbx
ret
cmp    $0x3fff,%rsi
ja     112f <gator_write_packed_int64+0x2f>
mov    %esi,%eax
or     $0x80,%al
mov    %al,(%rdi)
shr    $0x7,%rsi
mov    %sil,0x1(%rdi)
mov    $0x2,%eax
pop    %rbx
ret
cmp    $0x1fffff,%rsi
ja     1159 <gator_write_packed_int64+0x59>
mov    %esi,%eax
or     $0x80,%al
mov    %al,(%rdi)
mov    %rsi,%rax
shr    $0x7,%rax
or     $0x80,%al
mov    %al,0x1(%rdi)
shr    $0xe,%rsi
mov    %sil,0x2(%rdi)
mov    $0x3,%eax
pop    %rbx
ret
cmp    $0xfffffff,%rsi
ja     118f <gator_write_packed_int64+0x8f>
mov    %esi,%eax
or     $0x80,%al
mov    %al,(%rdi)
mov    %rsi,%rax
shr    $0x7,%rax
or     $0x80,%al
mov    %al,0x1(%rdi)
mov    %rsi,%rax
shr    $0xe,%rax
or     $0x80,%al
mov    %al,0x2(%rdi)
shr    $0x15,%rsi
mov    %sil,0x3(%rdi)
mov    $0x4,%eax
pop    %rbx
ret
mov    %rsi,%rax
shr    $0x23,%rax
jne    11d1 <gator_write_packed_int64+0xd1>
mov    %esi,%eax
or     $0x80,%al
mov    %al,(%rdi)
mov    %rsi,%rax
shr    $0x7,%rax
or     $0x80,%al
mov    %al,0x1(%rdi)
mov    %rsi,%rax
shr    $0xe,%rax
or     $0x80,%al
mov    %al,0x2(%rdi)
mov    %rsi,%rax
shr    $0x15,%rax
or     $0x80,%al
mov    %al,0x3(%rdi)
shr    $0x1c,%rsi
mov    %sil,0x4(%rdi)
mov    $0x5,%eax
pop    %rbx
ret
mov    %rsi,%rcx
shr    $0x2a,%rcx
jne    121e <gator_write_packed_int64+0x11e>
mov    %esi,%ecx
or     $0x80,%cl
mov    %cl,(%rdi)
mov    %rsi,%rcx
shr    $0x7,%rcx
or     $0x80,%cl
mov    %cl,0x1(%rdi)
mov    %rsi,%rcx
shr    $0xe,%rcx
or     $0x80,%cl
mov    %cl,0x2(%rdi)
mov    %rsi,%rcx
shr    $0x15,%rcx
or     $0x80,%cl
mov    %cl,0x3(%rdi)
shr    $0x1c,%rsi
or     $0x80,%sil
mov    %sil,0x4(%rdi)
mov    %al,0x5(%rdi)
mov    $0x6,%eax
pop    %rbx
ret
mov    %rsi,%r10
shr    $0x31,%r10
jne    1270 <gator_write_packed_int64+0x170>
mov    %esi,%edx
or     $0x80,%dl
mov    %dl,(%rdi)
mov    %rsi,%rdx
shr    $0x7,%rdx
or     $0x80,%dl
mov    %dl,0x1(%rdi)
mov    %rsi,%rdx
shr    $0xe,%rdx
or     $0x80,%dl
mov    %dl,0x2(%rdi)
mov    %rsi,%rdx
shr    $0x15,%rdx
or     $0x80,%dl
mov    %dl,0x3(%rdi)
shr    $0x1c,%rsi
or     $0x80,%sil
mov    %sil,0x4(%rdi)
or     $0x80,%al
mov    %al,0x5(%rdi)
mov    %cl,0x6(%rdi)
mov    $0x7,%eax
pop    %rbx
ret
mov    %rsi,%r8
shr    $0x38,%r8
mov    %esi,%r9d
or     $0x80,%r9b
mov    %rsi,%r11
shr    $0x7,%r11
or     $0x80,%r11b
mov    %rsi,%rdx
shr    $0xe,%rdx
or     $0x80,%dl
mov    %rsi,%rbx
shr    $0x15,%rbx
or     $0x80,%bl
shr    $0x1c,%rsi
or     $0x80,%sil
or     $0x80,%al
or     $0x80,%cl
mov    %r9b,(%rdi)
mov    %r11b,0x1(%rdi)
mov    %dl,0x2(%rdi)
mov    %bl,0x3(%rdi)
mov    %sil,0x4(%rdi)
mov    %al,0x5(%rdi)
mov    %cl,0x6(%rdi)
test   %r8,%r8
jne    12d1 <gator_write_packed_int64+0x1d1>
mov    %r10b,0x7(%rdi)
mov    $0x8,%eax
pop    %rbx
ret
or     $0x80,%r10b
mov    %r10b,0x7(%rdi)
mov    %r8b,0x8(%rdi)
mov    $0x9,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @gator_write_packed_int64(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = and i64 %6, -128
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i64, i64* %5
%11 = and i64 %10, 127
%12 = trunc i64 %11 to i8
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 %12, i8* %14
store i32 1, i32* %3
br label %307
15: ; preds = %2
%16 = load i64, i64* %5
%17 = and i64 %16, -16384
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load i64, i64* %5
%21 = or i64 %20, 128
%22 = trunc i64 %21 to i8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 %22, i8* %24
%25 = load i64, i64* %5
%26 = lshr i64 %25, 7
%27 = and i64 %26, 127
%28 = trunc i64 %27 to i8
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %28, i8* %30
store i32 2, i32* %3
br label %307
31: ; preds = %15
%32 = load i64, i64* %5
%33 = and i64 %32, -2097152
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %53
35: ; preds = %31
%36 = load i64, i64* %5
%37 = or i64 %36, 128
%38 = trunc i64 %37 to i8
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 0
store i8 %38, i8* %40
%41 = load i64, i64* %5
%42 = lshr i64 %41, 7
%43 = or i64 %42, 128
%44 = trunc i64 %43 to i8
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 1
store i8 %44, i8* %46
%47 = load i64, i64* %5
%48 = lshr i64 %47, 14
%49 = and i64 %48, 127
%50 = trunc i64 %49 to i8
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 2
store i8 %50, i8* %52
store i32 3, i32* %3
br label %307
53: ; preds = %31
%54 = load i64, i64* %5
%55 = and i64 %54, -268435456
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %81
57: ; preds = %53
%58 = load i64, i64* %5
%59 = or i64 %58, 128
%60 = trunc i64 %59 to i8
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 0
store i8 %60, i8* %62
%63 = load i64, i64* %5
%64 = lshr i64 %63, 7
%65 = or i64 %64, 128
%66 = trunc i64 %65 to i8
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8 %66, i8* %68
%69 = load i64, i64* %5
%70 = lshr i64 %69, 14
%71 = or i64 %70, 128
%72 = trunc i64 %71 to i8
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i64 2
store i8 %72, i8* %74
%75 = load i64, i64* %5
%76 = lshr i64 %75, 21
%77 = and i64 %76, 127
%78 = trunc i64 %77 to i8
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i64 3
store i8 %78, i8* %80
store i32 4, i32* %3
br label %307
81: ; preds = %53
%82 = load i64, i64* %5
%83 = and i64 %82, -34359738368
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %115
85: ; preds = %81
%86 = load i64, i64* %5
%87 = or i64 %86, 128
%88 = trunc i64 %87 to i8
%89 = load i8*, i8** %4
%90 = getelementptr inbounds i8, i8* %89, i64 0
store i8 %88, i8* %90
%91 = load i64, i64* %5
%92 = lshr i64 %91, 7
%93 = or i64 %92, 128
%94 = trunc i64 %93 to i8
%95 = load i8*, i8** %4
%96 = getelementptr inbounds i8, i8* %95, i64 1
store i8 %94, i8* %96
%97 = load i64, i64* %5
%98 = lshr i64 %97, 14
%99 = or i64 %98, 128
%100 = trunc i64 %99 to i8
%101 = load i8*, i8** %4
%102 = getelementptr inbounds i8, i8* %101, i64 2
store i8 %100, i8* %102
%103 = load i64, i64* %5
%104 = lshr i64 %103, 21
%105 = or i64 %104, 128
%106 = trunc i64 %105 to i8
%107 = load i8*, i8** %4
%108 = getelementptr inbounds i8, i8* %107, i64 3
store i8 %106, i8* %108
%109 = load i64, i64* %5
%110 = lshr i64 %109, 28
%111 = and i64 %110, 127
%112 = trunc i64 %111 to i8
%113 = load i8*, i8** %4
%114 = getelementptr inbounds i8, i8* %113, i64 4
store i8 %112, i8* %114
store i32 5, i32* %3
br label %307
115: ; preds = %81
%116 = load i64, i64* %5
%117 = and i64 %116, -4398046511104
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %155
119: ; preds = %115
%120 = load i64, i64* %5
%121 = or i64 %120, 128
%122 = trunc i64 %121 to i8
%123 = load i8*, i8** %4
%124 = getelementptr inbounds i8, i8* %123, i64 0
store i8 %122, i8* %124
%125 = load i64, i64* %5
%126 = lshr i64 %125, 7
%127 = or i64 %126, 128
%128 = trunc i64 %127 to i8
%129 = load i8*, i8** %4
%130 = getelementptr inbounds i8, i8* %129, i64 1
store i8 %128, i8* %130
%131 = load i64, i64* %5
%132 = lshr i64 %131, 14
%133 = or i64 %132, 128
%134 = trunc i64 %133 to i8
%135 = load i8*, i8** %4
%136 = getelementptr inbounds i8, i8* %135, i64 2
store i8 %134, i8* %136
%137 = load i64, i64* %5
%138 = lshr i64 %137, 21
%139 = or i64 %138, 128
%140 = trunc i64 %139 to i8
%141 = load i8*, i8** %4
%142 = getelementptr inbounds i8, i8* %141, i64 3
store i8 %140, i8* %142
%143 = load i64, i64* %5
%144 = lshr i64 %143, 28
%145 = or i64 %144, 128
%146 = trunc i64 %145 to i8
%147 = load i8*, i8** %4
%148 = getelementptr inbounds i8, i8* %147, i64 4
store i8 %146, i8* %148
%149 = load i64, i64* %5
%150 = lshr i64 %149, 35
%151 = and i64 %150, 127
%152 = trunc i64 %151 to i8
%153 = load i8*, i8** %4
%154 = getelementptr inbounds i8, i8* %153, i64 5
store i8 %152, i8* %154
store i32 6, i32* %3
br label %307
155: ; preds = %115
%156 = load i64, i64* %5
%157 = and i64 %156, -562949953421312
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %201
159: ; preds = %155
%160 = load i64, i64* %5
%161 = or i64 %160, 128
%162 = trunc i64 %161 to i8
%163 = load i8*, i8** %4
%164 = getelementptr inbounds i8, i8* %163, i64 0
store i8 %162, i8* %164
%165 = load i64, i64* %5
%166 = lshr i64 %165, 7
%167 = or i64 %166, 128
%168 = trunc i64 %167 to i8
%169 = load i8*, i8** %4
%170 = getelementptr inbounds i8, i8* %169, i64 1
store i8 %168, i8* %170
%171 = load i64, i64* %5
%172 = lshr i64 %171, 14
%173 = or i64 %172, 128
%174 = trunc i64 %173 to i8
%175 = load i8*, i8** %4
%176 = getelementptr inbounds i8, i8* %175, i64 2
store i8 %174, i8* %176
%177 = load i64, i64* %5
%178 = lshr i64 %177, 21
%179 = or i64 %178, 128
%180 = trunc i64 %179 to i8
%181 = load i8*, i8** %4
%182 = getelementptr inbounds i8, i8* %181, i64 3
store i8 %180, i8* %182
%183 = load i64, i64* %5
%184 = lshr i64 %183, 28
%185 = or i64 %184, 128
%186 = trunc i64 %185 to i8
%187 = load i8*, i8** %4
%188 = getelementptr inbounds i8, i8* %187, i64 4
store i8 %186, i8* %188
%189 = load i64, i64* %5
%190 = lshr i64 %189, 35
%191 = or i64 %190, 128
%192 = trunc i64 %191 to i8
%193 = load i8*, i8** %4
%194 = getelementptr inbounds i8, i8* %193, i64 5
store i8 %192, i8* %194
%195 = load i64, i64* %5
%196 = lshr i64 %195, 42
%197 = and i64 %196, 127
%198 = trunc i64 %197 to i8
%199 = load i8*, i8** %4
%200 = getelementptr inbounds i8, i8* %199, i64 6
store i8 %198, i8* %200
store i32 7, i32* %3
br label %307
201: ; preds = %155
%202 = load i64, i64* %5
%203 = and i64 %202, -72057594037927936
%204 = icmp eq i64 %203, 0
br i1 %204, label %205, label %253
205: ; preds = %201
%206 = load i64, i64* %5
%207 = or i64 %206, 128
%208 = trunc i64 %207 to i8
%209 = load i8*, i8** %4
%210 = getelementptr inbounds i8, i8* %209, i64 0
store i8 %208, i8* %210
%211 = load i64, i64* %5
%212 = lshr i64 %211, 7
%213 = or i64 %212, 128
%214 = trunc i64 %213 to i8
%215 = load i8*, i8** %4
%216 = getelementptr inbounds i8, i8* %215, i64 1
store i8 %214, i8* %216
%217 = load i64, i64* %5
%218 = lshr i64 %217, 14
%219 = or i64 %218, 128
%220 = trunc i64 %219 to i8
%221 = load i8*, i8** %4
%222 = getelementptr inbounds i8, i8* %221, i64 2
store i8 %220, i8* %222
%223 = load i64, i64* %5
%224 = lshr i64 %223, 21
%225 = or i64 %224, 128
%226 = trunc i64 %225 to i8
%227 = load i8*, i8** %4
%228 = getelementptr inbounds i8, i8* %227, i64 3
store i8 %226, i8* %228
%229 = load i64, i64* %5
%230 = lshr i64 %229, 28
%231 = or i64 %230, 128
%232 = trunc i64 %231 to i8
%233 = load i8*, i8** %4
%234 = getelementptr inbounds i8, i8* %233, i64 4
store i8 %232, i8* %234
%235 = load i64, i64* %5
%236 = lshr i64 %235, 35
%237 = or i64 %236, 128
%238 = trunc i64 %237 to i8
%239 = load i8*, i8** %4
%240 = getelementptr inbounds i8, i8* %239, i64 5
store i8 %238, i8* %240
%241 = load i64, i64* %5
%242 = lshr i64 %241, 42
%243 = or i64 %242, 128
%244 = trunc i64 %243 to i8
%245 = load i8*, i8** %4
%246 = getelementptr inbounds i8, i8* %245, i64 6
store i8 %244, i8* %246
%247 = load i64, i64* %5
%248 = lshr i64 %247, 49
%249 = and i64 %248, 127
%250 = trunc i64 %249 to i8
%251 = load i8*, i8** %4
%252 = getelementptr inbounds i8, i8* %251, i64 7
store i8 %250, i8* %252
store i32 8, i32* %3
br label %307
253: ; preds = %201
%254 = load i64, i64* %5
%255 = or i64 %254, 128
%256 = trunc i64 %255 to i8
%257 = load i8*, i8** %4
%258 = getelementptr inbounds i8, i8* %257, i64 0
store i8 %256, i8* %258
%259 = load i64, i64* %5
%260 = lshr i64 %259, 7
%261 = or i64 %260, 128
%262 = trunc i64 %261 to i8
%263 = load i8*, i8** %4
%264 = getelementptr inbounds i8, i8* %263, i64 1
store i8 %262, i8* %264
%265 = load i64, i64* %5
%266 = lshr i64 %265, 14
%267 = or i64 %266, 128
%268 = trunc i64 %267 to i8
%269 = load i8*, i8** %4
%270 = getelementptr inbounds i8, i8* %269, i64 2
store i8 %268, i8* %270
%271 = load i64, i64* %5
%272 = lshr i64 %271, 21
%273 = or i64 %272, 128
%274 = trunc i64 %273 to i8
%275 = load i8*, i8** %4
%276 = getelementptr inbounds i8, i8* %275, i64 3
store i8 %274, i8* %276
%277 = load i64, i64* %5
%278 = lshr i64 %277, 28
%279 = or i64 %278, 128
%280 = trunc i64 %279 to i8
%281 = load i8*, i8** %4
%282 = getelementptr inbounds i8, i8* %281, i64 4
store i8 %280, i8* %282
%283 = load i64, i64* %5
%284 = lshr i64 %283, 35
%285 = or i64 %284, 128
%286 = trunc i64 %285 to i8
%287 = load i8*, i8** %4
%288 = getelementptr inbounds i8, i8* %287, i64 5
store i8 %286, i8* %288
%289 = load i64, i64* %5
%290 = lshr i64 %289, 42
%291 = or i64 %290, 128
%292 = trunc i64 %291 to i8
%293 = load i8*, i8** %4
%294 = getelementptr inbounds i8, i8* %293, i64 6
store i8 %292, i8* %294
%295 = load i64, i64* %5
%296 = lshr i64 %295, 49
%297 = or i64 %296, 128
%298 = trunc i64 %297 to i8
%299 = load i8*, i8** %4
%300 = getelementptr inbounds i8, i8* %299, i64 7
store i8 %298, i8* %300
%301 = load i64, i64* %5
%302 = lshr i64 %301, 56
%303 = and i64 %302, 255
%304 = trunc i64 %303 to i8
%305 = load i8*, i8** %4
%306 = getelementptr inbounds i8, i8* %305, i64 8
store i8 %304, i8* %306
store i32 9, i32* %3
br label %307
307: ; preds = %253, %205, %159, %119, %85, %57, %35, %19, %9
%308 = load i32, i32* %3
ret i32 %308
}

LLVM IR (-O2):
define i32 @gator_write_packed_int64(i8* writeonly %0, i64 %1) {
%3 = icmp ult i64 %1, 128
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = trunc i64 %1 to i8
store i8 %5, i8* %0
br label %152
6: ; preds = %2
%7 = icmp ult i64 %1, 16384
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = trunc i64 %1 to i8
%10 = or i8 %9, -128
store i8 %10, i8* %0
%11 = lshr i64 %1, 7
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %12, i8* %13
br label %152
14: ; preds = %6
%15 = icmp ult i64 %1, 2097152
br i1 %15, label %16, label %26
16: ; preds = %14
%17 = trunc i64 %1 to i8
%18 = or i8 %17, -128
store i8 %18, i8* %0
%19 = lshr i64 %1, 7
%20 = trunc i64 %19 to i8
%21 = or i8 %20, -128
%22 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %21, i8* %22
%23 = lshr i64 %1, 14
%24 = trunc i64 %23 to i8
%25 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %24, i8* %25
br label %152
26: ; preds = %14
%27 = icmp ult i64 %1, 268435456
br i1 %27, label %28, label %42
28: ; preds = %26
%29 = trunc i64 %1 to i8
%30 = or i8 %29, -128
store i8 %30, i8* %0
%31 = lshr i64 %1, 7
%32 = trunc i64 %31 to i8
%33 = or i8 %32, -128
%34 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %33, i8* %34
%35 = lshr i64 %1, 14
%36 = trunc i64 %35 to i8
%37 = or i8 %36, -128
%38 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %37, i8* %38
%39 = lshr i64 %1, 21
%40 = trunc i64 %39 to i8
%41 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %40, i8* %41
br label %152
42: ; preds = %26
%43 = icmp ult i64 %1, 34359738368
br i1 %43, label %44, label %62
44: ; preds = %42
%45 = trunc i64 %1 to i8
%46 = or i8 %45, -128
store i8 %46, i8* %0
%47 = lshr i64 %1, 7
%48 = trunc i64 %47 to i8
%49 = or i8 %48, -128
%50 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %49, i8* %50
%51 = lshr i64 %1, 14
%52 = trunc i64 %51 to i8
%53 = or i8 %52, -128
%54 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %53, i8* %54
%55 = lshr i64 %1, 21
%56 = trunc i64 %55 to i8
%57 = or i8 %56, -128
%58 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %57, i8* %58
%59 = lshr i64 %1, 28
%60 = trunc i64 %59 to i8
%61 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %60, i8* %61
br label %152
62: ; preds = %42
%63 = icmp ult i64 %1, 4398046511104
br i1 %63, label %64, label %86
64: ; preds = %62
%65 = trunc i64 %1 to i8
%66 = or i8 %65, -128
store i8 %66, i8* %0
%67 = lshr i64 %1, 7
%68 = trunc i64 %67 to i8
%69 = or i8 %68, -128
%70 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %69, i8* %70
%71 = lshr i64 %1, 14
%72 = trunc i64 %71 to i8
%73 = or i8 %72, -128
%74 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %73, i8* %74
%75 = lshr i64 %1, 21
%76 = trunc i64 %75 to i8
%77 = or i8 %76, -128
%78 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %77, i8* %78
%79 = lshr i64 %1, 28
%80 = trunc i64 %79 to i8
%81 = or i8 %80, -128
%82 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %81, i8* %82
%83 = lshr i64 %1, 35
%84 = trunc i64 %83 to i8
%85 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %84, i8* %85
br label %152
86: ; preds = %62
%87 = icmp ult i64 %1, 562949953421312
br i1 %87, label %88, label %114
88: ; preds = %86
%89 = trunc i64 %1 to i8
%90 = or i8 %89, -128
store i8 %90, i8* %0
%91 = lshr i64 %1, 7
%92 = trunc i64 %91 to i8
%93 = or i8 %92, -128
%94 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %93, i8* %94
%95 = lshr i64 %1, 14
%96 = trunc i64 %95 to i8
%97 = or i8 %96, -128
%98 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %97, i8* %98
%99 = lshr i64 %1, 21
%100 = trunc i64 %99 to i8
%101 = or i8 %100, -128
%102 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %101, i8* %102
%103 = lshr i64 %1, 28
%104 = trunc i64 %103 to i8
%105 = or i8 %104, -128
%106 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %105, i8* %106
%107 = lshr i64 %1, 35
%108 = trunc i64 %107 to i8
%109 = or i8 %108, -128
%110 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %109, i8* %110
%111 = lshr i64 %1, 42
%112 = trunc i64 %111 to i8
%113 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %112, i8* %113
br label %152
114: ; preds = %86
%115 = icmp ult i64 %1, 72057594037927936
%116 = trunc i64 %1 to i8
%117 = or i8 %116, -128
store i8 %117, i8* %0
%118 = lshr i64 %1, 7
%119 = trunc i64 %118 to i8
%120 = or i8 %119, -128
%121 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %120, i8* %121
%122 = lshr i64 %1, 14
%123 = trunc i64 %122 to i8
%124 = or i8 %123, -128
%125 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %124, i8* %125
%126 = lshr i64 %1, 21
%127 = trunc i64 %126 to i8
%128 = or i8 %127, -128
%129 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %128, i8* %129
%130 = lshr i64 %1, 28
%131 = trunc i64 %130 to i8
%132 = or i8 %131, -128
%133 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %132, i8* %133
%134 = lshr i64 %1, 35
%135 = trunc i64 %134 to i8
%136 = or i8 %135, -128
%137 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %136, i8* %137
%138 = lshr i64 %1, 42
%139 = trunc i64 %138 to i8
%140 = or i8 %139, -128
%141 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %140, i8* %141
%142 = lshr i64 %1, 49
%143 = trunc i64 %142 to i8
br i1 %115, label %144, label %146
144: ; preds = %114
%145 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %143, i8* %145
br label %152
146: ; preds = %114
%147 = or i8 %143, -128
%148 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %147, i8* %148
%149 = lshr i64 %1, 56
%150 = trunc i64 %149 to i8
%151 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %150, i8* %151
br label %152
152: ; preds = %146, %144, %88, %64, %44, %28, %16, %8, %4
%153 = phi i32 [ 1, %4 ], [ 2, %8 ], [ 3, %16 ], [ 4, %28 ], [ 5, %44 ], [ 6, %64 ], [ 7, %88 ], [ 8, %144 ], [ 9, %146 ]
ret i32 %153
}