#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 */
struct stat {
  scalar_t__ st_size;
};
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ PROT_WRITE;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fstat(int, struct stat *);
scalar_t__ ftruncate(int, scalar_t__);
int /*<<< orphan*/ memcpy(void *, void *, scalar_t__);
void *mmap(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/,
           int /*<<< orphan*/, int, scalar_t__);
int /*<<< orphan*/ munmap(void *, scalar_t__);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int src, dst;
  if (argc < 3) {
    fprintf(stderr, "Usage: %s source destination\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((src = open(argv[1], O_RDONLY)) < 0) {
    perror("Unable to open source file for reading");
    exit(EXIT_FAILURE);
  }
  if ((dst = open(
           argv[2], O_RDWR | O_CREAT | O_TRUNC,
           (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) < 0) {
    perror("Unable to open target file for writing");
    exit(EXIT_FAILURE);
  }
  struct stat statbuf;
  if (fstat(src, &statbuf) < 0) {
    perror("Couldn't determine source file size");
    exit(EXIT_FAILURE);
  }
  if (ftruncate(dst, statbuf.st_size) < 0) {
    perror("Couldn't set target file size");
    exit(EXIT_FAILURE);
  }
  off_t written = 0;
  while (written < statbuf.st_size) {
    off_t incr;
    if (statbuf.st_size - written > (1024 * 1024 * 1024)) {
      incr = (1024 * 1024 * 1024);
    } else {
      incr = statbuf.st_size - written;
    }
    void *src_buf, *dst_buf;
    if ((src_buf = mmap(NULL, incr, PROT_READ, MAP_SHARED, src, written)) ==
        MAP_FAILED) {
      perror("mmap() failed on source file");
      exit(EXIT_FAILURE);
    }
    if ((dst_buf = mmap(NULL, incr, PROT_WRITE, MAP_SHARED, dst, written)) ==
        MAP_FAILED) {
      perror("mmap() failed on destination file");
      exit(EXIT_FAILURE);
    }
    memcpy(dst_buf, src_buf, incr);
    munmap(src_buf, incr);
    munmap(dst_buf, incr);
    written += incr;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11da <main+0x4a>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe39(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1218 <main+0x88>
lea    0xe19(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2dc8(%rip),%rax
or     (%rax),%esi
mov    0x2db7(%rip),%rax
or     (%rax),%esi
mov    0x2d36(%rip),%rax
mov    (%rax),%edx
mov    0x2d65(%rip),%rax
or     (%rax),%edx
mov    0x2d44(%rip),%rax
or     (%rax),%edx
mov    0x2d5b(%rip),%rax
or     (%rax),%edx
mov    0x2d2a(%rip),%rax
or     (%rax),%edx
mov    0x2cf1(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    129e <main+0x10e>
lea    0xdba(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   10b0 <fstat@plt>
cmp    $0x0,%rax
jge    12ce <main+0x13e>
lea    0xdb1(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <ftruncate@plt>
cmp    $0x0,%rax
jge    12fe <main+0x16e>
lea    0xda5(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1427 <main+0x297>
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
cmp    $0x40000000,%rax
jle    1335 <main+0x1a5>
movq   $0x40000000,-0x30(%rbp)
40
jmp    1341 <main+0x1b1>
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    0x2c9c(%rip),%rax
mov    (%rax),%edx
mov    0x2c83(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x28(%rbp),%r9
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    0x2bfd(%rip),%rcx
cmp    (%rcx),%rax
jne    1396 <main+0x206>
lea    0xd2b(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x30(%rbp),%rsi
mov    0x2bdf(%rip),%rax
mov    (%rax),%edx
mov    0x2c2e(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x28(%rbp),%r9
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mmap@plt>
mov    %rax,-0x40(%rbp)
mov    0x2ba8(%rip),%rcx
cmp    (%rcx),%rax
jne    13eb <main+0x25b>
lea    0xcf3(%rip),%rdi
call   1090 <perror@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <munmap@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <munmap@plt>
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1306 <main+0x176>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    1351 <main+0x1c1>
mov    0x8(%rbx),%rdi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     136b <main+0x1db>
mov    0x2df7(%rip),%rax
mov    0x2e20(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e0d(%rip),%rax
or     (%rax),%esi
mov    0x2d8c(%rip),%rax
mov    0x2dbd(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d9a(%rip),%rax
or     (%rax),%edx
mov    0x2db1(%rip),%rax
or     (%rax),%edx
mov    0x2d80(%rip),%rax
or     (%rax),%edx
mov    0x10(%rbx),%rdi
mov    0x2d43(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,(%rsp)
test   %eax,%eax
js     1374 <main+0x1e4>
lea    0x10(%rsp),%rsi
mov    0x4(%rsp),%edi
call   10b0 <fstat@plt>
test   %rax,%rax
js     137d <main+0x1ed>
mov    0x10(%rsp),%rbx
mov    (%rsp),%edi
mov    %rbx,%rsi
call   1040 <ftruncate@plt>
test   %rax,%rax
js     1386 <main+0x1f6>
test   %rbx,%rbx
jle    131d <main+0x18d>
xor    %r13d,%r13d
mov    0x2d64(%rip),%r14
mov    0x2cf5(%rip),%r15
mov    %rbx,0x8(%rsp)
sub    %r13,%rbx
cmp    $0x40000000,%rbx
mov    $0x40000000,%eax
cmovge %rax,%rbx
mov    0x2d4e(%rip),%rax
mov    (%rax),%edx
mov    (%r14),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    0x4(%rsp),%r8d
mov    %r13,%r9
call   1030 <mmap@plt>
cmp    (%r15),%rax
je     132e <main+0x19e>
mov    %rax,%rbp
mov    0x2cc0(%rip),%rax
mov    (%rax),%edx
mov    (%r14),%ecx
xor    %edi,%edi
mov    %rbx,%rsi
mov    (%rsp),%r8d
mov    %r13,%r9
call   1030 <mmap@plt>
cmp    (%r15),%rax
je     1337 <main+0x1a7>
mov    %rax,%r14
mov    %r15,%r12
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <munmap@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <munmap@plt>
add    %rbx,%r13
mov    0x8(%rsp),%rbx
cmp    %r13,%rbx
mov    0x2cc1(%rip),%r14
jg     1280 <main+0xf0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd79(%rip),%rdi
jmp    133e <main+0x1ae>
lea    0xd8d(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc9c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1343 <main+0x1b3>
lea    0xcac(%rip),%rdi
jmp    133e <main+0x1ae>
lea    0xcca(%rip),%rdi
jmp    133e <main+0x1ae>
lea    0xce8(%rip),%rdi
jmp    133e <main+0x1ae>
lea    0xd03(%rip),%rdi
jmp    133e <main+0x1ae>

LLVM IR (-O0):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source destination\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [39 x i8] c"Unable to open source file for reading\00"
@O_RDWR = 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
@.str.2 = [39 x i8] c"Unable to open target file for writing\00"
@.str.3 = [36 x i8] c"Couldn't determine source file size\00"
@.str.4 = [30 x i8] c"Couldn't set target file size\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [29 x i8] c"mmap() failed on source file\00"
@PROT_WRITE = global i32 0
@.str.6 = [34 x i8] c"mmap() failed on destination file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.stat
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 (i8*, i32, ...) @open(i8* %26, i32 %27)
store i32 %28, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDWR
%39 = load i32, i32* @O_CREAT
%40 = or i32 %38, %39
%41 = load i32, i32* @O_TRUNC
%42 = or i32 %40, %41
%43 = load i32, i32* @S_IRUSR
%44 = load i32, i32* @S_IWUSR
%45 = or i32 %43, %44
%46 = load i32, i32* @S_IRGRP
%47 = or i32 %45, %46
%48 = load i32, i32* @S_IWGRP
%49 = or i32 %47, %48
%50 = load i32, i32* @S_IROTH
%51 = or i32 %49, %50
%52 = load i32, i32* @S_IWOTH
%53 = or i32 %51, %52
%54 = call i32 (i8*, i32, ...) @open(i8* %37, i32 %42, i32 %53)
store i32 %54, i32* %7
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %34
%57 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %34
%61 = load i32, i32* %6
%62 = call i64 @fstat(i32 %61, %struct.stat* %8)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %60
%69 = load i32, i32* %7
%70 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%71 = load i64, i64* %70
%72 = call i64 @ftruncate(i32 %69, i64 %71)
%73 = icmp slt i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %68
%75 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %68
store i64 0, i64* %9
br label %79
79: ; preds = %122, %78
%80 = load i64, i64* %9
%81 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%82 = load i64, i64* %81
%83 = icmp slt i64 %80, %82
br i1 %83, label %84, label %136
84: ; preds = %79
%85 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%86 = load i64, i64* %85
%87 = load i64, i64* %9
%88 = sub nsw i64 %86, %87
%89 = icmp sgt i64 %88, 1073741824
br i1 %89, label %90, label %91
90: ; preds = %84
store i64 1073741824, i64* %10
br label %96
91: ; preds = %84
%92 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%93 = load i64, i64* %92
%94 = load i64, i64* %9
%95 = sub nsw i64 %93, %94
store i64 %95, i64* %10
br label %96
96: ; preds = %91, %90
%97 = load i64, i64* %10
%98 = load i32, i32* @PROT_READ
%99 = load i32, i32* @MAP_SHARED
%100 = load i32, i32* %6
%101 = load i64, i64* %9
%102 = call i8* @mmap(i32* null, i64 %97, i32 %98, i32 %99, i32 %100, i64 %101)
store i8* %102, i8** %11
%103 = load i8*, i8** @MAP_FAILED
%104 = icmp eq i8* %102, %103
br i1 %104, label %105, label %109
105: ; preds = %96
%106 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%107 = load i32, i32* @EXIT_FAILURE
%108 = call i32 @exit(i32 %107)
unreachable
109: ; preds = %96
%110 = load i64, i64* %10
%111 = load i32, i32* @PROT_WRITE
%112 = load i32, i32* @MAP_SHARED
%113 = load i32, i32* %7
%114 = load i64, i64* %9
%115 = call i8* @mmap(i32* null, i64 %110, i32 %111, i32 %112, i32 %113, i64 %114)
store i8* %115, i8** %12
%116 = load i8*, i8** @MAP_FAILED
%117 = icmp eq i8* %115, %116
br i1 %117, label %118, label %122
118: ; preds = %109
%119 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %109
%123 = load i8*, i8** %12
%124 = load i8*, i8** %11
%125 = load i64, i64* %10
%126 = call i32 @memcpy(i8* %123, i8* %124, i64 %125)
%127 = load i8*, i8** %11
%128 = load i64, i64* %10
%129 = call i32 @munmap(i8* %127, i64 %128)
%130 = load i8*, i8** %12
%131 = load i64, i64* %10
%132 = call i32 @munmap(i8* %130, i64 %131)
%133 = load i64, i64* %10
%134 = load i64, i64* %9
%135 = add nsw i64 %134, %133
store i64 %135, i64* %9
br label %79
136: ; preds = %79
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source destination\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [39 x i8] c"Unable to open source file for reading\00"
@O_RDWR = 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
@.str.2 = [39 x i8] c"Unable to open target file for writing\00"
@.str.3 = [36 x i8] c"Couldn't determine source file size\00"
@.str.4 = [30 x i8] c"Couldn't set target file size\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [29 x i8] c"mmap() failed on source file\00"
@PROT_WRITE = global i32 0
@.str.6 = [34 x i8] c"mmap() failed on destination file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 (i8*, i32, ...) @open(i8* %13, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %11
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDWR
%25 = load i32, i32* @O_CREAT
%26 = or i32 %25, %24
%27 = load i32, i32* @O_TRUNC
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IRUSR
%30 = load i32, i32* @S_IWUSR
%31 = or i32 %30, %29
%32 = load i32, i32* @S_IRGRP
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IWGRP
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IROTH
%37 = or i32 %35, %36
%38 = load i32, i32* @S_IWOTH
%39 = or i32 %37, %38
%40 = tail call i32 (i8*, i32, ...) @open(i8* %23, i32 %28, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %21
%43 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %21
%47 = bitcast %struct.stat* %3 to i8*
%48 = call i64 @fstat(i32 %15, %struct.stat* %3)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %46
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%56 = load i64, i64* %55
%57 = tail call i64 @ftruncate(i32 %40, i64 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %54
%60 = icmp sgt i64 %56, 0
br i1 %60, label %65, label %95
61: ; preds = %54
%62 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @exit(i32 %63)
unreachable
65: ; preds = %59, %89
%66 = phi i64 [ %93, %89 ], [ 0, %59 ]
%67 = sub nsw i64 %56, %66
%68 = icmp slt i64 %67, 1073741824
%69 = select i1 %68, i64 %67, i64 1073741824
%70 = load i32, i32* @PROT_READ
%71 = load i32, i32* @MAP_SHARED
%72 = tail call i8* @mmap(i32* null, i64 %69, i32 %70, i32 %71, i32 %15, i64 %66)
%73 = load i8*, i8** @MAP_FAILED
%74 = icmp eq i8* %72, %73
br i1 %74, label %75, label %79
75: ; preds = %65
%76 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = tail call i32 @exit(i32 %77)
unreachable
79: ; preds = %65
%80 = load i32, i32* @PROT_WRITE
%81 = load i32, i32* @MAP_SHARED
%82 = tail call i8* @mmap(i32* null, i64 %69, i32 %80, i32 %81, i32 %40, i64 %66)
%83 = load i8*, i8** @MAP_FAILED
%84 = icmp eq i8* %82, %83
br i1 %84, label %85, label %89
85: ; preds = %79
%86 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%87 = load i32, i32* @EXIT_FAILURE
%88 = tail call i32 @exit(i32 %87)
unreachable
89: ; preds = %79
%90 = tail call i32 @memcpy(i8* %82, i8* %72, i64 %69)
%91 = tail call i32 @munmap(i8* %72, i64 %69)
%92 = tail call i32 @munmap(i8* %82, i64 %69)
%93 = add nsw i64 %69, %66
%94 = icmp sgt i64 %56, %93
br i1 %94, label %65, label %95
95: ; preds = %89, %59
ret i32 0
}