#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  unsigned char *Buf, *Buf1, *a;
  int BufLen;
  int nbytes, fileLen;
  unsigned long checksum;
  int i;
  if (argc != 4) {
    printf("Usage: mkbl1 <source file> <destination file> <size> \n");
    return -1;
  }
  BufLen = atoi(argv[3]);
  Buf = (char *)malloc(BufLen);
  memset(Buf, 0x00, BufLen);
  Buf1 = (char *)malloc(BufLen);
  memset(Buf1, 0x00, BufLen);
  fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    printf("source file open error\n");
    free(Buf);
    return -1;
  }
  fseek(fp, 0L, SEEK_END);
  fileLen = ftell(fp);
  fseek(fp, 0L, SEEK_SET);
  if (BufLen > fileLen) {
    printf("Usage: unsupported size\n");
    free(Buf);
    fclose(fp);
    return -1;
  }
  nbytes = fread(Buf, 1, BufLen, fp);
  if (nbytes != BufLen) {
    printf("source file read error\n");
    free(Buf);
    fclose(fp);
    return -1;
  }
  fclose(fp);
  for (i = 0, checksum = 0; i < 16368; i++) {
    Buf1[i + 16] = Buf[i];
    checksum += Buf1[i + 16];
  }
  *(unsigned long *)(Buf1 + 0) = 0x1f;
  *(unsigned long *)(Buf1 + 4) = checksum;
  Buf1[0] ^= 0x53;
  Buf1[1] ^= 0x35;
  Buf1[2] ^= 0x50;
  Buf1[3] ^= 0x43;
  Buf1[4] ^= 0x32;
  Buf1[5] ^= 0x31;
  Buf1[6] ^= 0x30;
  Buf1[7] ^= 0x20;
  Buf1[8] ^= 0x48;
  Buf1[9] ^= 0x45;
  Buf1[10] ^= 0x41;
  Buf1[11] ^= 0x44;
  Buf1[12] ^= 0x45;
  Buf1[13] ^= 0x52;
  Buf1[14] ^= 0x20;
  Buf1[15] ^= 0x20;
  for (i = 1; i < 16; i++) {
    Buf1[i] ^= Buf1[i - 1];
  }
  fp = fopen(argv[2], "wb");
  if (fp == NULL) {
    printf("destination file open error\n");
    free(Buf);
    return -1;
  }
  a = Buf1;
  nbytes = fwrite(a, 1, BufLen, fp);
  if (nbytes != BufLen) {
    printf("destination file write error\n");
    free(Buf);
    free(Buf1);
    fclose(fp);
    return -1;
  }
  free(Buf);
  free(Buf1);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11e8 <main+0x38>
