#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 void *ssize_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ close(int);
int /*<<< orphan*/ exit(int);
void *lseek(int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(void *, void *, size_t);
void *mmap(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
scalar_t__ munmap(void *, size_t);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
void *write(int, char *, int);
int main(int argc, char *argv[]) {
  int fdi, fdo;
  void *src, *dst;
  size_t size;
  ssize_t offset;
  if (argc != 3) {
    printf("E: Need 2 filenames as arguments.\n");
    return EXIT_FAILURE;
  }
  if ((fdi = open(argv[1], O_RDONLY)) < 0) {
    perror("E: Can not open input file");
    exit(EXIT_FAILURE);
  }
  size = lseek(fdi, 0, SEEK_END);
  src = mmap(NULL, size, PROT_READ, MAP_SHARED, fdi, 0);
  if (src == (void *)-1) {
    perror("E: Can not map input file");
    exit(EXIT_FAILURE);
  }
  if ((fdo = open(argv[2], O_CREAT | O_RDWR | O_TRUNC, 00666)) < 0) {
    perror("E: Can not open output file");
    exit(EXIT_FAILURE);
  }
  offset = lseek(fdo, size - 1, SEEK_SET);
  if (offset == (ssize_t)-1) {
    perror("E: lseek() error");
    exit(EXIT_FAILURE);
  }
  offset = write(fdo, "", 1);
  if (offset == (ssize_t)-1) {
    perror("E: write() error");
    exit(EXIT_FAILURE);
  }
  dst = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fdo, 0);
  if (dst == MAP_FAILED) {
    perror("E: Can not map output file");
    exit(EXIT_FAILURE);
  }
  memcpy(dst, src, size);
  if (munmap(src, size)) {
    perror("E: Can not unmap input file");
    exit(EXIT_FAILURE);
  }
  if (munmap(dst, size)) {
    perror("E: Can not unmap output file");
    exit(EXIT_FAILURE);
  }
  if (close(fdi)) {
    perror("E: Can not close input file");
    exit(EXIT_FAILURE);
  }
  if (close(fdo)) {
    perror("E: Can not close output file");
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


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)
je     11dd <main+0x3d>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1498 <main+0x2f8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    121b <main+0x7b>
lea    0xe1b(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <lseek@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
mov    0x2d90(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x20(%rbp)
jne    1289 <main+0xe9>
lea    0xdc8(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
mov    0x2d27(%rip),%rax
or     (%rax),%esi
mov    0x2d46(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    12de <main+0x13e>
lea    0xd8d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
sub    $0x1,%rsi
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek@plt>
mov    %rax,-0x38(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x38(%rbp)
jne    1326 <main+0x186>
lea    0xd61(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%edi
lea    0xcf2(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %rax,-0x38(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x38(%rbp)
jne    1369 <main+0x1c9>
lea    0xd2f(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rsi
mov    0x2c24(%rip),%rax
mov    (%rax),%edx
mov    0x2c5b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bea(%rip),%rcx
cmp    (%rcx),%rax
jne    13c1 <main+0x221>
lea    0xce8(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <munmap@plt>
cmp    $0x0,%rax
je     1403 <main+0x263>
lea    0xcc1(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <munmap@plt>
cmp    $0x0,%rax
je     1434 <main+0x294>
lea    0xcac(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
cmp    $0x0,%rax
je     1460 <main+0x2c0>
lea    0xc9d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b47(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
cmp    $0x0,%rax
je     148c <main+0x2ec>
lea    0xc8d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b1b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2afd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x3,%edi
jne    130b <main+0x16b>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10a0 <open@plt>
test   %eax,%eax
js     1329 <main+0x189>
mov    %eax,%r14d
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %rax,%r12
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    0x2ddf(%rip),%rbx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    %r12,%rsi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     1332 <main+0x192>
mov    %rax,%r15
mov    0x2dd9(%rip),%rax
mov    0x2da2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%rbp),%rdi
mov    0x2dbb(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
xor    %eax,%eax
call   10a0 <open@plt>
test   %eax,%eax
js     133b <main+0x19b>
mov    %eax,%ebp
lea    -0x1(%r12),%rsi
mov    0x2d4f(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1060 <lseek@plt>
cmp    $0xffffffffffffffff,%rax
je     1344 <main+0x1a4>
lea    0xeae(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffffffffffff,%rax
je     134d <main+0x1ad>
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    %r12,%rsi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    0x2cda(%rip),%rax
cmp    (%rax),%rbx
je     1356 <main+0x1b6>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1080 <memcpy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <munmap@plt>
test   %rax,%rax
jne    135f <main+0x1bf>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <munmap@plt>
test   %rax,%rax
jne    1368 <main+0x1c8>
mov    %r14d,%edi
call   1070 <close@plt>
test   %rax,%rax
jne    1371 <main+0x1d1>
mov    %ebp,%edi
call   1070 <close@plt>
test   %rax,%rax
jne    137a <main+0x1da>
mov    0x2c87(%rip),%rax
jmp    131e <main+0x17e>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd0(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xce2(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xcf3(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd06(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd0e(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd16(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd28(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd3b(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd4f(%rip),%rdi
jmp    1381 <main+0x1e1>
lea    0xd62(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"E: Need 2 filenames as arguments.\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [27 x i8] c"E: Can not open input file\00"
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.2 = [26 x i8] c"E: Can not map input file\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [28 x i8] c"E: Can not open output file\00"
@SEEK_SET = global i32 0
@.str.4 = [17 x i8] c"E: lseek() error\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [17 x i8] c"E: write() error\00"
@PROT_WRITE = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [27 x i8] c"E: Can not map output file\00"
@.str.8 = [28 x i8] c"E: Can not unmap input file\00"
@.str.9 = [29 x i8] c"E: Can not unmap output file\00"
@.str.10 = [28 x i8] c"E: Can not close input file\00"
@.str.11 = [29 x i8] c"E: Can not close output file\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 i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %133
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 (i8*, i32, ...) @open(i8* %20, i32 %21)
store i32 %22, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = load i32, i32* %6
%30 = load i32, i32* @SEEK_END
%31 = call i8* @lseek(i32 %29, i64 0, i32 %30)
%32 = ptrtoint i8* %31 to i64
store i64 %32, i64* %10
%33 = load i64, i64* %10
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @MAP_SHARED
%36 = load i32, i32* %6
%37 = call i8* @mmap(i32* null, i64 %33, i32 %34, i32 %35, i32 %36, i32 0)
store i8* %37, i8** %8
%38 = load i8*, i8** %8
%39 = icmp eq i8* %38, inttoptr (i64 -1 to i8*)
br i1 %39, label %40, label %44
40: ; preds = %28
%41 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %28
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = load i32, i32* @O_CREAT
%49 = load i32, i32* @O_RDWR
%50 = or i32 %48, %49
%51 = load i32, i32* @O_TRUNC
%52 = or i32 %50, %51
%53 = call i32 (i8*, i32, ...) @open(i8* %47, i32 %52, i32 438)
store i32 %53, i32* %7
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %44
%56 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %44
%60 = load i32, i32* %7
%61 = load i64, i64* %10
%62 = sub i64 %61, 1
%63 = load i32, i32* @SEEK_SET
%64 = call i8* @lseek(i32 %60, i64 %62, i32 %63)
store i8* %64, i8** %11
%65 = load i8*, i8** %11
%66 = icmp eq i8* %65, inttoptr (i64 -1 to i8*)
br i1 %66, label %67, label %71
67: ; preds = %59
%68 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %59
%72 = load i32, i32* %7
%73 = call i8* @write(i32 %72, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i32 1)
store i8* %73, i8** %11
%74 = load i8*, i8** %11
%75 = icmp eq i8* %74, inttoptr (i64 -1 to i8*)
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %71
%81 = load i64, i64* %10
%82 = load i32, i32* @PROT_WRITE
%83 = load i32, i32* @MAP_SHARED
%84 = load i32, i32* %7
%85 = call i8* @mmap(i32* null, i64 %81, i32 %82, i32 %83, i32 %84, i32 0)
store i8* %85, i8** %9
%86 = load i8*, i8** %9
%87 = load i8*, i8** @MAP_FAILED
%88 = icmp eq i8* %86, %87
br i1 %88, label %89, label %93
89: ; preds = %80
%90 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %80
%94 = load i8*, i8** %9
%95 = load i8*, i8** %8
%96 = load i64, i64* %10
%97 = call i32 @memcpy(i8* %94, i8* %95, i64 %96)
%98 = load i8*, i8** %8
%99 = load i64, i64* %10
%100 = call i64 @munmap(i8* %98, i64 %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %106
102: ; preds = %93
%103 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %93
%107 = load i8*, i8** %9
%108 = load i64, i64* %10
%109 = call i64 @munmap(i8* %107, i64 %108)
%110 = icmp ne i64 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %106
%112 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %106
%116 = load i32, i32* %6
%117 = call i64 @close(i32 %116)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %115
%120 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %115
%124 = load i32, i32* %7
%125 = call i64 @close(i32 %124)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %123
%128 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%129 = load i32, i32* @EXIT_FAILURE
%130 = call i32 @exit(i32 %129)
unreachable
131: ; preds = %123
%132 = load i32, i32* @EXIT_SUCCESS
store i32 %132, i32* %3
br label %133
133: ; preds = %131, %14
%134 = load i32, i32* %3
ret i32 %134
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [27 x i8] c"E: Can not open input file\00"
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.2 = [26 x i8] c"E: Can not map input file\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [28 x i8] c"E: Can not open output file\00"
@SEEK_SET = global i32 0
@.str.4 = [17 x i8] c"E: lseek() error\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [17 x i8] c"E: write() error\00"
@PROT_WRITE = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [27 x i8] c"E: Can not map output file\00"
@.str.8 = [28 x i8] c"E: Can not unmap input file\00"
@.str.9 = [29 x i8] c"E: Can not unmap output file\00"
@.str.10 = [28 x i8] c"E: Can not close input file\00"
@.str.11 = [29 x i8] c"E: Can not close output file\00"
@EXIT_SUCCESS = global i32 0
@str = [34 x i8] c"E: Need 2 filenames as arguments.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %97
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 (i8*, i32, ...) @open(i8* %8, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %6
%17 = load i32, i32* @SEEK_END
%18 = tail call i8* @lseek(i32 %10, i64 0, i32 %17)
%19 = ptrtoint i8* %18 to i64
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @MAP_SHARED
%22 = tail call i8* @mmap(i32* null, i64 %19, i32 %20, i32 %21, i32 %10, i32 0)
%23 = icmp eq i8* %22, inttoptr (i64 -1 to i8*)
br i1 %23, label %24, label %28
24: ; preds = %16
%25 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %16
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = load i32, i32* @O_CREAT
%32 = load i32, i32* @O_RDWR
%33 = or i32 %32, %31
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = tail call i32 (i8*, i32, ...) @open(i8* %30, i32 %35, i32 438)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %28
%39 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %28
%43 = add i64 %19, -1
%44 = load i32, i32* @SEEK_SET
%45 = tail call i8* @lseek(i32 %36, i64 %43, i32 %44)
%46 = icmp eq i8* %45, inttoptr (i64 -1 to i8*)
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
%50 = tail call i32 @exit(i32 %49)
unreachable
51: ; preds = %42
%52 = tail call i8* @write(i32 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i32 1)
%53 = icmp eq i8* %52, inttoptr (i64 -1 to i8*)
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
%57 = tail call i32 @exit(i32 %56)
unreachable
58: ; preds = %51
%59 = load i32, i32* @PROT_WRITE
%60 = load i32, i32* @MAP_SHARED
%61 = tail call i8* @mmap(i32* null, i64 %19, i32 %59, i32 %60, i32 %36, i32 0)
%62 = load i8*, i8** @MAP_FAILED
%63 = icmp eq i8* %61, %62
br i1 %63, label %64, label %68
64: ; preds = %58
%65 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = tail call i32 @exit(i32 %66)
unreachable
68: ; preds = %58
%69 = tail call i32 @memcpy(i8* %61, i8* %22, i64 %19)
%70 = tail call i64 @munmap(i8* %22, i64 %19)
%71 = icmp eq i64 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %68
%73 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = tail call i32 @exit(i32 %74)
unreachable
76: ; preds = %68
%77 = tail call i64 @munmap(i8* %61, i64 %19)
%78 = icmp eq i64 %77, 0
br i1 %78, label %83, label %79
79: ; preds = %76
%80 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = tail call i32 @exit(i32 %81)
unreachable
83: ; preds = %76
%84 = tail call i64 @close(i32 %10)
%85 = icmp eq i64 %84, 0
br i1 %85, label %90, label %86
86: ; preds = %83
%87 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
%89 = tail call i32 @exit(i32 %88)
unreachable
90: ; preds = %83
%91 = tail call i64 @close(i32 %36)
%92 = icmp eq i64 %91, 0
br i1 %92, label %97, label %93
93: ; preds = %90
%94 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = tail call i32 @exit(i32 %95)
unreachable
97: ; preds = %90, %4
%98 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %90 ]
%99 = load i32, i32* %98
ret i32 %99
}