#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_dev;
  scalar_t__ st_ino;
  scalar_t__ st_size;
  int /*<<< orphan*/ st_mode;
};
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ R_OK;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ _SC_PAGE_SIZE;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ basename(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err_exit(char *, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *file_path_combine(char *, int /*<<< orphan*/);
scalar_t__ fstat(int, struct stat *);
scalar_t__ ftruncate(int, scalar_t__);
int /*<<< orphan*/ memcpy(void *, void *, size_t);
void *mmap(int /*<<< orphan*/, size_t, int, int /*<<< orphan*/, int,
           scalar_t__);
int /*<<< orphan*/ munmap(void *, size_t);
int open(char *, int, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
long sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc != 3) {
    usage();
    exit(EXIT_FAILURE);
  }
  char *source, *target, *dest;
  struct stat stat_buf, stat_buf1;
  source = argv[1];
  target = argv[2];
  if (stat(source, &stat_buf) < 0) {
    err_exit("tcpm: cannot stat '%s': %s\n", source, strerror(errno));
  }
  if (!S_ISREG(stat_buf.st_mode)) {
    err_exit("tcpm: '%s' doesn't point to a regular file'\n", source);
  }
  if (access(source, R_OK) < 0) {
    err_exit("tcpm: '%s': no read permission\n", source);
  }
  if (access(target, F_OK) == 0) {
    if (stat(target, &stat_buf1) < 0) {
      err_exit("tcpm: cannot stat '%s': %s\n", target, strerror(errno));
    }
    if (S_ISREG(stat_buf1.st_mode)) {
      dest = target;
    } else if (S_ISDIR(stat_buf1.st_mode)) {
      dest = file_path_combine(target, basename(source));
    } else {
      err_exit("tcpm: '%s' isn't a regular file or a directory'\n", target);
    }
  } else {
    dest = target;
  }
  if (access(dest, F_OK) == 0) {
    if (stat(dest, &stat_buf1) < 0) {
      err_exit("tcpm: cannot stat '%s': %s\n", dest, strerror(errno));
    }
    if (stat_buf.st_dev == stat_buf1.st_dev &&
        stat_buf.st_ino == stat_buf1.st_ino) {
      exit(EXIT_SUCCESS);
    }
  }
  int src_fd, dest_fd;
  struct stat src_stat;
  off_t pos;
  size_t map_len;
  void *src_addr, *dest_addr;
  long page_size;
  pos = 0;
  page_size = sysconf(_SC_PAGE_SIZE);
  if (page_size < 0) {
    page_size = 4096;
  }
  if ((src_fd = open(source, O_RDONLY)) == -1) {
    err_exit("tcpm: cannot open '%s': %s\n", source, strerror(errno));
  }
  if ((dest_fd = open(dest, O_RDWR | O_CREAT | O_TRUNC, stat_buf.st_mode)) ==
      -1) {
    err_exit("tcpm: cannot open '%s': %s\n", dest, strerror(errno));
  }
  if (fstat(src_fd, &src_stat) < 0) {
    err_exit("tcpm: cannot fstat '%s': %s\n", source, strerror(errno));
  }
  if (ftruncate(dest_fd, src_stat.st_size) < 0) {
    err_exit("tcpm: cannot ftruncate '%s': %s\n", dest, strerror(errno));
  }
  while (pos < src_stat.st_size) {
    if (src_stat.st_size - pos > page_size) {
      map_len = page_size;
    } else {
      map_len = src_stat.st_size - pos;
    }
    if ((src_addr = mmap(0, map_len, PROT_READ, MAP_SHARED, src_fd, pos)) ==
        MAP_FAILED) {
      err_exit("tcpm: mmap error for '%s': %s\n", source, strerror(errno));
    }
    if ((dest_addr = mmap(0, map_len, PROT_READ | PROT_WRITE, MAP_SHARED,
                          dest_fd, pos)) == MAP_FAILED) {
      err_exit("tcpm: mmap error for '%s': %s\n", dest, strerror(errno));
    }
    memcpy(dest_addr, src_addr, map_len);
    munmap(src_addr, map_len);
    munmap(dest_addr, map_len);
    pos += map_len;
  }
  close(src_fd);
  close(dest_fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1258 <main+0x38>
mov    $0x0,%al
call   10e0 <usage@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jge    12b7 <main+0x97>
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xc0(%rbp),%rsi
mov    %eax,%edx
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x30(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
jne    12db <main+0xbb>
mov    -0x18(%rbp),%rsi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cb2(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
jge    1309 <main+0xe9>
mov    -0x18(%rbp),%rsi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2c5c(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
jne    13e4 <main+0x1c4>
mov    -0x20(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jge    136c <main+0x14c>
mov    -0x20(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x50(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     138b <main+0x16b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    13df <main+0x1bf>
mov    -0x50(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     13c8 <main+0x1a8>
mov    -0x20(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <basename@plt>
mov    -0xd0(%rbp),%rdi
mov    %eax,%esi
call   10c0 <file_path_combine@plt>
mov    %rax,-0x28(%rbp)
jmp    13da <main+0x1ba>
mov    -0x20(%rbp),%rsi
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
jmp    13df <main+0x1bf>
jmp    13ec <main+0x1cc>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2b79(%rip),%rax
mov    (%rax),%esi
call   1100 <access@plt>
cmp    $0x0,%rax
jne    147e <main+0x25e>
mov    -0x28(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jge    144f <main+0x22f>
mov    -0x28(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xd8(%rbp),%rsi
mov    %eax,%edx
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x48(%rbp),%rax
cmp    -0x68(%rbp),%rax
jne    1479 <main+0x259>
mov    -0x40(%rbp),%rax
cmp    -0x60(%rbp),%rax
jne    1479 <main+0x259>
mov    0x2b16(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
jmp    147e <main+0x25e>
movq   $0x0,-0x98(%rbp)
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
call   1110 <sysconf@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
jge    14b7 <main+0x297>
movq   $0x1000,-0xb8(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2afe(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x6c(%rbp)
cmp    $0xffffffff,%eax
jne    1507 <main+0x2e7>
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    0x2ac7(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xe0(%rbp),%rsi
mov    %eax,%edx
lea    0xb9a(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x28(%rbp),%rdi
mov    0x2ab6(%rip),%rax
mov    (%rax),%esi
mov    0x2add(%rip),%rax
or     (%rax),%esi
mov    0x2acc(%rip),%rax
or     (%rax),%esi
mov    -0x30(%rbp),%edx
mov    $0x0,%al
call   10f0 <open@plt>
mov    %eax,-0x70(%rbp)
cmp    $0xffffffff,%eax
jne    156c <main+0x34c>
mov    -0x28(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    0x2a62(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xe8(%rbp),%rsi
mov    %eax,%edx
lea    0xb35(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x6c(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1140 <fstat@plt>
cmp    $0x0,%rax
jge    15b5 <main+0x395>
mov    -0x18(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    0x2a19(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xf0(%rbp),%rsi
mov    %eax,%edx
lea    0xb08(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0x70(%rbp),%edi
mov    -0x80(%rbp),%rsi
call   1050 <ftruncate@plt>
cmp    $0x0,%rax
jge    15fb <main+0x3db>
mov    -0x28(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    0x29d3(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xf8(%rbp),%rsi
mov    %eax,%edx
lea    0xadf(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
jmp    1600 <main+0x3e0>
mov    -0x98(%rbp),%rax
cmp    -0x80(%rbp),%rax
jge    1795 <main+0x575>
mov    -0x80(%rbp),%rax
sub    -0x98(%rbp),%rax
cmp    -0xb8(%rbp),%rax
jle    163c <main+0x41c>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
jmp    164e <main+0x42e>
mov    -0x80(%rbp),%rax
sub    -0x98(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rsi
mov    0x298c(%rip),%rax
mov    (%rax),%edx
mov    0x2973(%rip),%rax
mov    (%rax),%ecx
mov    -0x6c(%rbp),%r8d
mov    -0x98(%rbp),%r9
xor    %edi,%edi
call   1030 <mmap@plt>
mov    %rax,-0xa8(%rbp)
mov    0x28f9(%rip),%rcx
cmp    (%rcx),%rax
jne    16c0 <main+0x4a0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    0x290e(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x100(%rbp),%rsi
mov    %eax,%edx
lea    0xa3b(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0xa0(%rbp),%rsi
mov    0x291a(%rip),%rax
mov    (%rax),%edx
mov    0x28c9(%rip),%rax
or     (%rax),%edx
mov    0x28f8(%rip),%rax
mov    (%rax),%ecx
mov    -0x70(%rbp),%r8d
mov    -0x98(%rbp),%r9
xor    %edi,%edi
call   1030 <mmap@plt>
mov    %rax,-0xb0(%rbp)
mov    0x287e(%rip),%rcx
cmp    (%rcx),%rax
jne    173b <main+0x51b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    0x2893(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x108(%rbp),%rsi
mov    %eax,%edx
lea    0x9c0(%rip),%rdi
mov    $0x0,%al
call   10b0 <err_exit@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
call   1090 <memcpy@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   10d0 <munmap@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   10d0 <munmap@plt>
mov    -0xa0(%rbp),%rax
add    -0x98(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    1600 <main+0x3e0>
mov    -0x6c(%rbp),%edi
call   1060 <close@plt>
mov    -0x70(%rbp),%edi
call   1060 <close@plt>
mov    0x27dc(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
cmp    $0x3,%edi
jne    133d <main+0x11d>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbx
lea    0x48(%rsp),%rsi
mov    %rdi,(%rsp)
call   1080 <stat@plt>
test   %rax,%rax
jns    1277 <main+0x57>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xd96(%rip),%rdi
mov    (%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x60(%rsp),%edi
call   10a0 <S_ISREG@plt>
test   %rax,%rax
jne    1297 <main+0x77>
lea    0xd90(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%rdi
call   1100 <access@plt>
test   %rax,%rax
jns    12c0 <main+0xa0>
lea    0xd94(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x2ca9(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1100 <access@plt>
test   %rax,%rax
jne    1368 <main+0x148>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
test   %rax,%rax
jns    130e <main+0xee>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xcfe(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x40(%rsp),%edi
call   10a0 <S_ISREG@plt>
test   %rax,%rax
jne    1368 <main+0x148>
mov    0x40(%rsp),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
jne    1352 <main+0x132>
lea    0xd38(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <err_exit@plt>
jmp    1368 <main+0x148>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    (%rsp),%rdi
call   1070 <basename@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10c0 <file_path_combine@plt>
mov    %rax,%rbx
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1100 <access@plt>
test   %rax,%rax
jne    13c7 <main+0x1a7>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
test   %rax,%rax
jns    13ab <main+0x18b>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc61(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x48(%rsp),%rax
cmp    0x28(%rsp),%rax
jne    13c7 <main+0x1a7>
mov    0x50(%rsp),%rax
cmp    0x30(%rsp),%rax
je     1622 <main+0x402>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
call   1110 <sysconf@plt>
test   %rax,%rax
mov    $0x1000,%ecx
cmovns %rax,%rcx
mov    %rcx,0x20(%rsp)
mov    0x2bd3(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%rdi
xor    %eax,%eax
call   10f0 <open@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
jne    1425 <main+0x205>
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc82(%rip),%rdi
mov    (%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x2b9c(%rip),%rax
mov    0x2bc5(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2bb2(%rip),%rax
or     (%rax),%esi
mov    0x60(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <open@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    1478 <main+0x258>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc2e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
lea    0x68(%rsp),%rsi
mov    0xc(%rsp),%edi
call   1140 <fstat@plt>
test   %rax,%rax
jns    14ad <main+0x28d>
mov    0x2b1e(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc16(%rip),%rdi
mov    (%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x78(%rsp),%rbp
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
call   1050 <ftruncate@plt>
test   %rax,%rax
jns    14e4 <main+0x2c4>
mov    0x2ae6(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xbfb(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    %rbx,0x10(%rsp)
test   %rbp,%rbp
jle    1610 <main+0x3f0>
mov    0x2aef(%rip),%r12
mov    0x2ad8(%rip),%rbx
mov    0x2a79(%rip),%r15
xor    %r14d,%r14d
mov    %rbp,0x18(%rsp)
jmp    156a <main+0x34a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1090 <memcpy@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10d0 <munmap@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   10d0 <munmap@plt>
add    %rbp,%r14
mov    0x18(%rsp),%rbp
cmp    %r14,%rbp
mov    0x2a92(%rip),%r12
mov    0x2a7b(%rip),%rbx
mov    0x2a1c(%rip),%r15
jle    1610 <main+0x3f0>
sub    %r14,%rbp
mov    0x20(%rsp),%rax
cmp    %rax,%rbp
cmovg  %rax,%rbp
mov    (%r12),%edx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    %rbp,%rsi
mov    0xc(%rsp),%r8d
mov    %r14,%r9
call   1030 <mmap@plt>
mov    %rax,%r13
cmp    (%r15),%rax
jne    15bb <main+0x39b>
mov    0x2a10(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb46(%rip),%rdi
mov    (%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
mov    0x29de(%rip),%rax
mov    (%rax),%edx
or     (%r12),%edx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    %rbp,%rsi
mov    0x8(%rsp),%r8d
mov    %r14,%r9
call   1030 <mmap@plt>
mov    %rax,%r12
cmp    (%r15),%rax
jne    1520 <main+0x300>
mov    0x29c1(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xaf7(%rip),%rdi
mov    0x10(%rsp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <err_exit@plt>
jmp    1520 <main+0x300>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x295f(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i64, i64, i32 }
@EXIT_FAILURE = global i32 0
@.str = [28 x i8] c"tcpm: cannot stat '%s': %s\0A\00"
@errno = global i32 0
@.str.1 = [45 x i8] c"tcpm: '%s' doesn't point to a regular file'\0A\00"
@R_OK = global i32 0
@.str.2 = [32 x i8] c"tcpm: '%s': no read permission\0A\00"
@F_OK = global i32 0
@.str.3 = [49 x i8] c"tcpm: '%s' isn't a regular file or a directory'\0A\00"
@EXIT_SUCCESS = global i32 0
@_SC_PAGE_SIZE = global i32 0
@O_RDONLY = global i32 0
@.str.4 = [28 x i8] c"tcpm: cannot open '%s': %s\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.5 = [29 x i8] c"tcpm: cannot fstat '%s': %s\0A\00"
@.str.6 = [33 x i8] c"tcpm: cannot ftruncate '%s': %s\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [31 x i8] c"tcpm: mmap error for '%s': %s\0A\00"
@PROT_WRITE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.stat
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.stat
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 (...) @usage()
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
store i8* %31, i8** %7
%32 = load i8*, i8** %6
%33 = call i64 @stat(i8* %32, %struct.stat* %9)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %25
%36 = load i8*, i8** %6
%37 = load i32, i32* @errno
%38 = call i32 @strerror(i32 %37)
%39 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %36, i32 %38)
br label %40
40: ; preds = %35, %25
%41 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 3
%42 = load i32, i32* %41
%43 = call i64 @S_ISREG(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = load i8*, i8** %6
%47 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %40
%49 = load i8*, i8** %6
%50 = load i32, i32* @R_OK
%51 = call i64 @access(i8* %49, i32 %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i8*, i8** %6
%55 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %48
%57 = load i8*, i8** %7
%58 = load i32, i32* @F_OK
%59 = call i64 @access(i8* %57, i32 %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %92
61: ; preds = %56
%62 = load i8*, i8** %7
%63 = call i64 @stat(i8* %62, %struct.stat* %10)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %61
%66 = load i8*, i8** %7
%67 = load i32, i32* @errno
%68 = call i32 @strerror(i32 %67)
%69 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %66, i32 %68)
br label %70
70: ; preds = %65, %61
%71 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 3
%72 = load i32, i32* %71
%73 = call i64 @S_ISREG(i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = load i8*, i8** %7
store i8* %76, i8** %8
br label %91
77: ; preds = %70
%78 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 3
%79 = load i32, i32* %78
%80 = call i64 @S_ISDIR(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %87
82: ; preds = %77
%83 = load i8*, i8** %7
%84 = load i8*, i8** %6
%85 = call i32 @basename(i8* %84)
%86 = call i8* @file_path_combine(i8* %83, i32 %85)
store i8* %86, i8** %8
br label %90
87: ; preds = %77
%88 = load i8*, i8** %7
%89 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %87, %82
br label %91
91: ; preds = %90, %75
br label %94
92: ; preds = %56
%93 = load i8*, i8** %7
store i8* %93, i8** %8
br label %94
94: ; preds = %92, %91
%95 = load i8*, i8** %8
%96 = load i32, i32* @F_OK
%97 = call i64 @access(i8* %95, i32 %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %124
99: ; preds = %94
%100 = load i8*, i8** %8
%101 = call i64 @stat(i8* %100, %struct.stat* %10)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %108
103: ; preds = %99
%104 = load i8*, i8** %8
%105 = load i32, i32* @errno
%106 = call i32 @strerror(i32 %105)
%107 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %104, i32 %106)
br label %108
108: ; preds = %103, %99
%109 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%110 = load i64, i64* %109
%111 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%112 = load i64, i64* %111
%113 = icmp eq i64 %110, %112
br i1 %113, label %114, label %123
114: ; preds = %108
%115 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%116 = load i64, i64* %115
%117 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%118 = load i64, i64* %117
%119 = icmp eq i64 %116, %118
br i1 %119, label %120, label %123
120: ; preds = %114
%121 = load i32, i32* @EXIT_SUCCESS
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %114, %108
br label %124
124: ; preds = %123, %94
store i64 0, i64* %14
%125 = load i32, i32* @_SC_PAGE_SIZE
%126 = call i64 @sysconf(i32 %125)
store i64 %126, i64* %18
%127 = load i64, i64* %18
%128 = icmp slt i64 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %124
store i64 4096, i64* %18
br label %130
130: ; preds = %129, %124
%131 = load i8*, i8** %6
%132 = load i32, i32* @O_RDONLY
%133 = call i32 (i8*, i32, ...) @open(i8* %131, i32 %132)
store i32 %133, i32* %11
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %140
135: ; preds = %130
%136 = load i8*, i8** %6
%137 = load i32, i32* @errno
%138 = call i32 @strerror(i32 %137)
%139 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %136, i32 %138)
br label %140
140: ; preds = %135, %130
%141 = load i8*, i8** %8
%142 = load i32, i32* @O_RDWR
%143 = load i32, i32* @O_CREAT
%144 = or i32 %142, %143
%145 = load i32, i32* @O_TRUNC
%146 = or i32 %144, %145
%147 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 3
%148 = load i32, i32* %147
%149 = call i32 (i8*, i32, ...) @open(i8* %141, i32 %146, i32 %148)
store i32 %149, i32* %12
%150 = icmp eq i32 %149, -1
br i1 %150, label %151, label %156
151: ; preds = %140
%152 = load i8*, i8** %8
%153 = load i32, i32* @errno
%154 = call i32 @strerror(i32 %153)
%155 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %152, i32 %154)
br label %156
156: ; preds = %151, %140
%157 = load i32, i32* %11
%158 = call i64 @fstat(i32 %157, %struct.stat* %13)
%159 = icmp slt i64 %158, 0
br i1 %159, label %160, label %165
160: ; preds = %156
%161 = load i8*, i8** %6
%162 = load i32, i32* @errno
%163 = call i32 @strerror(i32 %162)
%164 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %161, i32 %163)
br label %165
165: ; preds = %160, %156
%166 = load i32, i32* %12
%167 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 2
%168 = load i64, i64* %167
%169 = call i64 @ftruncate(i32 %166, i64 %168)
%170 = icmp slt i64 %169, 0
br i1 %170, label %171, label %176
171: ; preds = %165
%172 = load i8*, i8** %8
%173 = load i32, i32* @errno
%174 = call i32 @strerror(i32 %173)
%175 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %172, i32 %174)
br label %176
176: ; preds = %171, %165
br label %177
177: ; preds = %226, %176
%178 = load i64, i64* %14
%179 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 2
%180 = load i64, i64* %179
%181 = icmp slt i64 %178, %180
br i1 %181, label %182, label %240
182: ; preds = %177
%183 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 2
%184 = load i64, i64* %183
%185 = load i64, i64* %14
%186 = sub nsw i64 %184, %185
%187 = load i64, i64* %18
%188 = icmp sgt i64 %186, %187
br i1 %188, label %189, label %191
189: ; preds = %182
%190 = load i64, i64* %18
store i64 %190, i64* %15
br label %196
191: ; preds = %182
%192 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 2
%193 = load i64, i64* %192
%194 = load i64, i64* %14
%195 = sub nsw i64 %193, %194
store i64 %195, i64* %15
br label %196
196: ; preds = %191, %189
%197 = load i64, i64* %15
%198 = load i32, i32* @PROT_READ
%199 = load i32, i32* @MAP_SHARED
%200 = load i32, i32* %11
%201 = load i64, i64* %14
%202 = call i8* @mmap(i32 0, i64 %197, i32 %198, i32 %199, i32 %200, i64 %201)
store i8* %202, i8** %16
%203 = load i8*, i8** @MAP_FAILED
%204 = icmp eq i8* %202, %203
br i1 %204, label %205, label %210
205: ; preds = %196
%206 = load i8*, i8** %6
%207 = load i32, i32* @errno
%208 = call i32 @strerror(i32 %207)
%209 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %206, i32 %208)
br label %210
210: ; preds = %205, %196
%211 = load i64, i64* %15
%212 = load i32, i32* @PROT_READ
%213 = load i32, i32* @PROT_WRITE
%214 = or i32 %212, %213
%215 = load i32, i32* @MAP_SHARED
%216 = load i32, i32* %12
%217 = load i64, i64* %14
%218 = call i8* @mmap(i32 0, i64 %211, i32 %214, i32 %215, i32 %216, i64 %217)
store i8* %218, i8** %17
%219 = load i8*, i8** @MAP_FAILED
%220 = icmp eq i8* %218, %219
br i1 %220, label %221, label %226
221: ; preds = %210
%222 = load i8*, i8** %8
%223 = load i32, i32* @errno
%224 = call i32 @strerror(i32 %223)
%225 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %222, i32 %224)
br label %226
226: ; preds = %221, %210
%227 = load i8*, i8** %17
%228 = load i8*, i8** %16
%229 = load i64, i64* %15
%230 = call i32 @memcpy(i8* %227, i8* %228, i64 %229)
%231 = load i8*, i8** %16
%232 = load i64, i64* %15
%233 = call i32 @munmap(i8* %231, i64 %232)
%234 = load i8*, i8** %17
%235 = load i64, i64* %15
%236 = call i32 @munmap(i8* %234, i64 %235)
%237 = load i64, i64* %15
%238 = load i64, i64* %14
%239 = add i64 %238, %237
store i64 %239, i64* %14
br label %177
240: ; preds = %177
%241 = load i32, i32* %11
%242 = call i32 @close(i32 %241)
%243 = load i32, i32* %12
%244 = call i32 @close(i32 %243)
%245 = load i32, i32* @EXIT_SUCCESS
%246 = call i32 @exit(i32 %245)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i64, i64, i64, i32 }
@EXIT_FAILURE = global i32 0
@.str = [28 x i8] c"tcpm: cannot stat '%s': %s\0A\00"
@errno = global i32 0
@.str.1 = [45 x i8] c"tcpm: '%s' doesn't point to a regular file'\0A\00"
@R_OK = global i32 0
@.str.2 = [32 x i8] c"tcpm: '%s': no read permission\0A\00"
@F_OK = global i32 0
@.str.3 = [49 x i8] c"tcpm: '%s' isn't a regular file or a directory'\0A\00"
@EXIT_SUCCESS = global i32 0
@_SC_PAGE_SIZE = global i32 0
@O_RDONLY = global i32 0
@.str.4 = [28 x i8] c"tcpm: cannot open '%s': %s\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.5 = [29 x i8] c"tcpm: cannot fstat '%s': %s\0A\00"
@.str.6 = [33 x i8] c"tcpm: cannot ftruncate '%s': %s\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.7 = [31 x i8] c"tcpm: mmap error for '%s': %s\0A\00"
@PROT_WRITE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = alloca %struct.stat
%6 = icmp eq i32 %0, 3
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = tail call i32 (...) @usage()
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = bitcast %struct.stat* %3 to i8*
%13 = bitcast %struct.stat* %4 to i8*
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @stat(i8* %15, %struct.stat* %3)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %11
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %22)
br label %24
24: ; preds = %20, %11
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
%26 = load i32, i32* %25
%27 = call i64 @S_ISREG(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %31
31: ; preds = %29, %24
%32 = load i32, i32* @R_OK
%33 = call i64 @access(i8* %15, i32 %32)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* @F_OK
%39 = call i64 @access(i8* %17, i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %62
41: ; preds = %37
%42 = call i64 @stat(i8* %17, %struct.stat* %4)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* @errno
%46 = call i32 @strerror(i32 %45)
%47 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %46)
br label %48
48: ; preds = %44, %41
%49 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 3
%50 = load i32, i32* %49
%51 = call i64 @S_ISREG(i32 %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %48
%54 = load i32, i32* %49
%55 = call i64 @S_ISDIR(i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %53
%58 = call i32 @basename(i8* %15)
%59 = call i8* @file_path_combine(i8* %17, i32 %58)
br label %62
60: ; preds = %53
%61 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %62
62: ; preds = %37, %48, %60, %57
%63 = phi i8* [ %59, %57 ], [ undef, %60 ], [ %17, %48 ], [ %17, %37 ]
%64 = load i32, i32* @F_OK
%65 = call i64 @access(i8* %63, i32 %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %89
67: ; preds = %62
%68 = call i64 @stat(i8* %63, %struct.stat* %4)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = load i32, i32* @errno
%72 = call i32 @strerror(i32 %71)
%73 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %63, i32 %72)
br label %74
74: ; preds = %70, %67
%75 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%76 = load i64, i64* %75
%77 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%78 = load i64, i64* %77
%79 = icmp eq i64 %76, %78
br i1 %79, label %80, label %89
80: ; preds = %74
%81 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%82 = load i64, i64* %81
%83 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%84 = load i64, i64* %83
%85 = icmp eq i64 %82, %84
br i1 %85, label %86, label %89
86: ; preds = %80
%87 = load i32, i32* @EXIT_SUCCESS
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %74, %80, %62
%90 = bitcast %struct.stat* %5 to i8*
%91 = load i32, i32* @_SC_PAGE_SIZE
%92 = call i64 @sysconf(i32 %91)
%93 = icmp slt i64 %92, 0
%94 = select i1 %93, i64 4096, i64 %92
%95 = load i32, i32* @O_RDONLY
%96 = call i32 (i8*, i32, ...) @open(i8* %15, i32 %95)
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %102
98: ; preds = %89
%99 = load i32, i32* @errno
%100 = call i32 @strerror(i32 %99)
%101 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %15, i32 %100)
br label %102
102: ; preds = %98, %89
%103 = load i32, i32* @O_RDWR
%104 = load i32, i32* @O_CREAT
%105 = or i32 %104, %103
%106 = load i32, i32* @O_TRUNC
%107 = or i32 %105, %106
%108 = load i32, i32* %25
%109 = call i32 (i8*, i32, ...) @open(i8* %63, i32 %107, i32 %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %115
111: ; preds = %102
%112 = load i32, i32* @errno
%113 = call i32 @strerror(i32 %112)
%114 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %63, i32 %113)
br label %115
115: ; preds = %111, %102
%116 = call i64 @fstat(i32 %96, %struct.stat* %5)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %115
%119 = load i32, i32* @errno
%120 = call i32 @strerror(i32 %119)
%121 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %15, i32 %120)
br label %122
122: ; preds = %118, %115
%123 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 2
%124 = load i64, i64* %123
%125 = call i64 @ftruncate(i32 %109, i64 %124)
%126 = icmp slt i64 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %122
%128 = load i32, i32* @errno
%129 = call i32 @strerror(i32 %128)
%130 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %63, i32 %129)
br label %131
131: ; preds = %127, %122
%132 = icmp sgt i64 %124, 0
br i1 %132, label %133, label %165
133: ; preds = %131, %159
%134 = phi i64 [ %163, %159 ], [ 0, %131 ]
%135 = sub nsw i64 %124, %134
%136 = icmp sgt i64 %135, %94
%137 = select i1 %136, i64 %94, i64 %135
%138 = load i32, i32* @PROT_READ
%139 = load i32, i32* @MAP_SHARED
%140 = call i8* @mmap(i32 0, i64 %137, i32 %138, i32 %139, i32 %96, i64 %134)
%141 = load i8*, i8** @MAP_FAILED
%142 = icmp eq i8* %140, %141
br i1 %142, label %143, label %147
143: ; preds = %133
%144 = load i32, i32* @errno
%145 = call i32 @strerror(i32 %144)
%146 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %15, i32 %145)
br label %147
147: ; preds = %143, %133
%148 = load i32, i32* @PROT_READ
%149 = load i32, i32* @PROT_WRITE
%150 = or i32 %149, %148
%151 = load i32, i32* @MAP_SHARED
%152 = call i8* @mmap(i32 0, i64 %137, i32 %150, i32 %151, i32 %109, i64 %134)
%153 = load i8*, i8** @MAP_FAILED
%154 = icmp eq i8* %152, %153
br i1 %154, label %155, label %159
155: ; preds = %147
%156 = load i32, i32* @errno
%157 = call i32 @strerror(i32 %156)
%158 = call i32 (i8*, i8*, ...) @err_exit(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %63, i32 %157)
br label %159
159: ; preds = %155, %147
%160 = call i32 @memcpy(i8* %152, i8* %140, i64 %137)
%161 = call i32 @munmap(i8* %140, i64 %137)
%162 = call i32 @munmap(i8* %152, i64 %137)
%163 = add i64 %137, %134
%164 = icmp sgt i64 %124, %163
br i1 %164, label %133, label %165
165: ; preds = %159, %131
%166 = call i32 @close(i32 %96)
%167 = call i32 @close(i32 %109)
%168 = load i32, i32* @EXIT_SUCCESS
%169 = call i32 @exit(i32 %168)
unreachable
}