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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, int);
unsigned int read(int, unsigned char *, unsigned int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int write(int, unsigned char *, int);
int main(int argc, char **argv) {
  int i, len;
  unsigned char buffer[(16 * 1024)] = {0};
  int ifd, ofd;
  unsigned int checksum = 0, count;
  if (argc != 3) {
    printf(" %d Wrong number of arguments\n", argc);
    exit(EXIT_FAILURE);
  }
  ifd = open(argv[1], O_RDONLY);
  if (ifd < 0) {
    fprintf(stderr, "%s: Can't open %s: %s\n", argv[0], argv[1],
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  ofd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC,
             (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
  if (ofd < 0) {
    fprintf(stderr, "%s: Can't open %s: %s\n", argv[0], argv[2],
            strerror(errno));
    if (ifd)
      close(ifd);
    exit(EXIT_FAILURE);
  }
  len = lseek(ifd, 0, SEEK_END);
  lseek(ifd, 0, SEEK_SET);
  memcpy(&buffer[0], "S5PC210 HEADER  ", 16);
  count = (len < ((16 * 1024) - 16)) ? len : ((16 * 1024) - 16);
  if (read(ifd, buffer + 16, count) != count) {
    fprintf(stderr, "%s: Can't read %s: %s\n", argv[0], argv[1],
            strerror(errno));
    if (ifd)
      close(ifd);
    if (ofd)
      close(ofd);
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < (16 * 1024) - 16; i++)
    checksum += buffer[i + 16];
  *(ulong *)buffer ^= 0x1f;
  *(ulong *)(buffer + 4) ^= checksum;
  for (i = 1; i < 16; i++)
    buffer[i] ^= buffer[i - 1];
  if (write(ofd, buffer, (16 * 1024)) != (16 * 1024)) {
    fprintf(stderr, "%s: Can't write %s: %s\n", argv[0], argv[2],
            strerror(errno));
    if (ifd)
      close(ifd);
    if (ofd)
      close(ofd);
    exit(EXIT_FAILURE);
  }
  if (ifd)
    close(ifd);
  if (ofd)
    close(ofd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4090,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4020(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   1060 <memset@plt>
movl   $0x0,-0x402c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120d <main+0x5d>
mov    -0x8(%rbp),%esi
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x4024(%rbp)
cmpl   $0x0,-0x4024(%rbp)
jge    12a3 <main+0xf3>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4044(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x4040(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x4038(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x4044(%rbp),%edi
mov    -0x4040(%rbp),%rdx
mov    -0x4038(%rbp),%rcx
mov    %rax,%r8
lea    0xd8f(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2cb6(%rip),%rax
mov    (%rax),%esi
mov    0x2d3d(%rip),%rax
or     (%rax),%esi
mov    0x2d2c(%rip),%rax
or     (%rax),%esi
mov    0x2cb3(%rip),%rax
mov    (%rax),%edx
mov    0x2cea(%rip),%rax
or     (%rax),%edx
mov    0x2cb9(%rip),%rax
or     (%rax),%edx
mov    0x2ce0(%rip),%rax
or     (%rax),%edx
mov    0x2c9f(%rip),%rax
or     (%rax),%edx
mov    0x2c66(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x4028(%rbp)
cmpl   $0x0,-0x4028(%rbp)
jge    1399 <main+0x1e9>
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x405c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x4058(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x4050(%rbp)
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x405c(%rbp),%edi
mov    -0x4058(%rbp),%rdx
mov    -0x4050(%rbp),%rcx
mov    %rax,%r8
lea    0xcb1(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     138b <main+0x1db>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x4024(%rbp),%edi
mov    0x2c32(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4024(%rbp),%edi
mov    0x2be1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
lea    -0x4020(%rbp),%rdi
lea    0xc60(%rip),%rsi
mov    $0x10,%edx
call   10a0 <memcpy@plt>
cmpl   $0x3ff0,-0x18(%rbp)
jge    13fb <main+0x24b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4060(%rbp)
jmp    140b <main+0x25b>
mov    $0x3ff0,%eax
mov    %eax,-0x4060(%rbp)
jmp    140b <main+0x25b>
mov    -0x4060(%rbp),%eax
mov    %eax,-0x4030(%rbp)
mov    -0x4024(%rbp),%edi
lea    -0x4020(%rbp),%rsi
add    $0x10,%rsi
mov    -0x4030(%rbp),%edx
call   1080 <read@plt>
cmp    -0x4030(%rbp),%eax
je     14da <main+0x32a>
mov    0x2b6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4074(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x4070(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x4068(%rbp)
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x4074(%rbp),%edi
mov    -0x4070(%rbp),%rdx
mov    -0x4068(%rbp),%rcx
mov    %rax,%r8
lea    0xbb0(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     14b4 <main+0x304>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     14cc <main+0x31c>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2ab5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3ff0,-0x14(%rbp)
jge    1518 <main+0x368>
mov    -0x14(%rbp),%eax
add    $0x10,%eax
cltq
movzbl -0x4020(%rbp,%rax,1),%eax
ff
add    -0x402c(%rbp),%eax
mov    %eax,-0x402c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14e1 <main+0x331>
mov    -0x4020(%rbp),%eax
xor    $0x1f,%eax
mov    %eax,-0x4020(%rbp)
mov    -0x402c(%rbp),%eax
xor    -0x401c(%rbp),%eax
mov    %eax,-0x401c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    157d <main+0x3cd>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movzbl -0x4020(%rbp,%rax,1),%edx
ff
movslq -0x14(%rbp),%rax
movzbl -0x4020(%rbp,%rax,1),%ecx
ff
xor    %edx,%ecx
mov    %cl,-0x4020(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1540 <main+0x390>
mov    -0x4028(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
cmp    $0x4000,%eax
je     163a <main+0x48a>
mov    0x2a0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x408c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x4088(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x4080(%rbp)
mov    0x29d6(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x408c(%rbp),%edi
mov    -0x4088(%rbp),%rdx
mov    -0x4080(%rbp),%rcx
mov    %rax,%r8
lea    0xa67(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     1614 <main+0x464>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     162c <main+0x47c>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2955(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x4024(%rbp)
je     1652 <main+0x4a2>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     166a <main+0x4ba>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2907(%rip),%rax
mov    (%rax),%eax
add    $0x4090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4000,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0x4000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
cmp    $0x3,%ebx
jne    1450 <main+0x2a0>
mov    0x8(%r14),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1463 <main+0x2b3>
mov    %eax,%r12d
mov    0x2d66(%rip),%rax
mov    0x2def(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ddc(%rip),%rax
or     (%rax),%esi
mov    0x2d63(%rip),%rax
mov    0x2d9c(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d69(%rip),%rax
or     (%rax),%edx
mov    0x2d90(%rip),%rax
or     (%rax),%edx
mov    0x2d4f(%rip),%rax
or     (%rax),%edx
mov    0x10(%r14),%rdi
mov    0x2d12(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     149d <main+0x2ed>
mov    %eax,%r15d
mov    0x2d6f(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,%ebp
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
lea    0xda5(%rip),%rsi
mov    %rsp,%rdi
mov    $0x10,%edx
call   10a0 <memcpy@plt>
cmp    $0x3ff0,%ebp
mov    $0x3ff0,%ebx
cmovl  %ebp,%ebx
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    %ebx,%edx
call   1080 <read@plt>
cmp    %ebx,%eax
jne    14dc <main+0x32c>
pxor   %xmm0,%xmm0
xor    %eax,%eax
pxor   %xmm2,%xmm2
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movq   0x10(%rsp,%rax,1),%xmm4
movd   0x14(%rsp,%rax,1),%xmm3
punpcklbw %xmm0,%xmm4
punpcklwd %xmm0,%xmm4
paddd  %xmm2,%xmm4
punpcklbw %xmm0,%xmm3
punpcklwd %xmm0,%xmm3
paddd  %xmm1,%xmm3
movq   0x18(%rsp,%rax,1),%xmm5
movd   0x1c(%rsp,%rax,1),%xmm6
punpcklbw %xmm0,%xmm5
punpcklwd %xmm0,%xmm5
punpcklbw %xmm0,%xmm6
punpcklwd %xmm0,%xmm6
movq   0x20(%rsp,%rax,1),%xmm2
movd   0x24(%rsp,%rax,1),%xmm1
punpcklbw %xmm0,%xmm2
punpcklwd %xmm0,%xmm2
paddd  %xmm5,%xmm2
paddd  %xmm4,%xmm2
punpcklbw %xmm0,%xmm1
punpcklwd %xmm0,%xmm1
paddd  %xmm6,%xmm1
paddd  %xmm3,%xmm1
add    $0x18,%rax
cmp    $0x3ff0,%rax
jne    12e0 <main+0x130>
paddd  %xmm2,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
mov    (%rsp),%ecx
mov    %ecx,%edx
xor    $0x1f,%edx
mov    %edx,(%rsp)
xor    0x4(%rsp),%eax
mov    %ecx,%esi
shr    $0x8,%esi
xor    %edx,%esi
mov    %sil,0x1(%rsp)
mov    %ecx,%edx
shr    $0x10,%edx
xor    %esi,%edx
mov    %dl,0x2(%rsp)
shr    $0x18,%ecx
xor    %edx,%ecx
mov    %cl,0x3(%rsp)
xor    %eax,%ecx
mov    %cl,0x4(%rsp)
mov    %eax,%edx
shr    $0x8,%edx
xor    %ecx,%edx
mov    %dl,0x5(%rsp)
mov    %eax,%ecx
shr    $0x10,%ecx
xor    %edx,%ecx
mov    %cl,0x6(%rsp)
shr    $0x18,%eax
xor    %ecx,%eax
mov    %al,0x7(%rsp)
xor    0x8(%rsp),%al
mov    %al,0x8(%rsp)
xor    0x9(%rsp),%al
mov    %al,0x9(%rsp)
xor    0xa(%rsp),%al
mov    %al,0xa(%rsp)
xor    0xb(%rsp),%al
mov    %al,0xb(%rsp)
xor    0xc(%rsp),%al
mov    %al,0xc(%rsp)
xor    0xd(%rsp),%al
mov    %al,0xd(%rsp)
xor    0xe(%rsp),%al
mov    %al,0xe(%rsp)
xor    %al,0xf(%rsp)
mov    %rsp,%rsi
mov    %r15d,%edi
mov    $0x4000,%edx
call   1030 <write@plt>
cmp    $0x4000,%eax
jne    1503 <main+0x353>
test   %r12d,%r12d
je     142a <main+0x27a>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     1437 <main+0x287>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%eax
add    $0x4000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xba9(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    1552 <main+0x3a2>
mov    0x2b46(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb97(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
jmp    1552 <main+0x3a2>
mov    0x2b0c(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%r15
mov    0x10(%r14),%r14
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb5d(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     1552 <main+0x3a2>
mov    %r12d,%edi
jmp    154d <main+0x39d>
mov    0x2acd(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2ab5(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb46(%rip),%rsi
jmp    1528 <main+0x378>
mov    0x2aa6(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x10(%r14),%r14
mov    0x2a8e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb36(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     1545 <main+0x395>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     1552 <main+0x3a2>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2a2f(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c" %d Wrong number of arguments\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"%s: Can't open %s: %s\0A\00"
@errno = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [17 x i8] c"S5PC210 HEADER \00"
@.str.3 = [23 x i8] c"%s: Can't read %s: %s\0A\00"
@.str.4 = [24 x i8] c"%s: Can't write %s: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [16384 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [16384 x i8]* %8 to i8*
store i32 0, i32* %11
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* %4
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = call i32 (i8*, i32, ...) @open(i8* %24, i32 %25)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* @errno
%38 = call i8* @strerror(i32 %37)
%39 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %36, i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %21
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = load i32, i32* @O_WRONLY
%47 = load i32, i32* @O_CREAT
%48 = or i32 %46, %47
%49 = load i32, i32* @O_TRUNC
%50 = or i32 %48, %49
%51 = load i32, i32* @S_IRUSR
%52 = load i32, i32* @S_IWUSR
%53 = or i32 %51, %52
%54 = load i32, i32* @S_IRGRP
%55 = or i32 %53, %54
%56 = load i32, i32* @S_IWGRP
%57 = or i32 %55, %56
%58 = load i32, i32* @S_IROTH
%59 = or i32 %57, %58
%60 = load i32, i32* @S_IWOTH
%61 = or i32 %59, %60
%62 = call i32 (i8*, i32, ...) @open(i8* %45, i32 %50, i32 %61)
store i32 %62, i32* %10
%63 = load i32, i32* %10
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %84
65: ; preds = %42
%66 = load i32, i32* @stderr
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 2
%72 = load i8*, i8** %71
%73 = load i32, i32* @errno
%74 = call i8* @strerror(i32 %73)
%75 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %69, i8* %72, i8* %74)
%76 = load i32, i32* %9
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %65
%79 = load i32, i32* %9
%80 = call i32 @close(i32 %79)
br label %81
81: ; preds = %78, %65
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %42
%85 = load i32, i32* %9
%86 = load i32, i32* @SEEK_END
%87 = call i32 @lseek(i32 %85, i32 0, i32 %86)
store i32 %87, i32* %7
%88 = load i32, i32* %9
%89 = load i32, i32* @SEEK_SET
%90 = call i32 @lseek(i32 %88, i32 0, i32 %89)
%91 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%92 = call i32 @memcpy(i8* %91, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 16)
%93 = load i32, i32* %7
%94 = icmp slt i32 %93, 16368
br i1 %94, label %95, label %97
95: ; preds = %84
%96 = load i32, i32* %7
br label %98
97: ; preds = %84
br label %98
98: ; preds = %97, %95
%99 = phi i32 [ %96, %95 ], [ 16368, %97 ]
store i32 %99, i32* %12
%100 = load i32, i32* %9
%101 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%102 = getelementptr inbounds i8, i8* %101, i64 16
%103 = load i32, i32* %12
%104 = call i32 @read(i32 %100, i8* %102, i32 %103)
%105 = load i32, i32* %12
%106 = icmp ne i32 %104, %105
br i1 %106, label %107, label %132
107: ; preds = %98
%108 = load i32, i32* @stderr
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 0
%111 = load i8*, i8** %110
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 1
%114 = load i8*, i8** %113
%115 = load i32, i32* @errno
%116 = call i8* @strerror(i32 %115)
%117 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %111, i8* %114, i8* %116)
%118 = load i32, i32* %9
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %123
120: ; preds = %107
%121 = load i32, i32* %9
%122 = call i32 @close(i32 %121)
br label %123
123: ; preds = %120, %107
%124 = load i32, i32* %10
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i32, i32* %10
%128 = call i32 @close(i32 %127)
br label %129
129: ; preds = %126, %123
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %98
store i32 0, i32* %6
br label %133
133: ; preds = %145, %132
%134 = load i32, i32* %6
%135 = icmp slt i32 %134, 16368
br i1 %135, label %136, label %148
136: ; preds = %133
%137 = load i32, i32* %6
%138 = add nsw i32 %137, 16
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %139
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = load i32, i32* %11
%144 = add i32 %143, %142
store i32 %144, i32* %11
br label %145
145: ; preds = %136
%146 = load i32, i32* %6
%147 = add nsw i32 %146, 1
store i32 %147, i32* %6
br label %133
148: ; preds = %133
%149 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%150 = bitcast i8* %149 to i32*
%151 = load i32, i32* %150
%152 = xor i32 %151, 31
store i32 %152, i32* %150
%153 = load i32, i32* %11
%154 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%155 = getelementptr inbounds i8, i8* %154, i64 4
%156 = bitcast i8* %155 to i32*
%157 = load i32, i32* %156
%158 = xor i32 %157, %153
store i32 %158, i32* %156
store i32 1, i32* %6
br label %159
159: ; preds = %176, %148
%160 = load i32, i32* %6
%161 = icmp slt i32 %160, 16
br i1 %161, label %162, label %179
162: ; preds = %159
%163 = load i32, i32* %6
%164 = sub nsw i32 %163, 1
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %165
%167 = load i8, i8* %166
%168 = zext i8 %167 to i32
%169 = load i32, i32* %6
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %170
%172 = load i8, i8* %171
%173 = zext i8 %172 to i32
%174 = xor i32 %173, %168
%175 = trunc i32 %174 to i8
store i8 %175, i8* %171
br label %176
176: ; preds = %162
%177 = load i32, i32* %6
%178 = add nsw i32 %177, 1
store i32 %178, i32* %6
br label %159
179: ; preds = %159
%180 = load i32, i32* %10
%181 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%182 = call i32 @write(i32 %180, i8* %181, i32 16384)
%183 = icmp ne i32 %182, 16384
br i1 %183, label %184, label %209
184: ; preds = %179
%185 = load i32, i32* @stderr
%186 = load i8**, i8*** %5
%187 = getelementptr inbounds i8*, i8** %186, i64 0
%188 = load i8*, i8** %187
%189 = load i8**, i8*** %5
%190 = getelementptr inbounds i8*, i8** %189, i64 2
%191 = load i8*, i8** %190
%192 = load i32, i32* @errno
%193 = call i8* @strerror(i32 %192)
%194 = call i32 @fprintf(i32 %185, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %188, i8* %191, i8* %193)
%195 = load i32, i32* %9
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %184
%198 = load i32, i32* %9
%199 = call i32 @close(i32 %198)
br label %200
200: ; preds = %197, %184
%201 = load i32, i32* %10
%202 = icmp ne i32 %201, 0
br i1 %202, label %203, label %206
203: ; preds = %200
%204 = load i32, i32* %10
%205 = call i32 @close(i32 %204)
br label %206
206: ; preds = %203, %200
%207 = load i32, i32* @EXIT_FAILURE
%208 = call i32 @exit(i32 %207)
unreachable
209: ; preds = %179
%210 = load i32, i32* %9
%211 = icmp ne i32 %210, 0
br i1 %211, label %212, label %215
212: ; preds = %209
%213 = load i32, i32* %9
%214 = call i32 @close(i32 %213)
br label %215
215: ; preds = %212, %209
%216 = load i32, i32* %10
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %221
218: ; preds = %215
%219 = load i32, i32* %10
%220 = call i32 @close(i32 %219)
br label %221
221: ; preds = %218, %215
%222 = load i32, i32* @EXIT_SUCCESS
ret i32 %222
}

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