#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 size_t uint8_t;
typedef size_t uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
size_t fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(size_t *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(size_t *, size_t, int, int /*<<< orphan*/ *);
size_t *malloc(size_t);
int /*<<< orphan*/ memset(size_t *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage: %s <input> <output>\nCurrently only 4-to-2-bit supported\n",
           argv[0]);
  }
  FILE *in, *out;
  size_t in_off = 0, out_off = 0;
  uint8_t pixperbyte, mask_shift, mask, depth, planeidx;
  uint8_t current_pixel, current_in_tile;
  int i, j;
  if ((in = fopen(argv[1], "rb")) == NULL) {
    perror("Could not open input file");
    return 1;
  }
  if ((out = fopen(argv[2], "wb")) == NULL) {
    perror("Could not open output file");
    return 1;
  }
  size_t fsize, dsize;
  fseek(in, 0, SEEK_END);
  fsize = ftell(in);
  fseek(in, 0, SEEK_SET);
  pixperbyte = 1;
  mask_shift = 0;
  mask = 0xff;
  depth = 8;
  dsize = fsize * depth / (8 / pixperbyte);
  uint16_t *obuf;
  if ((obuf = malloc(dsize)) == NULL) {
    perror("Could not reserve memory");
    fclose(out);
    fclose(in);
    return 1;
  }
  memset(obuf, 0, dsize);
  while (!feof(in)) {
    uint8_t chunk = fgetc(in);
    printf("%lX\n", (long unsigned int)out_off);
    for (i = 0; i < pixperbyte; i++) {
      current_pixel = (in_off * pixperbyte + i) % 8;
      current_in_tile = (in_off * pixperbyte + i) % 64;
      if (!current_pixel && in_off) {
        out_off++;
      }
      if (!current_in_tile && in_off) {
        out_off += (depth / 2 - 1) * 8;
      }
      uint8_t bits = (chunk & mask);
      chunk >>= mask_shift;
      for (planeidx = 0; planeidx < depth / 2; planeidx++) {
        for (j = 0; j < 2; j++) {
          obuf[out_off + planeidx * 8] |=
              ((bits & (1 << (j + 2 * planeidx))) >>
               (j + 2 * planeidx) << ((8 * j + 7) - current_pixel));
        }
      }
    }
    in_off++;
  }
  fwrite(obuf, dsize, 1, out);
  free(obuf);
  fclose(out);
  fclose(in);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f8 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe29(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1242 <main+0x82>
lea    0xe12(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3a7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    127c <main+0xbc>
lea    0xdf5(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3a7>
mov    -0x18(%rbp),%rdi
mov    0x2d61(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d30(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
movq   $0x1,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0xff,-0x48(%rbp)
movq   $0x8,-0x50(%rbp)
mov    -0x78(%rbp),%rax
imul   -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    $0x8,%eax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x38(%rbp)
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    1345 <main+0x185>
lea    0xd59(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1567 <main+0x3a7>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rdx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1375 <main+0x1b5>
jmp    1530 <main+0x370>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %rax,-0x90(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x6c(%rbp)
movslq -0x6c(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    151f <main+0x35f>
mov    -0x28(%rbp),%rax
imul   -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
add    %rcx,%rax
and    $0x7,%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
imul   -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
add    %rcx,%rax
and    $0x3f,%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    13fe <main+0x23e>
cmpq   $0x0,-0x28(%rbp)
je     13fe <main+0x23e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    142c <main+0x26c>
cmpq   $0x0,-0x28(%rbp)
je     142c <main+0x26c>
mov    -0x50(%rbp),%rax
shr    $0x1,%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x90(%rbp),%rax
and    -0x48(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x90(%rbp),%rax
shr    %cl,%rax
mov    %rax,-0x90(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    150c <main+0x34c>
movl   $0x0,-0x70(%rbp)
cmpl   $0x2,-0x70(%rbp)
jge    14f6 <main+0x336>
mov    -0x98(%rbp),%rdx
movslq -0x70(%rbp),%rax
mov    -0x58(%rbp),%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
and    %rax,%rdx
movslq -0x70(%rbp),%rcx
mov    -0x58(%rbp),%rax
shl    $0x1,%rax
add    %rax,%rcx
shr    %cl,%rdx
mov    -0x70(%rbp),%eax
shl    $0x3,%eax
add    $0x7,%eax
movslq %eax,%rcx
sub    -0x60(%rbp),%rcx
shl    %cl,%rdx
mov    -0x88(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x58(%rbp),%rsi
shl    $0x3,%rsi
add    %rsi,%rcx
or     (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1477 <main+0x2b7>
jmp    14fb <main+0x33b>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    145b <main+0x29b>
jmp    1511 <main+0x351>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    139e <main+0x1de>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1357 <main+0x197>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     11e8 <main+0x28>
mov    0x0(%rbp),%rsi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1412 <main+0x252>
mov    %rax,%r14
mov    0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     141b <main+0x25b>
mov    %rax,%r15
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbp
mov    0x2d93(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
movabs $0x1fffffffffffffff,%rbx
ff ff 1f
and    %rbp,%rbx
mov    %rbx,%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     142e <main+0x26e>
mov    %rax,%rbp
mov    %r15,0x8(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,(%rsp)
mov    %rbx,%rdx
call   1060 <memset@plt>
mov    %r14,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    13d0 <main+0x210>
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    %r14,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13d,%r15d
and    $0x7,%r15d
test   %r15,%r15
sete   %al
test   %r13,%r13
setne  %cl
and    %al,%cl
movzbl %cl,%eax
lea    (%rbx,%rax,1),%rcx
test   $0x3f,%r13b
lea    0x18(%rbx,%rax,1),%r12
cmovne %rcx,%r12
test   %r13,%r13
cmove  %rcx,%r12
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %rax,%r14
lea    0xda2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edx
and    $0x1,%edx
mov    %r15d,%eax
xor    $0x7,%al
mov    %eax,%ecx
shl    %cl,%rdx
mov    %r14d,%esi
shr    %esi
and    $0x1,%esi
xor    $0xf,%r15b
mov    %r15d,%ecx
shl    %cl,%rsi
or     0x0(%rbp,%r12,8),%rdx
or     %rdx,%rsi
mov    %r14d,%edx
shr    $0x2,%edx
and    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%rdx
mov    %rsi,0x0(%rbp,%r12,8)
or     0x40(%rbp,%r12,8),%rdx
mov    %r14d,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r15d,%ecx
shl    %cl,%rsi
or     %rdx,%rsi
mov    %rsi,0x40(%rbp,%r12,8)
mov    %r14d,%edx
shr    $0x4,%edx
and    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%rdx
mov    %r14d,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r15d,%ecx
shl    %cl,%rsi
or     0x80(%rbp,%r12,8),%rdx
or     %rdx,%rsi
mov    %r14d,%edx
shr    $0x6,%edx
and    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%rdx
mov    %rsi,0x80(%rbp,%r12,8)
or     0xc0(%rbp,%r12,8),%rdx
shr    $0x7,%r14d
and    $0x1,%r14d
mov    %r15d,%ecx
shl    %cl,%r14
or     %rdx,%r14
mov    %r14,0xc0(%rbp,%r12,8)
mov    0x10(%rsp),%r14
add    $0x1,%r13
mov    %r14,%rdi
call   1090 <feof@plt>
mov    %r12,%rbx
test   %eax,%eax
je     12b0 <main+0xf0>
mov    %rbp,%rdi
mov    (%rsp),%rsi
mov    $0x1,%edx
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc2a(%rip),%rdi
jmp    1422 <main+0x262>
lea    0xc3e(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%eax
jmp    1403 <main+0x243>
lea    0xc46(%rip),%rdi
call   10d0 <perror@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    1403 <main+0x243>

LLVM IR (-O0):
@.str = [64 x i8] c"Usage: %s <input> <output>\0ACurrently only 4-to-2-bit supported\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Could not open input file\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [27 x i8] c"Could not open output file\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [25 x i8] c"Could not reserve memory\00"
@.str.6 = [5 x i8] c"%lX\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64*
%22 = alloca i64
%23 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %26, %2
store i64 0, i64* %8
store i64 0, i64* %9
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %35, i32** %6
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %199
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %7
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %199
47: ; preds = %39
%48 = load i32*, i32** %6
%49 = load i32, i32* @SEEK_END
%50 = call i32 @fseek(i32* %48, i32 0, i32 %49)
%51 = load i32*, i32** %6
%52 = call i64 @ftell(i32* %51)
store i64 %52, i64* %19
%53 = load i32*, i32** %6
%54 = load i32, i32* @SEEK_SET
%55 = call i32 @fseek(i32* %53, i32 0, i32 %54)
store i64 1, i64* %10
store i64 0, i64* %11
store i64 255, i64* %12
store i64 8, i64* %13
%56 = load i64, i64* %19
%57 = load i64, i64* %13
%58 = mul i64 %56, %57
%59 = load i64, i64* %10
%60 = udiv i64 8, %59
%61 = udiv i64 %58, %60
store i64 %61, i64* %20
%62 = load i64, i64* %20
%63 = call i64* @malloc(i64 %62)
store i64* %63, i64** %21
%64 = icmp eq i64* %63, null
br i1 %64, label %65, label %71
65: ; preds = %47
%66 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%67 = load i32*, i32** %7
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
store i32 1, i32* %3
br label %199
71: ; preds = %47
%72 = load i64*, i64** %21
%73 = load i64, i64* %20
%74 = call i32 @memset(i64* %72, i32 0, i64 %73)
br label %75
75: ; preds = %185, %71
%76 = load i32*, i32** %6
%77 = call i32 @feof(i32* %76)
%78 = icmp ne i32 %77, 0
%79 = xor i1 %78, true
br i1 %79, label %80, label %188
80: ; preds = %75
%81 = load i32*, i32** %6
%82 = call i64 @fgetc(i32* %81)
store i64 %82, i64* %22
%83 = load i64, i64* %9
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 %83)
store i32 0, i32* %17
br label %85
85: ; preds = %182, %80
%86 = load i32, i32* %17
%87 = sext i32 %86 to i64
%88 = load i64, i64* %10
%89 = icmp ult i64 %87, %88
br i1 %89, label %90, label %185
90: ; preds = %85
%91 = load i64, i64* %8
%92 = load i64, i64* %10
%93 = mul i64 %91, %92
%94 = load i32, i32* %17
%95 = sext i32 %94 to i64
%96 = add i64 %93, %95
%97 = urem i64 %96, 8
store i64 %97, i64* %15
%98 = load i64, i64* %8
%99 = load i64, i64* %10
%100 = mul i64 %98, %99
%101 = load i32, i32* %17
%102 = sext i32 %101 to i64
%103 = add i64 %100, %102
%104 = urem i64 %103, 64
store i64 %104, i64* %16
%105 = load i64, i64* %15
%106 = icmp ne i64 %105, 0
br i1 %106, label %113, label %107
107: ; preds = %90
%108 = load i64, i64* %8
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load i64, i64* %9
%112 = add i64 %111, 1
store i64 %112, i64* %9
br label %113
113: ; preds = %110, %107, %90
%114 = load i64, i64* %16
%115 = icmp ne i64 %114, 0
br i1 %115, label %126, label %116
116: ; preds = %113
%117 = load i64, i64* %8
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %126
119: ; preds = %116
%120 = load i64, i64* %13
%121 = udiv i64 %120, 2
%122 = sub i64 %121, 1
%123 = mul i64 %122, 8
%124 = load i64, i64* %9
%125 = add i64 %124, %123
store i64 %125, i64* %9
br label %126
126: ; preds = %119, %116, %113
%127 = load i64, i64* %22
%128 = load i64, i64* %12
%129 = and i64 %127, %128
store i64 %129, i64* %23
%130 = load i64, i64* %11
%131 = load i64, i64* %22
%132 = lshr i64 %131, %130
store i64 %132, i64* %22
store i64 0, i64* %14
br label %133
133: ; preds = %178, %126
%134 = load i64, i64* %14
%135 = load i64, i64* %13
%136 = udiv i64 %135, 2
%137 = icmp ult i64 %134, %136
br i1 %137, label %138, label %181
138: ; preds = %133
store i32 0, i32* %18
br label %139
139: ; preds = %174, %138
%140 = load i32, i32* %18
%141 = icmp slt i32 %140, 2
br i1 %141, label %142, label %177
142: ; preds = %139
%143 = load i64, i64* %23
%144 = load i32, i32* %18
%145 = sext i32 %144 to i64
%146 = load i64, i64* %14
%147 = mul i64 2, %146
%148 = add i64 %145, %147
%149 = trunc i64 %148 to i32
%150 = shl i32 1, %149
%151 = sext i32 %150 to i64
%152 = and i64 %143, %151
%153 = load i32, i32* %18
%154 = sext i32 %153 to i64
%155 = load i64, i64* %14
%156 = mul i64 2, %155
%157 = add i64 %154, %156
%158 = lshr i64 %152, %157
%159 = load i32, i32* %18
%160 = mul nsw i32 8, %159
%161 = add nsw i32 %160, 7
%162 = sext i32 %161 to i64
%163 = load i64, i64* %15
%164 = sub i64 %162, %163
%165 = shl i64 %158, %164
%166 = load i64*, i64** %21
%167 = load i64, i64* %9
%168 = load i64, i64* %14
%169 = mul i64 %168, 8
%170 = add i64 %167, %169
%171 = getelementptr inbounds i64, i64* %166, i64 %170
%172 = load i64, i64* %171
%173 = or i64 %172, %165
store i64 %173, i64* %171
br label %174
174: ; preds = %142
%175 = load i32, i32* %18
%176 = add nsw i32 %175, 1
store i32 %176, i32* %18
br label %139
177: ; preds = %139
br label %178
178: ; preds = %177
%179 = load i64, i64* %14
%180 = add i64 %179, 1
store i64 %180, i64* %14
br label %133
181: ; preds = %133
br label %182
182: ; preds = %181
%183 = load i32, i32* %17
%184 = add nsw i32 %183, 1
store i32 %184, i32* %17
br label %85
185: ; preds = %85
%186 = load i64, i64* %8
%187 = add i64 %186, 1
store i64 %187, i64* %8
br label %75
188: ; preds = %75
%189 = load i64*, i64** %21
%190 = load i64, i64* %20
%191 = load i32*, i32** %7
%192 = call i32 @fwrite(i64* %189, i64 %190, i32 1, i32* %191)
%193 = load i64*, i64** %21
%194 = call i32 @free(i64* %193)
%195 = load i32*, i32** %7
%196 = call i32 @fclose(i32* %195)
%197 = load i32*, i32** %6
%198 = call i32 @fclose(i32* %197)
br label %199
199: ; preds = %188, %65, %45, %37
%200 = load i32, i32* %3
ret i32 %200
}

LLVM IR (-O2):
@.str = [64 x i8] c"Usage: %s <input> <output>\0ACurrently only 4-to-2-bit supported\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Could not open input file\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [27 x i8] c"Could not open output file\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [25 x i8] c"Could not reserve memory\00"
@.str.6 = [5 x i8] c"%lX\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %106
14: ; preds = %7
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %106
21: ; preds = %14
%22 = load i32, i32* @SEEK_END
%23 = tail call i32 @fseek(i32* %10, i32 0, i32 %22)
%24 = tail call i64 @ftell(i32* %10)
%25 = load i32, i32* @SEEK_SET
%26 = tail call i32 @fseek(i32* %10, i32 0, i32 %25)
%27 = and i64 %24, 2305843009213693951
%28 = tail call i64* @malloc(i64 %27)
%29 = icmp eq i64* %28, null
br i1 %29, label %30, label %34
30: ; preds = %21
%31 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%32 = tail call i32 @fclose(i32* %17)
%33 = tail call i32 @fclose(i32* %10)
br label %106
34: ; preds = %21
%35 = tail call i32 @memset(i64* %28, i32 0, i64 %27)
%36 = tail call i32 @feof(i32* %10)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %101
38: ; preds = %34, %38
%39 = phi i64 [ %98, %38 ], [ 0, %34 ]
%40 = phi i64 [ %53, %38 ], [ 0, %34 ]
%41 = tail call i64 @fgetc(i32* %10)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 %40)
%43 = and i64 %39, 7
%44 = and i64 %39, 63
%45 = icmp eq i64 %43, 0
%46 = icmp ne i64 %39, 0
%47 = and i1 %46, %45
%48 = zext i1 %47 to i64
%49 = icmp eq i64 %44, 0
%50 = and i1 %46, %49
%51 = add i64 %40, %48
%52 = add i64 %51, 24
%53 = select i1 %50, i64 %52, i64 %51
%54 = getelementptr inbounds i64, i64* %28, i64 %53
%55 = load i64, i64* %54
%56 = and i64 %41, 1
%57 = xor i64 %43, 7
%58 = shl nuw i64 %56, %57
%59 = or i64 %55, %58
%60 = lshr i64 %41, 1
%61 = and i64 %60, 1
%62 = xor i64 %43, 15
%63 = shl nuw i64 %61, %62
%64 = or i64 %59, %63
store i64 %64, i64* %54
%65 = add i64 %53, 8
%66 = getelementptr inbounds i64, i64* %28, i64 %65
%67 = load i64, i64* %66
%68 = lshr i64 %41, 2
%69 = and i64 %68, 1
%70 = shl nuw i64 %69, %57
%71 = or i64 %67, %70
%72 = lshr i64 %41, 3
%73 = and i64 %72, 1
%74 = shl nuw i64 %73, %62
%75 = or i64 %71, %74
store i64 %75, i64* %66
%76 = add i64 %53, 16
%77 = getelementptr inbounds i64, i64* %28, i64 %76
%78 = load i64, i64* %77
%79 = lshr i64 %41, 4
%80 = and i64 %79, 1
%81 = shl nuw i64 %80, %57
%82 = or i64 %78, %81
%83 = lshr i64 %41, 5
%84 = and i64 %83, 1
%85 = shl nuw i64 %84, %62
%86 = or i64 %82, %85
store i64 %86, i64* %77
%87 = add i64 %53, 24
%88 = getelementptr inbounds i64, i64* %28, i64 %87
%89 = load i64, i64* %88
%90 = lshr i64 %41, 6
%91 = and i64 %90, 1
%92 = shl nuw i64 %91, %57
%93 = or i64 %89, %92
%94 = lshr i64 %41, 7
%95 = and i64 %94, 1
%96 = shl nuw i64 %95, %62
%97 = or i64 %93, %96
store i64 %97, i64* %88
%98 = add i64 %39, 1
%99 = tail call i32 @feof(i32* %10)
%100 = icmp eq i32 %99, 0
br i1 %100, label %38, label %101
101: ; preds = %38, %34
%102 = tail call i32 @fwrite(i64* %28, i64 %27, i32 1, i32* %17)
%103 = tail call i32 @free(i64* %28)
%104 = tail call i32 @fclose(i32* %17)
%105 = tail call i32 @fclose(i32* %10)
br label %106
106: ; preds = %30, %101, %19, %12
%107 = phi i32 [ 1, %12 ], [ 1, %19 ], [ 1, %30 ], [ 0, %101 ]
ret i32 %107
}