#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int readhead(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  unsigned char rotated[256];
  unsigned char buffer[1024];
  unsigned char r, t, b;
  int length, i, bytesread;
  FILE *fi, *fo;
  if (argc < 3) {
    printf("Usage: promgen [-r] <infile> <outfile>\n");
    exit(1);
  }
  int rotate = 1;
  int ar = 1;
  if (strcmp(argv[1], "-r") == 0) {
    rotate = 0;
    ar++;
  }
  fi = fopen(argv[ar++], "rb");
  if (!fi) {
    printf("Couldn't open file '%s' for reading.\n", argv[1]);
    exit(2);
  }
  fo = fopen(argv[ar++], "wb");
  if (!fo) {
    printf("Couldn't open file '%s' for writing.\n", argv[2]);
    fclose(fi);
    exit(3);
  }
  for (i = 0; i < 256; i++) {
    r = 0;
    t = (unsigned char)i;
    for (b = 0; b < 8; b++) {
      r <<= 1;
      r |= (t & 1);
      t >>= 1;
    }
    rotated[i] = r;
  }
  if ((length = readhead(fi)) < 0) {
    printf("Parsing of header unsuccessful. Invalid bitfile?\n");
    exit(11);
  }
  do {
    bytesread = fread(buffer, 1, 1024, fi);
    if (rotate) {
      for (i = 0; i < bytesread; i++) {
        buffer[i] = rotated[buffer[i]];
      }
    }
    fwrite(buffer, 1, bytesread, fo);
    length -= bytesread;
  } while (length && bytesread);
  fclose(fo);
  fclose(fi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x540,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11bb <main+0x3b>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x1,-0x534(%rbp)
movl   $0x1,-0x538(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1206 <main+0x86>
movl   $0x0,-0x534(%rbp)
mov    -0x538(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x538(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x538(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x538(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe02(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x528(%rbp)
cmpq   $0x0,-0x528(%rbp)
jne    1263 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x538(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x538(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdce(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x530(%rbp)
cmpq   $0x0,-0x530(%rbp)
jne    12cc <main+0x14c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x528(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x3,%edi
call   1090 <exit@plt>
movl   $0x0,-0x51c(%rbp)
cmpl   $0x100,-0x51c(%rbp)
jge    1384 <main+0x204>
movb   $0x0,-0x511(%rbp)
mov    -0x51c(%rbp),%eax
mov    %al,-0x512(%rbp)
movb   $0x0,-0x513(%rbp)
movzbl -0x513(%rbp),%eax
cmp    $0x8,%eax
jge    135c <main+0x1dc>
movzbl -0x511(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x511(%rbp)
movzbl -0x512(%rbp),%ecx
and    $0x1,%ecx
movzbl -0x511(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x511(%rbp)
movzbl -0x512(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x512(%rbp)
mov    -0x513(%rbp),%al
add    $0x1,%al
mov    %al,-0x513(%rbp)
jmp    1300 <main+0x180>
mov    -0x511(%rbp),%cl
movslq -0x51c(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x51c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x51c(%rbp)
jmp    12d6 <main+0x156>
mov    -0x528(%rbp),%rdi
call   1060 <readhead@plt>
mov    %eax,-0x518(%rbp)
cmp    $0x0,%eax
jge    13b7 <main+0x237>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xb,%edi
call   1090 <exit@plt>
jmp    13bc <main+0x23c>
lea    -0x510(%rbp),%rdi
mov    -0x528(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x520(%rbp)
cmpl   $0x0,-0x534(%rbp)
je     1445 <main+0x2c5>
movl   $0x0,-0x51c(%rbp)
mov    -0x51c(%rbp),%eax
cmp    -0x520(%rbp),%eax
jge    1440 <main+0x2c0>
movslq -0x51c(%rbp),%rax
movzbl -0x510(%rbp,%rax,1),%eax
ff
mov    -0x110(%rbp,%rax,1),%cl
movslq -0x51c(%rbp),%rax
mov    %cl,-0x510(%rbp,%rax,1)
mov    -0x51c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x51c(%rbp)
jmp    13f6 <main+0x276>
jmp    1445 <main+0x2c5>
lea    -0x510(%rbp),%rdi
mov    -0x520(%rbp),%edx
mov    -0x530(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
mov    -0x520(%rbp),%ecx
mov    -0x518(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x518(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x518(%rbp)
mov    %al,-0x539(%rbp)
je     149c <main+0x31c>
cmpl   $0x0,-0x520(%rbp)
setne  %al
mov    %al,-0x539(%rbp)
mov    -0x539(%rbp),%al
test   $0x1,%al
jne    13bc <main+0x23c>
mov    -0x530(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x528(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x540,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x518,%rsp
cmp    $0x2,%edi
jle    13fa <main+0x26a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1080 <strcmp@plt>
mov    %rax,0x8(%rsp)
cmp    $0x1,%rax
mov    $0x1,%ebp
adc    $0x0,%ebp
mov    (%rbx,%rbp,8),%rdi
lea    0xe7a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1410 <main+0x280>
mov    %rax,%r15
mov    %ebp,%eax
mov    0x8(%rbx,%rax,8),%rdi
lea    0xe84(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     142c <main+0x29c>
mov    %rax,%r12
movdqa 0xdef(%rip),%xmm0
xor    %eax,%eax
movdqa 0xdf5(%rip),%xmm1
movdqa 0xdfd(%rip),%xmm2
movdqa 0xe05(%rip),%xmm3
movdqa 0xe0d(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm5
psrlw  $0x4,%xmm5
pand   %xmm1,%xmm5
movdqa %xmm0,%xmm6
pand   %xmm1,%xmm6
psllw  $0x4,%xmm6
por    %xmm5,%xmm6
movdqa %xmm6,%xmm5
psrlw  $0x2,%xmm5
pand   %xmm2,%xmm5
pand   %xmm2,%xmm6
psllw  $0x2,%xmm6
por    %xmm5,%xmm6
movdqa %xmm6,%xmm5
psrlw  $0x1,%xmm5
pand   %xmm3,%xmm5
pand   %xmm3,%xmm6
paddb  %xmm6,%xmm6
por    %xmm5,%xmm6
movdqa %xmm6,0x10(%rsp,%rax,1)
add    $0x10,%rax
paddb  %xmm4,%xmm0
cmp    $0x100,%rax
jne    1240 <main+0xb0>
mov    %r15,%rdi
call   1070 <readhead@plt>
test   %eax,%eax
js     1450 <main+0x2c0>
mov    %eax,%ebp
lea    0x110(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %eax,%r14d
cmpq   $0x0,0x8(%rsp)
je     13b5 <main+0x225>
test   %r14d,%r14d
jle    13b5 <main+0x225>
mov    %r14d,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x3,%eax
cmp    $0x3,%rdx
jae    1320 <main+0x190>
xor    %edx,%edx
jmp    1389 <main+0x1f9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
and    $0xfffffffc,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x110(%rsp,%rdx,1),%esi
movzbl 0x10(%rsp,%rsi,1),%ebx
mov    %bl,0x110(%rsp,%rdx,1)
movzbl 0x111(%rsp,%rdx,1),%esi
movzbl 0x10(%rsp,%rsi,1),%ebx
mov    %bl,0x111(%rsp,%rdx,1)
movzbl 0x112(%rsp,%rdx,1),%esi
movzbl 0x10(%rsp,%rsi,1),%ebx
mov    %bl,0x112(%rsp,%rdx,1)
movzbl 0x113(%rsp,%rdx,1),%esi
movzbl 0x10(%rsp,%rsi,1),%ebx
mov    %bl,0x113(%rsp,%rdx,1)
add    $0x4,%rdx
cmp    %rdx,%rcx
jne    1330 <main+0x1a0>
test   %rax,%rax
je     13b5 <main+0x225>
lea    (%rsp,%rdx,1),%rcx
add    $0x110,%rcx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movzbl (%rcx,%rdx,1),%esi
movzbl 0x10(%rsp,%rsi,1),%ebx
mov    %bl,(%rcx,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    13a0 <main+0x210>
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r12,%rcx
call   10b0 <fwrite@plt>
test   %r14d,%r14d
je     13d6 <main+0x246>
sub    %r14d,%ebp
jne    12d0 <main+0x140>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x8(%rbx),%rsi
lea    0xc3b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
mov    0x10(%rbx),%rsi
lea    0xc48(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0x3,%edi
call   10a0 <exit@plt>
lea    0xc4e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xb,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Usage: promgen [-r] <infile> <outfile>\0A\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [38 x i8] c"Couldn't open file '%s' for reading.\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [38 x i8] c"Couldn't open file '%s' for writing.\0A\00"
@.str.6 = [50 x i8] c"Parsing of header unsuccessful. Invalid bitfile?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
store i32 1, i32* %16
store i32 1, i32* %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
store i32 0, i32* %16
%30 = load i32, i32* %17
%31 = add nsw i32 %30, 1
store i32 %31, i32* %17
br label %32
32: ; preds = %29, %23
%33 = load i8**, i8*** %5
%34 = load i32, i32* %17
%35 = add nsw i32 %34, 1
store i32 %35, i32* %17
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %39, i32** %14
%40 = load i32*, i32** %14
%41 = icmp ne i32* %40, null
br i1 %41, label %48, label %42
42: ; preds = %32
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = call i32 @exit(i32 2)
unreachable
48: ; preds = %32
%49 = load i8**, i8*** %5
%50 = load i32, i32* %17
%51 = add nsw i32 %50, 1
store i32 %51, i32* %17
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
%54 = load i8*, i8** %53
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %55, i32** %15
%56 = load i32*, i32** %15
%57 = icmp ne i32* %56, null
br i1 %57, label %66, label %58
58: ; preds = %48
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %61)
%63 = load i32*, i32** %14
%64 = call i32 @fclose(i32* %63)
%65 = call i32 @exit(i32 3)
unreachable
66: ; preds = %48
store i32 0, i32* %12
br label %67
67: ; preds = %101, %66
%68 = load i32, i32* %12
%69 = icmp slt i32 %68, 256
br i1 %69, label %70, label %104
70: ; preds = %67
store i8 0, i8* %8
%71 = load i32, i32* %12
%72 = trunc i32 %71 to i8
store i8 %72, i8* %9
store i8 0, i8* %10
br label %73
73: ; preds = %93, %70
%74 = load i8, i8* %10
%75 = zext i8 %74 to i32
%76 = icmp slt i32 %75, 8
br i1 %76, label %77, label %96
77: ; preds = %73
%78 = load i8, i8* %8
%79 = zext i8 %78 to i32
%80 = shl i32 %79, 1
%81 = trunc i32 %80 to i8
store i8 %81, i8* %8
%82 = load i8, i8* %9
%83 = zext i8 %82 to i32
%84 = and i32 %83, 1
%85 = load i8, i8* %8
%86 = zext i8 %85 to i32
%87 = or i32 %86, %84
%88 = trunc i32 %87 to i8
store i8 %88, i8* %8
%89 = load i8, i8* %9
%90 = zext i8 %89 to i32
%91 = ashr i32 %90, 1
%92 = trunc i32 %91 to i8
store i8 %92, i8* %9
br label %93
93: ; preds = %77
%94 = load i8, i8* %10
%95 = add i8 %94, 1
store i8 %95, i8* %10
br label %73
96: ; preds = %73
%97 = load i8, i8* %8
%98 = load i32, i32* %12
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %99
store i8 %97, i8* %100
br label %101
101: ; preds = %96
%102 = load i32, i32* %12
%103 = add nsw i32 %102, 1
store i32 %103, i32* %12
br label %67
104: ; preds = %67
%105 = load i32*, i32** %14
%106 = call i32 @readhead(i32* %105)
store i32 %106, i32* %11
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
%110 = call i32 @exit(i32 11)
unreachable
111: ; preds = %104
br label %112
112: ; preds = %152, %111
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%114 = load i32*, i32** %14
%115 = call i32 @fread(i8* %113, i32 1, i32 1024, i32* %114)
store i32 %115, i32* %13
%116 = load i32, i32* %16
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %138
118: ; preds = %112
store i32 0, i32* %12
br label %119
119: ; preds = %134, %118
%120 = load i32, i32* %12
%121 = load i32, i32* %13
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %137
123: ; preds = %119
%124 = load i32, i32* %12
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %125
%127 = load i8, i8* %126
%128 = zext i8 %127 to i64
%129 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = load i32, i32* %12
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %132
store i8 %130, i8* %133
br label %134
134: ; preds = %123
%135 = load i32, i32* %12
%136 = add nsw i32 %135, 1
store i32 %136, i32* %12
br label %119
137: ; preds = %119
br label %138
138: ; preds = %137, %112
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%140 = load i32, i32* %13
%141 = load i32*, i32** %15
%142 = call i32 @fwrite(i8* %139, i32 1, i32 %140, i32* %141)
%143 = load i32, i32* %13
%144 = load i32, i32* %11
%145 = sub nsw i32 %144, %143
store i32 %145, i32* %11
br label %146
146: ; preds = %138
%147 = load i32, i32* %11
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %146
%150 = load i32, i32* %13
%151 = icmp ne i32 %150, 0
br label %152
152: ; preds = %149, %146
%153 = phi i1 [ false, %146 ], [ %151, %149 ]
br i1 %153, label %112, label %154
154: ; preds = %152
%155 = load i32*, i32** %15
%156 = call i32 @fclose(i32* %155)
%157 = load i32*, i32** %14
%158 = call i32 @fclose(i32* %157)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [38 x i8] c"Couldn't open file '%s' for reading.\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [38 x i8] c"Couldn't open file '%s' for writing.\0A\00"
@str = [49 x i8] c"Parsing of header unsuccessful. Invalid bitfile?\00"
@str.7 = [39 x i8] c"Usage: promgen [-r] <infile> <outfile>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.7, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i32 2, i32 1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %11
%23 = load i8*, i8** %12
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 2)
unreachable
26: ; preds = %11
%27 = add nuw nsw i32 %16, 1
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %42, label %33
33: ; preds = %26, %33
%34 = phi i64 [ %39, %33 ], [ 0, %26 ]
%35 = phi <16 x i8> [ %40, %33 ], [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %26 ]
%36 = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %35)
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %34
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %38
%39 = add nuw i64 %34, 16
%40 = add <16 x i8> %35, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%41 = icmp eq i64 %39, 256
br i1 %41, label %48, label %33
42: ; preds = %26
%43 = getelementptr inbounds i8*, i8** %1, i64 2
%44 = load i8*, i8** %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = tail call i32 @fclose(i32* %20)
%47 = tail call i32 @exit(i32 3)
unreachable
48: ; preds = %33
%49 = tail call i32 @readhead(i32* %20)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%53 = tail call i32 @exit(i32 11)
unreachable
54: ; preds = %48, %109
%55 = phi i32 [ %111, %109 ], [ %49, %48 ]
%56 = call i32 @fread(i8* %6, i32 1, i32 1024, i32* %20)
%57 = icmp slt i32 %56, 1
%58 = or i1 %15, %57
br i1 %58, label %109, label %59
59: ; preds = %54
%60 = zext i32 %56 to i64
%61 = add nsw i64 %60, -1
%62 = and i64 %60, 3
%63 = icmp ult i64 %61, 3
br i1 %63, label %95, label %64
64: ; preds = %59
%65 = and i64 %60, 4294967292
br label %66
66: ; preds = %66, %64
%67 = phi i64 [ 0, %64 ], [ %92, %66 ]
%68 = phi i64 [ 0, %64 ], [ %93, %66 ]
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %67
%70 = load i8, i8* %69
%71 = zext i8 %70 to i64
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %71
%73 = load i8, i8* %72
store i8 %73, i8* %69
%74 = or i64 %67, 1
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = zext i8 %76 to i64
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %77
%79 = load i8, i8* %78
store i8 %79, i8* %75
%80 = or i64 %67, 2
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = zext i8 %82 to i64
%84 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %83
%85 = load i8, i8* %84
store i8 %85, i8* %81
%86 = or i64 %67, 3
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = zext i8 %88 to i64
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %89
%91 = load i8, i8* %90
store i8 %91, i8* %87
%92 = add nuw nsw i64 %67, 4
%93 = add i64 %68, 4
%94 = icmp eq i64 %93, %65
br i1 %94, label %95, label %66
95: ; preds = %66, %59
%96 = phi i64 [ 0, %59 ], [ %92, %66 ]
%97 = icmp eq i64 %62, 0
br i1 %97, label %109, label %98
98: ; preds = %95, %98
%99 = phi i64 [ %106, %98 ], [ %96, %95 ]
%100 = phi i64 [ %107, %98 ], [ 0, %95 ]
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %99
%102 = load i8, i8* %101
%103 = zext i8 %102 to i64
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %103
%105 = load i8, i8* %104
store i8 %105, i8* %101
%106 = add nuw nsw i64 %99, 1
%107 = add i64 %100, 1
%108 = icmp eq i64 %107, %62
br i1 %108, label %109, label %98
109: ; preds = %95, %98, %54
%110 = call i32 @fwrite(i8* %6, i32 1, i32 %56, i32* %31)
%111 = sub nsw i32 %55, %56
%112 = icmp ne i32 %111, 0
%113 = icmp ne i32 %56, 0
%114 = and i1 %113, %112
br i1 %114, label %54, label %115
115: ; preds = %109
%116 = tail call i32 @fclose(i32* %31)
%117 = tail call i32 @fclose(i32* %20)
ret i32 0
}