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

/* 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];
  *(unsigned long *)buffer ^= 0x1f;
  *(unsigned long *)(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),%rax
xor    $0x1f,%rax
mov    %rax,-0x4020(%rbp)
mov    -0x402c(%rbp),%eax
xor    -0x401c(%rbp),%rax
mov    %rax,-0x401c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1582 <main+0x3d2>
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    1545 <main+0x395>
mov    -0x4028(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
cmp    $0x4000,%eax
je     163f <main+0x48f>
mov    0x2a05(%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    0x29d1(%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    0xa62(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     1619 <main+0x469>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     1631 <main+0x481>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2950(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x4024(%rbp)
je     1657 <main+0x4a7>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     166f <main+0x4bf>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2902(%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    147f <main+0x2cf>
mov    0x8(%r14),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1492 <main+0x2e2>
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     14cc <main+0x31c>
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    150b <main+0x35b>
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,%ecx
mov    (%rsp),%rdx
mov    %rdx,%rsi
xor    $0x1f,%rsi
mov    %rsi,(%rsp)
mov    0x4(%rsp),%rax
xor    %rax,%rcx
mov    %rdx,%rdi
shr    $0x8,%rdi
xor    %rsi,%rdi
mov    %dil,0x1(%rsp)
mov    %rdx,%rsi
shr    $0x10,%rsi
xor    %rdi,%rsi
mov    %sil,0x2(%rsp)
shr    $0x18,%rdx
xor    %rsi,%rdx
mov    %dl,0x3(%rsp)
xor    %rcx,%rdx
mov    %dl,0x4(%rsp)
mov    %rcx,%rsi
shr    $0x8,%rsi
xor    %rdx,%rsi
mov    %sil,0x5(%rsp)
mov    %rcx,%rdx
shr    $0x10,%rdx
xor    %rsi,%rdx
mov    %dl,0x6(%rsp)
shr    $0x18,%rcx
xor    %rdx,%rcx
mov    %cl,0x7(%rsp)
mov    %rax,%rdx
shr    $0x20,%rdx
xor    %rcx,%rdx
mov    %dl,0x8(%rsp)
mov    %rax,%rcx
shr    $0x28,%rcx
xor    %rdx,%rcx
mov    %cl,0x9(%rsp)
mov    %rax,%rdx
shr    $0x30,%rdx
xor    %rcx,%rdx
mov    %dl,0xa(%rsp)
shr    $0x38,%rax
xor    %edx,%eax
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    1532 <main+0x382>
test   %r12d,%r12d
je     1459 <main+0x2a9>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     1466 <main+0x2b6>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2b0b(%rip),%rax
mov    (%rax),%eax
add    $0x4000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb7a(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    1581 <main+0x3d1>
mov    0x2b17(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb68(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
jmp    1581 <main+0x3d1>
mov    0x2add(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%r15
mov    0x10(%r14),%r14
mov    0x2ac5(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb2e(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     1581 <main+0x3d1>
mov    %r12d,%edi
jmp    157c <main+0x3cc>
mov    0x2a9e(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2a86(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb17(%rip),%rsi
jmp    1557 <main+0x3a7>
mov    0x2a77(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x10(%r14),%r14
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb07(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     1574 <main+0x3c4>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     1581 <main+0x3d1>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2a00(%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 i64*
%151 = load i64, i64* %150
%152 = xor i64 %151, 31
store i64 %152, i64* %150
%153 = load i32, i32* %11
%154 = zext i32 %153 to i64
%155 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%156 = getelementptr inbounds i8, i8* %155, i64 4
%157 = bitcast i8* %156 to i64*
%158 = load i64, i64* %157
%159 = xor i64 %158, %154
store i64 %159, i64* %157
store i32 1, i32* %6
br label %160
160: ; preds = %177, %148
%161 = load i32, i32* %6
%162 = icmp slt i32 %161, 16
br i1 %162, label %163, label %180
163: ; preds = %160
%164 = load i32, i32* %6
%165 = sub nsw i32 %164, 1
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %166
%168 = load i8, i8* %167
%169 = zext i8 %168 to i32
%170 = load i32, i32* %6
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %171
%173 = load i8, i8* %172
%174 = zext i8 %173 to i32
%175 = xor i32 %174, %169
%176 = trunc i32 %175 to i8
store i8 %176, i8* %172
br label %177
177: ; preds = %163
%178 = load i32, i32* %6
%179 = add nsw i32 %178, 1
store i32 %179, i32* %6
br label %160
180: ; preds = %160
%181 = load i32, i32* %10
%182 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%183 = call i32 @write(i32 %181, i8* %182, i32 16384)
%184 = icmp ne i32 %183, 16384
br i1 %184, label %185, label %210
185: ; preds = %180
%186 = load i32, i32* @stderr
%187 = load i8**, i8*** %5
%188 = getelementptr inbounds i8*, i8** %187, i64 0
%189 = load i8*, i8** %188
%190 = load i8**, i8*** %5
%191 = getelementptr inbounds i8*, i8** %190, i64 2
%192 = load i8*, i8** %191
%193 = load i32, i32* @errno
%194 = call i8* @strerror(i32 %193)
%195 = call i32 @fprintf(i32 %186, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %189, i8* %192, i8* %194)
%196 = load i32, i32* %9
%197 = icmp ne i32 %196, 0
br i1 %197, label %198, label %201
198: ; preds = %185
%199 = load i32, i32* %9
%200 = call i32 @close(i32 %199)
br label %201
201: ; preds = %198, %185
%202 = load i32, i32* %10
%203 = icmp ne i32 %202, 0
br i1 %203, label %204, label %207
204: ; preds = %201
%205 = load i32, i32* %10
%206 = call i32 @close(i32 %205)
br label %207
207: ; preds = %204, %201
%208 = load i32, i32* @EXIT_FAILURE
%209 = call i32 @exit(i32 %208)
unreachable
210: ; preds = %180
%211 = load i32, i32* %9
%212 = icmp ne i32 %211, 0
br i1 %212, label %213, label %216
213: ; preds = %210
%214 = load i32, i32* %9
%215 = call i32 @close(i32 %214)
br label %216
216: ; preds = %213, %210
%217 = load i32, i32* %10
%218 = icmp ne i32 %217, 0
br i1 %218, label %219, label %222
219: ; preds = %216
%220 = load i32, i32* %10
%221 = call i32 @close(i32 %220)
br label %222
222: ; preds = %219, %216
%223 = load i32, i32* @EXIT_SUCCESS
ret i32 %223
}

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 %176
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 i64*
%113 = load i64, i64* %112
%114 = xor i64 %113, 31
store i64 %114, i64* %112
%115 = zext i32 %111 to i64
%116 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 4
%117 = bitcast i8* %116 to i64*
%118 = load i64, i64* %117
%119 = xor i64 %118, %115
%120 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 1
%121 = lshr i64 %113, 8
%122 = xor i64 %121, %114
%123 = trunc i64 %122 to i8
store i8 %123, i8* %120
%124 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 2
%125 = lshr i64 %113, 16
%126 = xor i64 %125, %122
%127 = trunc i64 %126 to i8
store i8 %127, i8* %124
%128 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 3
%129 = lshr i64 %113, 24
%130 = xor i64 %129, %126
%131 = trunc i64 %130 to i8
store i8 %131, i8* %128
%132 = xor i64 %119, %130
%133 = trunc i64 %132 to i8
store i8 %133, i8* %116
%134 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 5
%135 = lshr i64 %119, 8
%136 = xor i64 %135, %132
%137 = trunc i64 %136 to i8
store i8 %137, i8* %134
%138 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 6
%139 = lshr i64 %119, 16
%140 = xor i64 %139, %136
%141 = trunc i64 %140 to i8
store i8 %141, i8* %138
%142 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 7
%143 = lshr i64 %119, 24
%144 = xor i64 %143, %140
%145 = trunc i64 %144 to i8
store i8 %145, i8* %142
%146 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 8
%147 = lshr i64 %118, 32
%148 = xor i64 %147, %144
%149 = trunc i64 %148 to i8
store i8 %149, i8* %146
%150 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 9
%151 = lshr i64 %118, 40
%152 = xor i64 %151, %148
%153 = trunc i64 %152 to i8
store i8 %153, i8* %150
%154 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 10
%155 = lshr i64 %118, 48
%156 = xor i64 %155, %152
%157 = trunc i64 %156 to i8
store i8 %157, i8* %154
%158 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 11
%159 = lshr i64 %118, 56
%160 = xor i64 %159, %156
%161 = trunc i64 %160 to i8
store i8 %161, i8* %158
%162 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 12
%163 = load i8, i8* %162
%164 = xor i8 %163, %161
store i8 %164, i8* %162
%165 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 13
%166 = load i8, i8* %165
%167 = xor i8 %166, %164
store i8 %167, i8* %165
%168 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14
%169 = load i8, i8* %168
%170 = xor i8 %169, %167
store i8 %170, i8* %168
%171 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 15
%172 = load i8, i8* %171
%173 = xor i8 %172, %170
store i8 %173, i8* %171
%174 = call i32 @write(i32 %44, i8* %4, i32 16384)
%175 = icmp eq i32 %174, 16384
br i1 %175, label %210, label %193
176: ; preds = %59
%177 = load i32, i32* @stderr
%178 = load i8*, i8** %1
%179 = load i8*, i8** %11
%180 = load i32, i32* @errno
%181 = call i8* @strerror(i32 %180)
%182 = call i32 @fprintf(i32 %177, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %178, i8* %179, i8* %181)
%183 = icmp eq i32 %14, 0
br i1 %183, label %186, label %184
184: ; preds = %176
%185 = call i32 @close(i32 %14)
br label %186
186: ; preds = %184, %176
%187 = icmp eq i32 %44, 0
br i1 %187, label %190, label %188
188: ; preds = %186
%189 = call i32 @close(i32 %44)
br label %190
190: ; preds = %188, %186
%191 = load i32, i32* @EXIT_FAILURE
%192 = call i32 @exit(i32 %191)
unreachable
193: ; preds = %109
%194 = load i32, i32* @stderr
%195 = load i8*, i8** %1
%196 = load i8*, i8** %26
%197 = load i32, i32* @errno
%198 = call i8* @strerror(i32 %197)
%199 = call i32 @fprintf(i32 %194, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %195, i8* %196, i8* %198)
%200 = icmp eq i32 %14, 0
br i1 %200, label %203, label %201
201: ; preds = %193
%202 = call i32 @close(i32 %14)
br label %203
203: ; preds = %201, %193
%204 = icmp eq i32 %44, 0
br i1 %204, label %207, label %205
205: ; preds = %203
%206 = call i32 @close(i32 %44)
br label %207
207: ; preds = %205, %203
%208 = load i32, i32* @EXIT_FAILURE
%209 = call i32 @exit(i32 %208)
unreachable
210: ; preds = %109
%211 = icmp eq i32 %14, 0
br i1 %211, label %214, label %212
212: ; preds = %210
%213 = call i32 @close(i32 %14)
br label %214
214: ; preds = %212, %210
%215 = icmp eq i32 %44, 0
br i1 %215, label %218, label %216
216: ; preds = %214
%217 = call i32 @close(i32 %44)
br label %218
218: ; preds = %216, %214
%219 = load i32, i32* @EXIT_SUCCESS
ret i32 %219
}