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

/* 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 *, unsigned int *, 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);
  count = (len < (14 * 1024 - 4)) ? len : (14 * 1024 - 4);
  if (read(ifd, buffer, 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, checksum = 0; i < (14 * 1024 - 4); i++)
    checksum += buffer[i];
  memcpy(&buffer[(14 * 1024 - 4)], &checksum, sizeof(checksum));
  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>
cmpl   $0x37fc,-0x18(%rbp)
jge    13e3 <main+0x233>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4060(%rbp)
jmp    13f3 <main+0x243>
mov    $0x37fc,%eax
mov    %eax,-0x4060(%rbp)
jmp    13f3 <main+0x243>
mov    -0x4060(%rbp),%eax
mov    %eax,-0x4030(%rbp)
mov    -0x4024(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    -0x4030(%rbp),%edx
call   1080 <read@plt>
cmp    -0x4030(%rbp),%eax
je     14be <main+0x30e>
mov    0x2b86(%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    0x2b52(%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    0xbbb(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     1498 <main+0x2e8>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     14b0 <main+0x300>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2ad1(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x402c(%rbp)
cmpl   $0x37fc,-0x14(%rbp)
jge    1502 <main+0x352>
movslq -0x14(%rbp),%rax
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    14cf <main+0x31f>
lea    -0x4020(%rbp),%rdi
add    $0x37fc,%rdi
lea    -0x402c(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x4028(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
cmp    $0x4000,%eax
je     15de <main+0x42e>
mov    0x2a66(%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    0x2a32(%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    0xab2(%rip),%rsi
call   1090 <fprintf@plt>
cmpl   $0x0,-0x4024(%rbp)
je     15b8 <main+0x408>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     15d0 <main+0x420>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x29b1(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x4024(%rbp)
je     15f6 <main+0x446>
mov    -0x4024(%rbp),%edi
call   1070 <close@plt>
cmpl   $0x0,-0x4028(%rbp)
je     160e <main+0x45e>
mov    -0x4028(%rbp),%edi
call   1070 <close@plt>
mov    0x2963(%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    $0x4010,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0x10(%rsp),%rdi
mov    $0x4000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
cmp    $0x3,%ebx
jne    13f4 <main+0x244>
mov    0x8(%r14),%rdi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1407 <main+0x257>
mov    %eax,%r12d
mov    0x2d64(%rip),%rax
mov    0x2ded(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dda(%rip),%rax
or     (%rax),%esi
mov    0x2d61(%rip),%rax
mov    0x2d9a(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d67(%rip),%rax
or     (%rax),%edx
mov    0x2d8e(%rip),%rax
or     (%rax),%edx
mov    0x2d4d(%rip),%rax
or     (%rax),%edx
mov    0x10(%r14),%rdi
mov    0x2d10(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1441 <main+0x291>
mov    %eax,%r15d
mov    0x2d6d(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,%ebp
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0x37fc,%ebp
mov    $0x37fc,%ebx
cmovl  %ebp,%ebx
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    %ebx,%edx
call   1080 <read@plt>
cmp    %ebx,%eax
jne    1480 <main+0x2d0>
pxor   %xmm0,%xmm0
mov    $0x14,%eax
pxor   %xmm2,%xmm2
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   -0x4(%rsp,%rax,1),%xmm4
movd   (%rsp,%rax,1),%xmm3
punpcklbw %xmm0,%xmm4
punpcklwd %xmm0,%xmm4
paddd  %xmm2,%xmm4
punpcklbw %xmm0,%xmm3
punpcklwd %xmm0,%xmm3
paddd  %xmm1,%xmm3
movq   0x4(%rsp,%rax,1),%xmm5
movd   0x8(%rsp,%rax,1),%xmm6
punpcklbw %xmm0,%xmm5
punpcklwd %xmm0,%xmm5
punpcklbw %xmm0,%xmm6
punpcklwd %xmm0,%xmm6
movq   0xc(%rsp,%rax,1),%xmm2
movd   0x10(%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    $0x380c,%rax
jne    12d0 <main+0x120>
paddd  %xmm2,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
movzbl 0x3808(%rsp),%ecx
add    %eax,%ecx
movzbl 0x3809(%rsp),%eax
add    %ecx,%eax
movzbl 0x380a(%rsp),%ecx
add    %eax,%ecx
movzbl 0x380b(%rsp),%eax
add    %ecx,%eax
mov    %eax,0xc(%rsp)
lea    0x380c(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x4000,%edx
call   1030 <write@plt>
cmp    $0x4000,%eax
jne    14a7 <main+0x2f7>
test   %r12d,%r12d
je     13ce <main+0x21e>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     13db <main+0x22b>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2b96(%rip),%rax
mov    (%rax),%eax
add    $0x4010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc05(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    14f6 <main+0x346>
mov    0x2ba2(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xbf3(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
jmp    14f6 <main+0x346>
mov    0x2b68(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%r15
mov    0x10(%r14),%r14
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xbb9(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     14f6 <main+0x346>
mov    %r12d,%edi
jmp    14f1 <main+0x341>
mov    0x2b29(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x8(%r14),%r14
mov    0x2b11(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb91(%rip),%rsi
jmp    14cc <main+0x31c>
mov    0x2b02(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%rbp
mov    0x10(%r14),%r14
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xb81(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1090 <fprintf@plt>
test   %r12d,%r12d
je     14e9 <main+0x339>
mov    %r12d,%edi
call   1070 <close@plt>
test   %r15d,%r15d
je     14f6 <main+0x346>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0x2a8b(%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 = [23 x i8] c"%s: Can't read %s: %s\0A\00"
@.str.3 = [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 = load i32, i32* %7
%92 = icmp slt i32 %91, 14332
br i1 %92, label %93, label %95
93: ; preds = %84
%94 = load i32, i32* %7
br label %96
95: ; preds = %84
br label %96
96: ; preds = %95, %93
%97 = phi i32 [ %94, %93 ], [ 14332, %95 ]
store i32 %97, i32* %12
%98 = load i32, i32* %9
%99 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%100 = load i32, i32* %12
%101 = call i32 @read(i32 %98, i8* %99, i32 %100)
%102 = load i32, i32* %12
%103 = icmp ne i32 %101, %102
br i1 %103, label %104, label %129
104: ; preds = %96
%105 = load i32, i32* @stderr
%106 = load i8**, i8*** %5
%107 = getelementptr inbounds i8*, i8** %106, i64 0
%108 = load i8*, i8** %107
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 1
%111 = load i8*, i8** %110
%112 = load i32, i32* @errno
%113 = call i8* @strerror(i32 %112)
%114 = call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %108, i8* %111, i8* %113)
%115 = load i32, i32* %9
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %104
%118 = load i32, i32* %9
%119 = call i32 @close(i32 %118)
br label %120
120: ; preds = %117, %104
%121 = load i32, i32* %10
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = load i32, i32* %10
%125 = call i32 @close(i32 %124)
br label %126
126: ; preds = %123, %120
%127 = load i32, i32* @EXIT_FAILURE
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %96
store i32 0, i32* %6
store i32 0, i32* %11
br label %130
130: ; preds = %141, %129
%131 = load i32, i32* %6
%132 = icmp slt i32 %131, 14332
br i1 %132, label %133, label %144
133: ; preds = %130
%134 = load i32, i32* %6
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 %135
%137 = load i8, i8* %136
%138 = zext i8 %137 to i32
%139 = load i32, i32* %11
%140 = add i32 %139, %138
store i32 %140, i32* %11
br label %141
141: ; preds = %133
%142 = load i32, i32* %6
%143 = add nsw i32 %142, 1
store i32 %143, i32* %6
br label %130
144: ; preds = %130
%145 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 14332
%146 = call i32 @memcpy(i8* %145, i32* %11, i32 4)
%147 = load i32, i32* %10
%148 = getelementptr inbounds [16384 x i8], [16384 x i8]* %8, i64 0, i64 0
%149 = call i32 @write(i32 %147, i8* %148, i32 16384)
%150 = icmp ne i32 %149, 16384
br i1 %150, label %151, label %176
151: ; preds = %144
%152 = load i32, i32* @stderr
%153 = load i8**, i8*** %5
%154 = getelementptr inbounds i8*, i8** %153, i64 0
%155 = load i8*, i8** %154
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 2
%158 = load i8*, i8** %157
%159 = load i32, i32* @errno
%160 = call i8* @strerror(i32 %159)
%161 = call i32 @fprintf(i32 %152, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %155, i8* %158, i8* %160)
%162 = load i32, i32* %9
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %151
%165 = load i32, i32* %9
%166 = call i32 @close(i32 %165)
br label %167
167: ; preds = %164, %151
%168 = load i32, i32* %10
%169 = icmp ne i32 %168, 0
br i1 %169, label %170, label %173
170: ; preds = %167
%171 = load i32, i32* %10
%172 = call i32 @close(i32 %171)
br label %173
173: ; preds = %170, %167
%174 = load i32, i32* @EXIT_FAILURE
%175 = call i32 @exit(i32 %174)
unreachable
176: ; preds = %144
%177 = load i32, i32* %9
%178 = icmp ne i32 %177, 0
br i1 %178, label %179, label %182
179: ; preds = %176
%180 = load i32, i32* %9
%181 = call i32 @close(i32 %180)
br label %182
182: ; preds = %179, %176
%183 = load i32, i32* %10
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %188
185: ; preds = %182
%186 = load i32, i32* %10
%187 = call i32 @close(i32 %186)
br label %188
188: ; preds = %185, %182
%189 = load i32, i32* @EXIT_SUCCESS
ret i32 %189
}

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 = [23 x i8] c"%s: Can't read %s: %s\0A\00"
@.str.3 = [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 = alloca i32
%5 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 (i8*, i32, ...) @open(i8* %14, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = load i8*, i8** %13
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21, i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @exit(i32 %25)
unreachable
27: ; preds = %12
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = load i32, i32* @O_WRONLY
%31 = load i32, i32* @O_CREAT
%32 = or i32 %31, %30
%33 = load i32, i32* @O_TRUNC
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IRUSR
%36 = load i32, i32* @S_IWUSR
%37 = or i32 %36, %35
%38 = load i32, i32* @S_IRGRP
%39 = or i32 %37, %38
%40 = load i32, i32* @S_IWGRP
%41 = or i32 %39, %40
%42 = load i32, i32* @S_IROTH
%43 = or i32 %41, %42
%44 = load i32, i32* @S_IWOTH
%45 = or i32 %43, %44
%46 = tail call i32 (i8*, i32, ...) @open(i8* %29, i32 %34, i32 %45)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %61
48: ; preds = %27
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %1
%51 = load i8*, i8** %28
%52 = load i32, i32* @errno
%53 = tail call i8* @strerror(i32 %52)
%54 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %50, i8* %51, i8* %53)
%55 = icmp eq i32 %16, 0
br i1 %55, label %58, label %56
56: ; preds = %48
%57 = tail call i32 @close(i32 %16)
br label %58
58: ; preds = %56, %48
%59 = load i32, i32* @EXIT_FAILURE
%60 = tail call i32 @exit(i32 %59)
unreachable
61: ; preds = %27
%62 = load i32, i32* @SEEK_END
%63 = tail call i32 @lseek(i32 %16, i32 0, i32 %62)
%64 = load i32, i32* @SEEK_SET
%65 = tail call i32 @lseek(i32 %16, i32 0, i32 %64)
%66 = icmp slt i32 %63, 14332
%67 = select i1 %66, i32 %63, i32 14332
%68 = call i32 @read(i32 %16, i8* %5, i32 %67)
%69 = icmp eq i32 %68, %67
br i1 %69, label %70, label %108
70: ; preds = %61, %70
%71 = phi i64 [ %106, %70 ], [ 0, %61 ]
%72 = phi <4 x i32> [ %104, %70 ], [ zeroinitializer, %61 ]
%73 = phi <4 x i32> [ %105, %70 ], [ zeroinitializer, %61 ]
%74 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 %71
%75 = bitcast i8* %74 to <4 x i8>*
%76 = load <4 x i8>, <4 x i8>* %75
%77 = getelementptr inbounds i8, i8* %74, i64 4
%78 = bitcast i8* %77 to <4 x i8>*
%79 = load <4 x i8>, <4 x i8>* %78
%80 = zext <4 x i8> %76 to <4 x i32>
%81 = zext <4 x i8> %79 to <4 x i32>
%82 = add <4 x i32> %72, %80
%83 = add <4 x i32> %73, %81
%84 = add nuw nsw i64 %71, 8
%85 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 %84
%86 = bitcast i8* %85 to <4 x i8>*
%87 = load <4 x i8>, <4 x i8>* %86
%88 = getelementptr inbounds i8, i8* %85, i64 4
%89 = bitcast i8* %88 to <4 x i8>*
%90 = load <4 x i8>, <4 x i8>* %89
%91 = zext <4 x i8> %87 to <4 x i32>
%92 = zext <4 x i8> %90 to <4 x i32>
%93 = add <4 x i32> %82, %91
%94 = add <4 x i32> %83, %92
%95 = add nuw nsw i64 %71, 16
%96 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 %95
%97 = bitcast i8* %96 to <4 x i8>*
%98 = load <4 x i8>, <4 x i8>* %97
%99 = getelementptr inbounds i8, i8* %96, i64 4
%100 = bitcast i8* %99 to <4 x i8>*
%101 = load <4 x i8>, <4 x i8>* %100
%102 = zext <4 x i8> %98 to <4 x i32>
%103 = zext <4 x i8> %101 to <4 x i32>
%104 = add <4 x i32> %93, %102
%105 = add <4 x i32> %94, %103
%106 = add nuw nsw i64 %71, 24
%107 = icmp eq i64 %106, 14328
br i1 %107, label %125, label %70
108: ; preds = %61
%109 = load i32, i32* @stderr
%110 = load i8*, i8** %1
%111 = load i8*, i8** %13
%112 = load i32, i32* @errno
%113 = tail call i8* @strerror(i32 %112)
%114 = tail call i32 @fprintf(i32 %109, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %110, i8* %111, i8* %113)
%115 = icmp eq i32 %16, 0
br i1 %115, label %118, label %116
116: ; preds = %108
%117 = tail call i32 @close(i32 %16)
br label %118
118: ; preds = %116, %108
%119 = icmp eq i32 %46, 0
br i1 %119, label %122, label %120
120: ; preds = %118
%121 = tail call i32 @close(i32 %46)
br label %122
122: ; preds = %120, %118
%123 = load i32, i32* @EXIT_FAILURE
%124 = tail call i32 @exit(i32 %123)
unreachable
125: ; preds = %70
%126 = add <4 x i32> %105, %104
%127 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %126)
%128 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14328
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = add i32 %127, %130
%132 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14329
%133 = load i8, i8* %132
%134 = zext i8 %133 to i32
%135 = add i32 %131, %134
%136 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14330
%137 = load i8, i8* %136
%138 = zext i8 %137 to i32
%139 = add i32 %135, %138
%140 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14331
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = add i32 %139, %142
store i32 %143, i32* %4
%144 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 14332
%145 = call i32 @memcpy(i8* %144, i32* %4, i32 4)
%146 = call i32 @write(i32 %46, i8* %5, i32 16384)
%147 = icmp eq i32 %146, 16384
br i1 %147, label %165, label %148
148: ; preds = %125
%149 = load i32, i32* @stderr
%150 = load i8*, i8** %1
%151 = load i8*, i8** %28
%152 = load i32, i32* @errno
%153 = call i8* @strerror(i32 %152)
%154 = call i32 @fprintf(i32 %149, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %150, i8* %151, i8* %153)
%155 = icmp eq i32 %16, 0
br i1 %155, label %158, label %156
156: ; preds = %148
%157 = call i32 @close(i32 %16)
br label %158
158: ; preds = %156, %148
%159 = icmp eq i32 %46, 0
br i1 %159, label %162, label %160
160: ; preds = %158
%161 = call i32 @close(i32 %46)
br label %162
162: ; preds = %160, %158
%163 = load i32, i32* @EXIT_FAILURE
%164 = call i32 @exit(i32 %163)
unreachable
165: ; preds = %125
%166 = icmp eq i32 %16, 0
br i1 %166, label %169, label %167
167: ; preds = %165
%168 = call i32 @close(i32 %16)
br label %169
169: ; preds = %167, %165
%170 = icmp eq i32 %46, 0
br i1 %170, label %173, label %171
171: ; preds = %169
%172 = call i32 @close(i32 %46)
br label %173
173: ; preds = %171, %169
%174 = load i32, i32* @EXIT_SUCCESS
ret i32 %174
}