lea    0xe29(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x34(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1270 <main+0xc0>
lea    0xde4(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x18(%rbp),%rdi
mov    0x2d6d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d3b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    12de <main+0x12e>
lea    0xd97(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
je     132c <main+0x17c>
lea    0xd62(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4c(%rbp)
movq   $0x0,-0x48(%rbp)
cmpl   $0x3ff0,-0x4c(%rbp)
jge    1393 <main+0x1e3>
mov    -0x20(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x10,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x10,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1344 <main+0x194>
mov    -0x28(%rbp),%rax
movq   $0x1f,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x4(%rax)
mov    -0x28(%rbp),%rax
movzbl (%rax),%ecx
xor    $0x53,%ecx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%ecx
xor    $0x35,%ecx
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x2(%rax),%ecx
xor    $0x50,%ecx
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x3(%rax),%ecx
xor    $0x43,%ecx
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x4(%rax),%ecx
xor    $0x32,%ecx
mov    %cl,0x4(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x5(%rax),%ecx
xor    $0x31,%ecx
mov    %cl,0x5(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x6(%rax),%ecx
xor    $0x30,%ecx
mov    %cl,0x6(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x7(%rax),%ecx
xor    $0x20,%ecx
mov    %cl,0x7(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x8(%rax),%ecx
xor    $0x48,%ecx
mov    %cl,0x8(%rax)
mov    -0x28(%rbp),%rax
movzbl 0x9(%rax),%ecx
xor    $0x45,%ecx
mov    %cl,0x9(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xa(%rax),%ecx
xor    $0x41,%ecx
mov    %cl,0xa(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xb(%rax),%ecx
xor    $0x44,%ecx
mov    %cl,0xb(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xc(%rax),%ecx
xor    $0x45,%ecx
mov    %cl,0xc(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xd(%rax),%ecx
xor    $0x52,%ecx
mov    %cl,0xd(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xe(%rax),%ecx
xor    $0x20,%ecx
mov    %cl,0xe(%rax)
mov    -0x28(%rbp),%rax
movzbl 0xf(%rax),%ecx
xor    $0x20,%ecx
mov    %cl,0xf(%rax)
movl   $0x1,-0x4c(%rbp)
cmpl   $0x10,-0x4c(%rbp)
jge    14c9 <main+0x319>
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
xor    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    148f <main+0x2df>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xbab(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    150d <main+0x35d>
lea    0xb93(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
je     156c <main+0x3bc>
lea    0xb63(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <main+0x3de>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    125c <main+0xac>
mov    %rsi,%r15
mov    0x18(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1070 <memset@plt>
mov    %r12d,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1070 <memset@plt>
mov    0x8(%r15),%rdi
lea    0xdf3(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     126d <main+0xbd>
mov    %rax,%rbp
mov    0x2dc7(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbp,%rdi
call   1080 <ftell@plt>
mov    %eax,%r13d
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
cmp    %r13d,%r12d
jle    1286 <main+0xd6>
lea    0xdff(%rip),%rdi
jmp    131b <main+0x16b>
lea    0xe22(%rip),%rdi
call   1040 <puts@plt>
jmp    1330 <main+0x180>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1330 <main+0x180>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rbp,%rcx
call   1050 <fread@plt>
cmp    %r12d,%eax
jne    1314 <main+0x164>
mov    %rbp,%rdi
call   1060 <fclose@plt>
lea    0x10(%rbx),%rax
mov    %r14,%rcx
add    $0x3ff0,%rcx
cmp    %rcx,%rax
jae    1344 <main+0x194>
mov    %rbx,%rax
add    $0x4000,%rax
cmp    %r14,%rax
jbe    1344 <main+0x194>
xor    %eax,%eax
xor    %ecx,%ecx
nop
movzbl (%r14,%rax,1),%edx
mov    %dl,0x10(%rbx,%rax,1)
add    %rdx,%rcx
movzbl 0x1(%r14,%rax,1),%edx
mov    %dl,0x11(%rbx,%rax,1)
add    %rdx,%rcx
movzbl 0x2(%r14,%rax,1),%edx
mov    %dl,0x12(%rbx,%rax,1)
add    %rdx,%rcx
movzbl 0x3(%r14,%rax,1),%edx
mov    %dl,0x13(%rbx,%rax,1)
add    %rdx,%rcx
add    $0x4,%rax
cmp    $0x3ff0,%rax
jne    12d0 <main+0x120>
jmp    13fd <main+0x24d>
lea    0xd24(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
pxor   %xmm0,%xmm0
xor    %eax,%eax
pxor   %xmm2,%xmm2
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzwl (%r14,%rax,1),%ecx
movd   %ecx,%xmm4
movzwl 0x2(%r14,%rax,1),%edx
movd   %edx,%xmm3
mov    %cx,0x10(%rbx,%rax,1)
mov    %dx,0x12(%rbx,%rax,1)
punpcklbw %xmm0,%xmm4
punpcklwd %xmm0,%xmm4
punpckldq %xmm0,%xmm4
paddq  %xmm2,%xmm4
punpcklbw %xmm0,%xmm3
punpcklwd %xmm0,%xmm3
punpckldq %xmm0,%xmm3
paddq  %xmm1,%xmm3
movzwl 0x4(%r14,%rax,1),%ecx
movd   %ecx,%xmm2
movzwl 0x6(%r14,%rax,1),%edx
movd   %edx,%xmm1
mov    %cx,0x14(%rbx,%rax,1)
mov    %dx,0x16(%rbx,%rax,1)
punpcklbw %xmm0,%xmm2
punpcklwd %xmm0,%xmm2
punpckldq %xmm0,%xmm2
paddq  %xmm4,%xmm2
punpcklbw %xmm0,%xmm1
punpcklwd %xmm0,%xmm1
punpckldq %xmm0,%xmm1
paddq  %xmm3,%xmm1
add    $0x8,%rax
cmp    $0x3ff0,%rax
jne    1360 <main+0x1b0>
paddq  %xmm2,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddq  %xmm1,%xmm0
movq   %xmm0,%rcx
movq   $0x1f,(%rbx)
movb   $0x4c,(%rbx)
mov    0x1(%rbx),%al
mov    %rcx,%rdi
shr    $0x8,%rdi
mov    %rcx,%rsi
shr    $0x10,%rsi
mov    %rcx,%rdx
shr    $0x18,%rdx
mov    %rcx,%rbp
shr    $0x20,%rbp
mov    %rcx,%r10
shr    $0x28,%r10
mov    %rcx,%r9
shr    $0x30,%r9
mov    %rcx,%r8
shr    $0x38,%r8
xor    $0x79,%al
mov    %al,0x1(%rbx)
xor    0x2(%rbx),%al
xor    $0x50,%al
mov    %al,0x2(%rbx)
xor    0x3(%rbx),%al
xor    $0x43,%al
mov    %al,0x3(%rbx)
xor    %cl,%al
xor    $0x32,%al
mov    %al,0x4(%rbx)
xor    %dil,%al
xor    $0x31,%al
mov    %al,0x5(%rbx)
xor    %sil,%al
xor    $0x30,%al
mov    %al,0x6(%rbx)
xor    %dl,%al
xor    $0x20,%al
mov    %al,0x7(%rbx)
xor    %bpl,%al
xor    $0x48,%al
mov    %al,0x8(%rbx)
xor    %r10b,%al
xor    $0x45,%al
mov    %al,0x9(%rbx)
xor    %r9b,%al
xor    $0x41,%al
mov    %al,0xa(%rbx)
xor    %r8b,%al
xor    $0x44,%al
mov    %al,0xb(%rbx)
xor    0xc(%rbx),%al
xor    $0x45,%al
mov    %al,0xc(%rbx)
xor    0xd(%rbx),%al
xor    $0x52,%al
mov    %al,0xd(%rbx)
xor    0xe(%rbx),%al
mov    %eax,%ecx
xor    $0x20,%cl
mov    %cl,0xe(%rbx)
xor    %al,0xf(%rbx)
mov    0x10(%r15),%rdi
lea    0xb4c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14fb <main+0x34b>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
cmp    %r12d,%eax
jne    1507 <main+0x357>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1335 <main+0x185>
lea    0xb21(%rip),%rdi
jmp    1274 <main+0xc4>
lea    0xaf8(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
jmp    1323 <main+0x173>

LLVM IR (-O0):
@.str = [55 x i8] c"Usage: mkbl1 <source file> <destination file> <size> \0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"source file open error\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [25 x i8] c"Usage: unsupported size\0A\00"
@.str.4 = [24 x i8] c"source file read error\0A\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [29 x i8] c"destination file open error\0A\00"
@.str.7 = [30 x i8] c"destination file write error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %268
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = load i32, i32* %10
%29 = call i32 @memset(i8* %27, i32 0, i32 %28)
%30 = load i32, i32* %10
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = load i32, i32* %10
%35 = call i32 @memset(i8* %33, i32 0, i32 %34)
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %6
%40 = load i32*, i32** %6
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %46
42: ; preds = %19
%43 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%44 = load i8*, i8** %7
%45 = call i32 @free(i8* %44)
store i32 -1, i32* %3
br label %268
46: ; preds = %19
%47 = load i32*, i32** %6
%48 = load i32, i32* @SEEK_END
%49 = call i32 @fseek(i32* %47, i64 0, i32 %48)
%50 = load i32*, i32** %6
%51 = call i32 @ftell(i32* %50)
store i32 %51, i32* %12
%52 = load i32*, i32** %6
%53 = load i32, i32* @SEEK_SET
%54 = call i32 @fseek(i32* %52, i64 0, i32 %53)
%55 = load i32, i32* %10
%56 = load i32, i32* %12
%57 = icmp sgt i32 %55, %56
br i1 %57, label %58, label %64
58: ; preds = %46
%59 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8*, i8** %7
%61 = call i32 @free(i8* %60)
%62 = load i32*, i32** %6
%63 = call i32 @fclose(i32* %62)
store i32 -1, i32* %3
br label %268
64: ; preds = %46
%65 = load i8*, i8** %7
%66 = load i32, i32* %10
%67 = load i32*, i32** %6
%68 = call i32 @fread(i8* %65, i32 1, i32 %66, i32* %67)
store i32 %68, i32* %11
%69 = load i32, i32* %11
%70 = load i32, i32* %10
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %78
72: ; preds = %64
%73 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%74 = load i8*, i8** %7
%75 = call i32 @free(i8* %74)
%76 = load i32*, i32** %6
%77 = call i32 @fclose(i32* %76)
store i32 -1, i32* %3
br label %268
78: ; preds = %64
%79 = load i32*, i32** %6
%80 = call i32 @fclose(i32* %79)
store i32 0, i32* %14
store i64 0, i64* %13
br label %81
81: ; preds = %104, %78
%82 = load i32, i32* %14
%83 = icmp slt i32 %82, 16368
br i1 %83, label %84, label %107
84: ; preds = %81
%85 = load i8*, i8** %7
%86 = load i32, i32* %14
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = load i8*, i8** %8
%91 = load i32, i32* %14
%92 = add nsw i32 %91, 16
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %90, i64 %93
store i8 %89, i8* %94
%95 = load i8*, i8** %8
%96 = load i32, i32* %14
%97 = add nsw i32 %96, 16
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %95, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i64
%102 = load i64, i64* %13
%103 = add i64 %102, %101
store i64 %103, i64* %13
br label %104
104: ; preds = %84
%105 = load i32, i32* %14
%106 = add nsw i32 %105, 1
store i32 %106, i32* %14
br label %81
107: ; preds = %81
%108 = load i8*, i8** %8
%109 = getelementptr inbounds i8, i8* %108, i64 0
%110 = bitcast i8* %109 to i64*
store i64 31, i64* %110
%111 = load i64, i64* %13
%112 = load i8*, i8** %8
%113 = getelementptr inbounds i8, i8* %112, i64 4
%114 = bitcast i8* %113 to i64*
store i64 %111, i64* %114
%115 = load i8*, i8** %8
%116 = getelementptr inbounds i8, i8* %115, i64 0
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = xor i32 %118, 83
%120 = trunc i32 %119 to i8
store i8 %120, i8* %116
%121 = load i8*, i8** %8
%122 = getelementptr inbounds i8, i8* %121, i64 1
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = xor i32 %124, 53
%126 = trunc i32 %125 to i8
store i8 %126, i8* %122
%127 = load i8*, i8** %8
%128 = getelementptr inbounds i8, i8* %127, i64 2
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = xor i32 %130, 80
%132 = trunc i32 %131 to i8
store i8 %132, i8* %128
%133 = load i8*, i8** %8
%134 = getelementptr inbounds i8, i8* %133, i64 3
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = xor i32 %136, 67
%138 = trunc i32 %137 to i8
store i8 %138, i8* %134
%139 = load i8*, i8** %8
%140 = getelementptr inbounds i8, i8* %139, i64 4
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = xor i32 %142, 50
%144 = trunc i32 %143 to i8
store i8 %144, i8* %140
%145 = load i8*, i8** %8
%146 = getelementptr inbounds i8, i8* %145, i64 5
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
%149 = xor i32 %148, 49
%150 = trunc i32 %149 to i8
store i8 %150, i8* %146
%151 = load i8*, i8** %8
%152 = getelementptr inbounds i8, i8* %151, i64 6
%153 = load i8, i8* %152
%154 = zext i8 %153 to i32
%155 = xor i32 %154, 48
%156 = trunc i32 %155 to i8
store i8 %156, i8* %152
%157 = load i8*, i8** %8
%158 = getelementptr inbounds i8, i8* %157, i64 7
%159 = load i8, i8* %158
%160 = zext i8 %159 to i32
%161 = xor i32 %160, 32
%162 = trunc i32 %161 to i8
store i8 %162, i8* %158
%163 = load i8*, i8** %8
%164 = getelementptr inbounds i8, i8* %163, i64 8
%165 = load i8, i8* %164
%166 = zext i8 %165 to i32
%167 = xor i32 %166, 72
%168 = trunc i32 %167 to i8
store i8 %168, i8* %164
%169 = load i8*, i8** %8
%170 = getelementptr inbounds i8, i8* %169, i64 9
%171 = load i8, i8* %170
%172 = zext i8 %171 to i32
%173 = xor i32 %172, 69
%174 = trunc i32 %173 to i8
store i8 %174, i8* %170
%175 = load i8*, i8** %8
%176 = getelementptr inbounds i8, i8* %175, i64 10
%177 = load i8, i8* %176
%178 = zext i8 %177 to i32
%179 = xor i32 %178, 65
%180 = trunc i32 %179 to i8
store i8 %180, i8* %176
%181 = load i8*, i8** %8
%182 = getelementptr inbounds i8, i8* %181, i64 11
%183 = load i8, i8* %182
%184 = zext i8 %183 to i32
%185 = xor i32 %184, 68
%186 = trunc i32 %185 to i8
store i8 %186, i8* %182
%187 = load i8*, i8** %8
%188 = getelementptr inbounds i8, i8* %187, i64 12
%189 = load i8, i8* %188
%190 = zext i8 %189 to i32
%191 = xor i32 %190, 69
%192 = trunc i32 %191 to i8
store i8 %192, i8* %188
%193 = load i8*, i8** %8
%194 = getelementptr inbounds i8, i8* %193, i64 13
%195 = load i8, i8* %194
%196 = zext i8 %195 to i32
%197 = xor i32 %196, 82
%198 = trunc i32 %197 to i8
store i8 %198, i8* %194
%199 = load i8*, i8** %8
%200 = getelementptr inbounds i8, i8* %199, i64 14
%201 = load i8, i8* %200
%202 = zext i8 %201 to i32
%203 = xor i32 %202, 32
%204 = trunc i32 %203 to i8
store i8 %204, i8* %200
%205 = load i8*, i8** %8
%206 = getelementptr inbounds i8, i8* %205, i64 15
%207 = load i8, i8* %206
%208 = zext i8 %207 to i32
%209 = xor i32 %208, 32
%210 = trunc i32 %209 to i8
store i8 %210, i8* %206
store i32 1, i32* %14
br label %211
211: ; preds = %230, %107
%212 = load i32, i32* %14
%213 = icmp slt i32 %212, 16
br i1 %213, label %214, label %233
214: ; preds = %211
%215 = load i8*, i8** %8
%216 = load i32, i32* %14
%217 = sub nsw i32 %216, 1
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %215, i64 %218
%220 = load i8, i8* %219
%221 = zext i8 %220 to i32
%222 = load i8*, i8** %8
%223 = load i32, i32* %14
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds i8, i8* %222, i64 %224
%226 = load i8, i8* %225
%227 = zext i8 %226 to i32
%228 = xor i32 %227, %221
%229 = trunc i32 %228 to i8
store i8 %229, i8* %225
br label %230
230: ; preds = %214
%231 = load i32, i32* %14
%232 = add nsw i32 %231, 1
store i32 %232, i32* %14
br label %211
233: ; preds = %211
%234 = load i8**, i8*** %5
%235 = getelementptr inbounds i8*, i8** %234, i64 2
%236 = load i8*, i8** %235
%237 = call i32* @fopen(i8* %236, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %237, i32** %6
%238 = load i32*, i32** %6
%239 = icmp eq i32* %238, null
br i1 %239, label %240, label %244
240: ; preds = %233
%241 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%242 = load i8*, i8** %7
%243 = call i32 @free(i8* %242)
store i32 -1, i32* %3
br label %268
244: ; preds = %233
%245 = load i8*, i8** %8
store i8* %245, i8** %9
%246 = load i8*, i8** %9
%247 = load i32, i32* %10
%248 = load i32*, i32** %6
%249 = call i32 @fwrite(i8* %246, i32 1, i32 %247, i32* %248)
store i32 %249, i32* %11
%250 = load i32, i32* %11
%251 = load i32, i32* %10
%252 = icmp ne i32 %250, %251
br i1 %252, label %253, label %261
253: ; preds = %244
%254 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%255 = load i8*, i8** %7
%256 = call i32 @free(i8* %255)
%257 = load i8*, i8** %8
%258 = call i32 @free(i8* %257)
%259 = load i32*, i32** %6
%260 = call i32 @fclose(i32* %259)
store i32 -1, i32* %3
br label %268
261: ; preds = %244
%262 = load i8*, i8** %7
%263 = call i32 @free(i8* %262)
%264 = load i8*, i8** %8
%265 = call i32 @free(i8* %264)
%266 = load i32*, i32** %6
%267 = call i32 @fclose(i32* %266)
store i32 0, i32* %3
br label %268
268: ; preds = %261, %253, %240, %72, %58, %42, %17
%269 = load i32, i32* %3
ret i32 %269
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [3 x i8] c"wb\00"
@str = [29 x i8] c"destination file write error\00"
@str.8 = [28 x i8] c"destination file open error\00"
@str.9 = [23 x i8] c"source file read error\00"
@str.10 = [24 x i8] c"Usage: unsupported size\00"
@str.11 = [23 x i8] c"source file open error\00"
@str.12 = [54 x i8] c"Usage: mkbl1 <source file> <destination file> <size> \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.12, i64 0, i64 0))
br label %211
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @memset(i8* %11, i32 0, i32 %9)
%13 = tail call i64 @malloc(i32 %9)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @memset(i8* %14, i32 0, i32 %9)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %6
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%22 = tail call i32 @free(i8* %11)
br label %211
23: ; preds = %6
%24 = load i32, i32* @SEEK_END
%25 = tail call i32 @fseek(i32* %18, i64 0, i32 %24)
%26 = tail call i32 @ftell(i32* %18)
%27 = load i32, i32* @SEEK_SET
%28 = tail call i32 @fseek(i32* %18, i64 0, i32 %27)
%29 = icmp sgt i32 %9, %26
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
%32 = tail call i32 @free(i8* %11)
%33 = tail call i32 @fclose(i32* %18)
br label %211
34: ; preds = %23
%35 = tail call i32 @fread(i8* %11, i32 1, i32 %9, i32* %18)
%36 = icmp eq i32 %35, %9
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%39 = tail call i32 @free(i8* %11)
%40 = tail call i32 @fclose(i32* %18)
br label %211
41: ; preds = %34
%42 = tail call i32 @fclose(i32* %18)
%43 = getelementptr i8, i8* %14, i64 16
%44 = getelementptr i8, i8* %14, i64 16384
%45 = getelementptr i8, i8* %11, i64 16368
%46 = icmp ult i8* %43, %45
%47 = icmp ugt i8* %44, %11
%48 = and i1 %46, %47
br i1 %48, label %89, label %49
49: ; preds = %41, %49
%50 = phi i64 [ %84, %49 ], [ 0, %41 ]
%51 = phi <2 x i64> [ %82, %49 ], [ zeroinitializer, %41 ]
%52 = phi <2 x i64> [ %83, %49 ], [ zeroinitializer, %41 ]
%53 = getelementptr inbounds i8, i8* %11, i64 %50
%54 = bitcast i8* %53 to <2 x i8>*
%55 = load <2 x i8>, <2 x i8>* %54
%56 = getelementptr inbounds i8, i8* %53, i64 2
%57 = bitcast i8* %56 to <2 x i8>*
%58 = load <2 x i8>, <2 x i8>* %57
%59 = add nuw nsw i64 %50, 16
%60 = getelementptr inbounds i8, i8* %14, i64 %59
%61 = bitcast i8* %60 to <2 x i8>*
store <2 x i8> %55, <2 x i8>* %61
%62 = getelementptr inbounds i8, i8* %60, i64 2
%63 = bitcast i8* %62 to <2 x i8>*
store <2 x i8> %58, <2 x i8>* %63
%64 = zext <2 x i8> %55 to <2 x i64>
%65 = zext <2 x i8> %58 to <2 x i64>
%66 = add <2 x i64> %51, %64
%67 = add <2 x i64> %52, %65
%68 = or i64 %50, 4
%69 = getelementptr inbounds i8, i8* %11, i64 %68
%70 = bitcast i8* %69 to <2 x i8>*
%71 = load <2 x i8>, <2 x i8>* %70
%72 = getelementptr inbounds i8, i8* %69, i64 2
%73 = bitcast i8* %72 to <2 x i8>*
%74 = load <2 x i8>, <2 x i8>* %73
%75 = add nuw nsw i64 %50, 20
%76 = getelementptr inbounds i8, i8* %14, i64 %75
%77 = bitcast i8* %76 to <2 x i8>*
store <2 x i8> %71, <2 x i8>* %77
%78 = getelementptr inbounds i8, i8* %76, i64 2
%79 = bitcast i8* %78 to <2 x i8>*
store <2 x i8> %74, <2 x i8>* %79
%80 = zext <2 x i8> %71 to <2 x i64>
%81 = zext <2 x i8> %74 to <2 x i64>
%82 = add <2 x i64> %66, %80
%83 = add <2 x i64> %67, %81
%84 = add nuw nsw i64 %50, 8
%85 = icmp eq i64 %84, 16368
br i1 %85, label %86, label %49
86: ; preds = %49
%87 = add <2 x i64> %83, %82
%88 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %87)
br label %121
89: ; preds = %41, %89
%90 = phi i64 [ %119, %89 ], [ 0, %41 ]
%91 = phi i64 [ %118, %89 ], [ 0, %41 ]
%92 = getelementptr inbounds i8, i8* %11, i64 %90
%93 = load i8, i8* %92
%94 = add nuw nsw i64 %90, 16
%95 = getelementptr inbounds i8, i8* %14, i64 %94
store i8 %93, i8* %95
%96 = zext i8 %93 to i64
%97 = add i64 %91, %96
%98 = or i64 %90, 1
%99 = getelementptr inbounds i8, i8* %11, i64 %98
%100 = load i8, i8* %99
%101 = add nuw nsw i64 %90, 17
%102 = getelementptr inbounds i8, i8* %14, i64 %101
store i8 %100, i8* %102
%103 = zext i8 %100 to i64
%104 = add i64 %97, %103
%105 = or i64 %90, 2
%106 = getelementptr inbounds i8, i8* %11, i64 %105
%107 = load i8, i8* %106
%108 = add nuw nsw i64 %90, 18
%109 = getelementptr inbounds i8, i8* %14, i64 %108
store i8 %107, i8* %109
%110 = zext i8 %107 to i64
%111 = add i64 %104, %110
%112 = or i64 %90, 3
%113 = getelementptr inbounds i8, i8* %11, i64 %112
%114 = load i8, i8* %113
%115 = add nuw nsw i64 %90, 19
%116 = getelementptr inbounds i8, i8* %14, i64 %115
store i8 %114, i8* %116
%117 = zext i8 %114 to i64
%118 = add i64 %111, %117
%119 = add nuw nsw i64 %90, 4
%120 = icmp eq i64 %119, 16368
br i1 %120, label %121, label %89
121: ; preds = %89, %86
%122 = phi i64 [ %88, %86 ], [ %118, %89 ]
%123 = inttoptr i64 %13 to i64*
store i64 31, i64* %123
%124 = getelementptr inbounds i8, i8* %14, i64 4
%125 = load i8, i8* %14
%126 = xor i8 %125, 83
store i8 %126, i8* %14
%127 = getelementptr inbounds i8, i8* %14, i64 1
%128 = load i8, i8* %127
%129 = getelementptr inbounds i8, i8* %14, i64 2
%130 = load i8, i8* %129
%131 = getelementptr inbounds i8, i8* %14, i64 3
%132 = load i8, i8* %131
%133 = trunc i64 %122 to i8
%134 = getelementptr inbounds i8, i8* %14, i64 5
%135 = lshr i64 %122, 8
%136 = trunc i64 %135 to i8
%137 = getelementptr inbounds i8, i8* %14, i64 6
%138 = lshr i64 %122, 16
%139 = trunc i64 %138 to i8
%140 = getelementptr inbounds i8, i8* %14, i64 7
%141 = lshr i64 %122, 24
%142 = trunc i64 %141 to i8
%143 = getelementptr inbounds i8, i8* %14, i64 8
%144 = lshr i64 %122, 32
%145 = trunc i64 %144 to i8
%146 = getelementptr inbounds i8, i8* %14, i64 9
%147 = lshr i64 %122, 40
%148 = trunc i64 %147 to i8
%149 = getelementptr inbounds i8, i8* %14, i64 10
%150 = lshr i64 %122, 48
%151 = trunc i64 %150 to i8
%152 = getelementptr inbounds i8, i8* %14, i64 11
%153 = lshr i64 %122, 56
%154 = trunc i64 %153 to i8
%155 = getelementptr inbounds i8, i8* %14, i64 12
%156 = load i8, i8* %155
%157 = getelementptr inbounds i8, i8* %14, i64 13
%158 = load i8, i8* %157
%159 = getelementptr inbounds i8, i8* %14, i64 14
%160 = load i8, i8* %159
%161 = getelementptr inbounds i8, i8* %14, i64 15
%162 = load i8, i8* %161
%163 = xor i8 %128, %126
%164 = xor i8 %163, 53
store i8 %164, i8* %127
%165 = xor i8 %130, %164
%166 = xor i8 %165, 80
store i8 %166, i8* %129
%167 = xor i8 %132, %166
%168 = xor i8 %167, 67
store i8 %168, i8* %131
%169 = xor i8 %168, %133
%170 = xor i8 %169, 50
store i8 %170, i8* %124
%171 = xor i8 %170, %136
%172 = xor i8 %171, 49
store i8 %172, i8* %134
%173 = xor i8 %172, %139
%174 = xor i8 %173, 48
store i8 %174, i8* %137
%175 = xor i8 %174, %142
%176 = xor i8 %175, 32
store i8 %176, i8* %140
%177 = xor i8 %176, %145
%178 = xor i8 %177, 72
store i8 %178, i8* %143
%179 = xor i8 %178, %148
%180 = xor i8 %179, 69
store i8 %180, i8* %146
%181 = xor i8 %180, %151
%182 = xor i8 %181, 65
store i8 %182, i8* %149
%183 = xor i8 %182, %154
%184 = xor i8 %183, 68
store i8 %184, i8* %152
%185 = xor i8 %156, %184
%186 = xor i8 %185, 69
store i8 %186, i8* %155
%187 = xor i8 %158, %186
%188 = xor i8 %187, 82
store i8 %188, i8* %157
%189 = xor i8 %160, %188
%190 = xor i8 %189, 32
store i8 %190, i8* %159
%191 = xor i8 %162, %189
store i8 %191, i8* %161
%192 = getelementptr inbounds i8*, i8** %1, i64 2
%193 = load i8*, i8** %192
%194 = tail call i32* @fopen(i8* %193, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%195 = icmp eq i32* %194, null
br i1 %195, label %196, label %199
196: ; preds = %121
%197 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%198 = tail call i32 @free(i8* %11)
br label %211
199: ; preds = %121
%200 = tail call i32 @fwrite(i8* %14, i32 1, i32 %9, i32* %194)
%201 = icmp eq i32 %200, %9
br i1 %201, label %207, label %202
202: ; preds = %199
%203 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%204 = tail call i32 @free(i8* %11)
%205 = tail call i32 @free(i8* %14)
%206 = tail call i32 @fclose(i32* %194)
br label %211
207: ; preds = %199
%208 = tail call i32 @free(i8* %11)
%209 = tail call i32 @free(i8* %14)
%210 = tail call i32 @fclose(i32* %194)
br label %211
211: ; preds = %207, %202, %196, %37, %30, %20, %4
%212 = phi i32 [ -1, %4 ], [ -1, %20 ], [ -1, %30 ], [ -1, %37 ], [ -1, %196 ], [ -1, %202 ], [ 0, %207 ]
ret i32 %212
}