#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int FD_CLOEXEC;
int /*<<< orphan*/ F_GETFD;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFD;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int O_RDWR;
int O_SYNC;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ err_sys(char *, ...);
scalar_t__ fcntl(int, int /*<<< orphan*/, int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int oflags = O_RDWR;
  char *pathname = "input.dat";
  int fd1, fd2, fd3;
  if ((fd1 = open(pathname, oflags, 0)) < 0) {
    err_sys("error opening %s fd1", pathname);
  }
  fcntl(fd1, F_SETFD, FD_CLOEXEC);
  if ((fd2 = dup(fd1)) < 0) {
    err_sys("error on dup fd1");
  }
  if ((fd3 = open(pathname, oflags)) < 0) {
    err_sys("error on opening %s as fd3", pathname);
  }
  int fdflag, flflag;
  printf("================ initial status of fd and fl ===================\n");
  if ((fdflag = fcntl(fd1, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd1");
  }
  if ((flflag = fcntl(fd1, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd1");
  }
  printf("fd1: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd2, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd2");
  }
  if ((flflag = fcntl(fd2, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd2");
  }
  printf("fd2: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd3, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd3");
  }
  if ((flflag = fcntl(fd3, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd3");
  }
  printf("fd3: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  printf("================ Change fd flag of fd1 ===================\n");
  if (fcntl(fd1, F_SETFD, 0) < 0) {
    err_sys("error on setting fd flag of fd1");
  }
  if ((fdflag = fcntl(fd1, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd1");
  }
  if ((flflag = fcntl(fd1, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd1");
  }
  printf("fd1: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd2, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd2");
  }
  if ((flflag = fcntl(fd2, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd2");
  }
  printf("fd2: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd3, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd3");
  }
  if ((flflag = fcntl(fd3, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd3");
  }
  printf("fd3: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  printf("================ Change fl flag of fd1 ===================\n");
  flflag = (O_NONBLOCK | O_SYNC | O_TRUNC);
  if (fcntl(fd1, F_SETFL, flflag) < 0) {
    err_sys("error on setting fl flag of fd1");
  }
  if ((fdflag = fcntl(fd1, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd1");
  }
  if ((flflag = fcntl(fd1, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd1");
  }
  printf("fd1: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd2, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd2");
  }
  if ((flflag = fcntl(fd2, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd2");
  }
  printf("fd2: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  if ((fdflag = fcntl(fd3, F_GETFD, 0)) < 0) {
    err_sys("error on fcntl while geting fd flags for fd3");
  }
  if ((flflag = fcntl(fd3, F_GETFL, 0)) < 0) {
    err_sys("error on fcntl while getting file flags for fd3");
  }
  printf("fd3: fd flag is 0x%x, fl flag is 0x%x\n", fdflag, flflag);
  close(fd1);
  close(fd2);
  close(fd3);
  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)
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11bb <main+0x5b>
mov    -0x20(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
call   1040 <fcntl@plt>
mov    -0x24(%rbp),%edi
call   1060 <dup@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    11f7 <main+0x97>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    1223 <main+0xc3>
mov    -0x20(%rbp),%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    125e <main+0xfe>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    128b <main+0x12b>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%edi
mov    0x2cff(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    12cc <main+0x16c>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x28(%rbp),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    12f9 <main+0x199>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2c91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    133a <main+0x1da>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x2c(%rbp),%edi
mov    0x2c5c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1367 <main+0x207>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
mov    0x2c2d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    13b4 <main+0x254>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2bea(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    13e1 <main+0x281>
lea    0xcb3(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2bb5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    140e <main+0x2ae>
lea    0xcb3(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%edi
mov    0x2b7c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    144f <main+0x2ef>
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x28(%rbp),%edi
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    147c <main+0x31c>
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2b0e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    14bd <main+0x35d>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x2c(%rbp),%edi
mov    0x2ad9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    14ea <main+0x38a>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2abd(%rip),%rax
mov    (%rax),%eax
mov    0x2abc(%rip),%rcx
or     (%rcx),%eax
mov    0x2ad3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2a84(%rip),%rax
mov    (%rax),%esi
mov    -0x34(%rbp),%edx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    1556 <main+0x3f6>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2a48(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    1583 <main+0x423>
lea    0xb11(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x24(%rbp),%edi
mov    0x2a13(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    15b0 <main+0x450>
lea    0xb11(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xb2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%edi
mov    0x29da(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    15f1 <main+0x491>
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x28(%rbp),%edi
mov    0x29a5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    161e <main+0x4be>
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xb43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x296c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    165f <main+0x4ff>
lea    0xb3d(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x2c(%rbp),%edi
mov    0x2937(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    168c <main+0x52c>
lea    0xb3d(%rip),%rdi
mov    $0x0,%al
call   1030 <err_sys@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xb59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
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
push   %rax
mov    0x2e5e(%rip),%rax
mov    (%rax),%ebp
lea    0xe75(%rip),%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    11b2 <main+0x42>
lea    0xe66(%rip),%rdi
lea    0xe55(%rip),%rsi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
call   1050 <fcntl@plt>
mov    %r12d,%edi
call   1070 <dup@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    11e9 <main+0x79>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xe10(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1215 <main+0xa5>
lea    0xe29(%rip),%rdi
lea    0xdf2(%rip),%rsi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xffb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    1249 <main+0xd9>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x2d50(%rip),%r13
mov    0x0(%r13),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    1273 <main+0x103>
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xe2e(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    12ad <main+0x13d>
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    12d0 <main+0x160>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xe55(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    130a <main+0x19a>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    132d <main+0x1bd>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xe7c(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c6e(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
test   %rax,%rax
jns    1371 <main+0x201>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    1399 <main+0x229>
lea    0xcb9(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    13bc <main+0x24c>
lea    0xcc3(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xce5(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    13f6 <main+0x286>
lea    0xce0(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    1419 <main+0x2a9>
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xd0c(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2b76(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    1453 <main+0x2e3>
lea    0xd07(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    1476 <main+0x306>
lea    0xd11(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xd33(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    0x2b35(%rip),%rax
mov    0x2b36(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2b4b(%rip),%rax
or     (%rax),%edx
mov    0x2b02(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
call   1050 <fcntl@plt>
test   %rax,%rax
jns    14d3 <main+0x363>
lea    0xd2b(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x2ace(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    14fb <main+0x38b>
lea    0xb57(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    151e <main+0x3ae>
lea    0xb61(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xb83(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2a71(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    1558 <main+0x3e8>
lea    0xb7e(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    157b <main+0x40b>
lea    0xb88(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xbaa(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2a14(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jns    15b5 <main+0x445>
lea    0xba5(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
mov    0x0(%r13),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jns    15d8 <main+0x468>
lea    0xbaf(%rip),%rdi
xor    %eax,%eax
call   1040 <err_sys@plt>
lea    0xbd1(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r15d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [21 x i8] c"error opening %s fd1\00"
@F_SETFD = global i32 0
@FD_CLOEXEC = global i32 0
@.str.2 = [17 x i8] c"error on dup fd1\00"
@.str.3 = [27 x i8] c"error on opening %s as fd3\00"
@.str.4 = [66 x i8] c"================ initial status of fd and fl ===================\0A\00"
@F_GETFD = global i32 0
@.str.5 = [45 x i8] c"error on fcntl while geting fd flags for fd1\00"
@F_GETFL = global i32 0
@.str.6 = [48 x i8] c"error on fcntl while getting file flags for fd1\00"
@.str.7 = [39 x i8] c"fd1: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.8 = [45 x i8] c"error on fcntl while geting fd flags for fd2\00"
@.str.9 = [48 x i8] c"error on fcntl while getting file flags for fd2\00"
@.str.10 = [39 x i8] c"fd2: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.11 = [45 x i8] c"error on fcntl while geting fd flags for fd3\00"
@.str.12 = [48 x i8] c"error on fcntl while getting file flags for fd3\00"
@.str.13 = [39 x i8] c"fd3: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.14 = [60 x i8] c"================ Change fd flag of fd1 ===================\0A\00"
@.str.15 = [32 x i8] c"error on setting fd flag of fd1\00"
@.str.16 = [60 x i8] c"================ Change fl flag of fd1 ===================\0A\00"
@O_NONBLOCK = global i32 0
@O_SYNC = global i32 0
@O_TRUNC = global i32 0
@F_SETFL = global i32 0
@.str.17 = [32 x i8] c"error on setting fl flag of fd1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%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 = load i32, i32* @O_RDWR
store i32 %13, i32* %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %7
%14 = load i8*, i8** %7
%15 = load i32, i32* %6
%16 = call i32 (i8*, i32, ...) @open(i8* %14, i32 %15, i32 0)
store i32 %16, i32* %8
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %7
%20 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %2
%22 = load i32, i32* %8
%23 = load i32, i32* @F_SETFD
%24 = load i32, i32* @FD_CLOEXEC
%25 = call i64 @fcntl(i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %8
%27 = call i32 @dup(i32 %26)
store i32 %27, i32* %9
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %21
%32 = load i8*, i8** %7
%33 = load i32, i32* %6
%34 = call i32 (i8*, i32, ...) @open(i8* %32, i32 %33)
store i32 %34, i32* %10
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i8*, i8** %7
%38 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %31
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* %8
%42 = load i32, i32* @F_GETFD
%43 = call i64 @fcntl(i32 %41, i32 %42, i32 0)
%44 = trunc i64 %43 to i32
store i32 %44, i32* %11
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %39
%49 = load i32, i32* %8
%50 = load i32, i32* @F_GETFL
%51 = call i64 @fcntl(i32 %49, i32 %50, i32 0)
%52 = trunc i64 %51 to i32
store i32 %52, i32* %12
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %48
%55 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %56
56: ; preds = %54, %48
%57 = load i32, i32* %11
%58 = load i32, i32* %12
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %57, i32 %58)
%60 = load i32, i32* %9
%61 = load i32, i32* @F_GETFD
%62 = call i64 @fcntl(i32 %60, i32 %61, i32 0)
%63 = trunc i64 %62 to i32
store i32 %63, i32* %11
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %56
%66 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %67
67: ; preds = %65, %56
%68 = load i32, i32* %9
%69 = load i32, i32* @F_GETFL
%70 = call i64 @fcntl(i32 %68, i32 %69, i32 0)
%71 = trunc i64 %70 to i32
store i32 %71, i32* %12
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %75
75: ; preds = %73, %67
%76 = load i32, i32* %11
%77 = load i32, i32* %12
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %76, i32 %77)
%79 = load i32, i32* %10
%80 = load i32, i32* @F_GETFD
%81 = call i64 @fcntl(i32 %79, i32 %80, i32 0)
%82 = trunc i64 %81 to i32
store i32 %82, i32* %11
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %75
%85 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %86
86: ; preds = %84, %75
%87 = load i32, i32* %10
%88 = load i32, i32* @F_GETFL
%89 = call i64 @fcntl(i32 %87, i32 %88, i32 0)
%90 = trunc i64 %89 to i32
store i32 %90, i32* %12
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %86
%93 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %94
94: ; preds = %92, %86
%95 = load i32, i32* %11
%96 = load i32, i32* %12
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %95, i32 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.14, i64 0, i64 0))
%99 = load i32, i32* %8
%100 = load i32, i32* @F_SETFD
%101 = call i64 @fcntl(i32 %99, i32 %100, i32 0)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %94
%104 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0))
br label %105
105: ; preds = %103, %94
%106 = load i32, i32* %8
%107 = load i32, i32* @F_GETFD
%108 = call i64 @fcntl(i32 %106, i32 %107, i32 0)
%109 = trunc i64 %108 to i32
store i32 %109, i32* %11
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %105
%112 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %113
113: ; preds = %111, %105
%114 = load i32, i32* %8
%115 = load i32, i32* @F_GETFL
%116 = call i64 @fcntl(i32 %114, i32 %115, i32 0)
%117 = trunc i64 %116 to i32
store i32 %117, i32* %12
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %121
119: ; preds = %113
%120 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %121
121: ; preds = %119, %113
%122 = load i32, i32* %11
%123 = load i32, i32* %12
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %122, i32 %123)
%125 = load i32, i32* %9
%126 = load i32, i32* @F_GETFD
%127 = call i64 @fcntl(i32 %125, i32 %126, i32 0)
%128 = trunc i64 %127 to i32
store i32 %128, i32* %11
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %121
%131 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %132
132: ; preds = %130, %121
%133 = load i32, i32* %9
%134 = load i32, i32* @F_GETFL
%135 = call i64 @fcntl(i32 %133, i32 %134, i32 0)
%136 = trunc i64 %135 to i32
store i32 %136, i32* %12
%137 = icmp slt i32 %136, 0
br i1 %137, label %138, label %140
138: ; preds = %132
%139 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %140
140: ; preds = %138, %132
%141 = load i32, i32* %11
%142 = load i32, i32* %12
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %141, i32 %142)
%144 = load i32, i32* %10
%145 = load i32, i32* @F_GETFD
%146 = call i64 @fcntl(i32 %144, i32 %145, i32 0)
%147 = trunc i64 %146 to i32
store i32 %147, i32* %11
%148 = icmp slt i32 %147, 0
br i1 %148, label %149, label %151
149: ; preds = %140
%150 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %151
151: ; preds = %149, %140
%152 = load i32, i32* %10
%153 = load i32, i32* @F_GETFL
%154 = call i64 @fcntl(i32 %152, i32 %153, i32 0)
%155 = trunc i64 %154 to i32
store i32 %155, i32* %12
%156 = icmp slt i32 %155, 0
br i1 %156, label %157, label %159
157: ; preds = %151
%158 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %159
159: ; preds = %157, %151
%160 = load i32, i32* %11
%161 = load i32, i32* %12
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %160, i32 %161)
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0))
%164 = load i32, i32* @O_NONBLOCK
%165 = load i32, i32* @O_SYNC
%166 = or i32 %164, %165
%167 = load i32, i32* @O_TRUNC
%168 = or i32 %166, %167
store i32 %168, i32* %12
%169 = load i32, i32* %8
%170 = load i32, i32* @F_SETFL
%171 = load i32, i32* %12
%172 = call i64 @fcntl(i32 %169, i32 %170, i32 %171)
%173 = icmp slt i64 %172, 0
br i1 %173, label %174, label %176
174: ; preds = %159
%175 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0))
br label %176
176: ; preds = %174, %159
%177 = load i32, i32* %8
%178 = load i32, i32* @F_GETFD
%179 = call i64 @fcntl(i32 %177, i32 %178, i32 0)
%180 = trunc i64 %179 to i32
store i32 %180, i32* %11
%181 = icmp slt i32 %180, 0
br i1 %181, label %182, label %184
182: ; preds = %176
%183 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %184
184: ; preds = %182, %176
%185 = load i32, i32* %8
%186 = load i32, i32* @F_GETFL
%187 = call i64 @fcntl(i32 %185, i32 %186, i32 0)
%188 = trunc i64 %187 to i32
store i32 %188, i32* %12
%189 = icmp slt i32 %188, 0
br i1 %189, label %190, label %192
190: ; preds = %184
%191 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %192
192: ; preds = %190, %184
%193 = load i32, i32* %11
%194 = load i32, i32* %12
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %193, i32 %194)
%196 = load i32, i32* %9
%197 = load i32, i32* @F_GETFD
%198 = call i64 @fcntl(i32 %196, i32 %197, i32 0)
%199 = trunc i64 %198 to i32
store i32 %199, i32* %11
%200 = icmp slt i32 %199, 0
br i1 %200, label %201, label %203
201: ; preds = %192
%202 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %203
203: ; preds = %201, %192
%204 = load i32, i32* %9
%205 = load i32, i32* @F_GETFL
%206 = call i64 @fcntl(i32 %204, i32 %205, i32 0)
%207 = trunc i64 %206 to i32
store i32 %207, i32* %12
%208 = icmp slt i32 %207, 0
br i1 %208, label %209, label %211
209: ; preds = %203
%210 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %211
211: ; preds = %209, %203
%212 = load i32, i32* %11
%213 = load i32, i32* %12
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %212, i32 %213)
%215 = load i32, i32* %10
%216 = load i32, i32* @F_GETFD
%217 = call i64 @fcntl(i32 %215, i32 %216, i32 0)
%218 = trunc i64 %217 to i32
store i32 %218, i32* %11
%219 = icmp slt i32 %218, 0
br i1 %219, label %220, label %222
220: ; preds = %211
%221 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %222
222: ; preds = %220, %211
%223 = load i32, i32* %10
%224 = load i32, i32* @F_GETFL
%225 = call i64 @fcntl(i32 %223, i32 %224, i32 0)
%226 = trunc i64 %225 to i32
store i32 %226, i32* %12
%227 = icmp slt i32 %226, 0
br i1 %227, label %228, label %230
228: ; preds = %222
%229 = call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %230
230: ; preds = %228, %222
%231 = load i32, i32* %11
%232 = load i32, i32* %12
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %231, i32 %232)
%234 = load i32, i32* %8
%235 = call i32 @close(i32 %234)
%236 = load i32, i32* %9
%237 = call i32 @close(i32 %236)
%238 = load i32, i32* %10
%239 = call i32 @close(i32 %238)
ret i32 0
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [21 x i8] c"error opening %s fd1\00"
@F_SETFD = global i32 0
@FD_CLOEXEC = global i32 0
@.str.2 = [17 x i8] c"error on dup fd1\00"
@.str.3 = [27 x i8] c"error on opening %s as fd3\00"
@F_GETFD = global i32 0
@.str.5 = [45 x i8] c"error on fcntl while geting fd flags for fd1\00"
@F_GETFL = global i32 0
@.str.6 = [48 x i8] c"error on fcntl while getting file flags for fd1\00"
@.str.7 = [39 x i8] c"fd1: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.8 = [45 x i8] c"error on fcntl while geting fd flags for fd2\00"
@.str.9 = [48 x i8] c"error on fcntl while getting file flags for fd2\00"
@.str.10 = [39 x i8] c"fd2: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.11 = [45 x i8] c"error on fcntl while geting fd flags for fd3\00"
@.str.12 = [48 x i8] c"error on fcntl while getting file flags for fd3\00"
@.str.13 = [39 x i8] c"fd3: fd flag is 0x%x, fl flag is 0x%x\0A\00"
@.str.15 = [32 x i8] c"error on setting fd flag of fd1\00"
@O_NONBLOCK = global i32 0
@O_SYNC = global i32 0
@O_TRUNC = global i32 0
@F_SETFL = global i32 0
@.str.17 = [32 x i8] c"error on setting fl flag of fd1\00"
@str = [65 x i8] c"================ initial status of fd and fl ===================\00"
@str.18 = [59 x i8] c"================ Change fd flag of fd1 ===================\00"
@str.19 = [59 x i8] c"================ Change fl flag of fd1 ===================\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = load i32, i32* @F_SETFD
%10 = load i32, i32* @FD_CLOEXEC
%11 = tail call i64 @fcntl(i32 %4, i32 %9, i32 %10)
%12 = tail call i32 @dup(i32 %4)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
%17 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%23 = load i32, i32* @F_GETFD
%24 = tail call i64 @fcntl(i32 %4, i32 %23, i32 0)
%25 = trunc i64 %24 to i32
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
%30 = load i32, i32* @F_GETFL
%31 = tail call i64 @fcntl(i32 %4, i32 %30, i32 0)
%32 = trunc i64 %31 to i32
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %25, i32 %32)
%38 = load i32, i32* @F_GETFD
%39 = tail call i64 @fcntl(i32 %12, i32 %38, i32 0)
%40 = trunc i64 %39 to i32
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
%45 = load i32, i32* @F_GETFL
%46 = tail call i64 @fcntl(i32 %12, i32 %45, i32 0)
%47 = trunc i64 %46 to i32
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %51
51: ; preds = %49, %44
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %40, i32 %47)
%53 = load i32, i32* @F_GETFD
%54 = tail call i64 @fcntl(i32 %17, i32 %53, i32 0)
%55 = trunc i64 %54 to i32
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %59
59: ; preds = %57, %51
%60 = load i32, i32* @F_GETFL
%61 = tail call i64 @fcntl(i32 %17, i32 %60, i32 0)
%62 = trunc i64 %61 to i32
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %66
66: ; preds = %64, %59
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %55, i32 %62)
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.18, i64 0, i64 0))
%69 = load i32, i32* @F_SETFD
%70 = tail call i64 @fcntl(i32 %4, i32 %69, i32 0)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = load i32, i32* @F_GETFD
%76 = tail call i64 @fcntl(i32 %4, i32 %75, i32 0)
%77 = trunc i64 %76 to i32
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %79, %74
%82 = load i32, i32* @F_GETFL
%83 = tail call i64 @fcntl(i32 %4, i32 %82, i32 0)
%84 = trunc i64 %83 to i32
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %81
%87 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %88
88: ; preds = %86, %81
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %77, i32 %84)
%90 = load i32, i32* @F_GETFD
%91 = tail call i64 @fcntl(i32 %12, i32 %90, i32 0)
%92 = trunc i64 %91 to i32
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %88
%95 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %96
96: ; preds = %94, %88
%97 = load i32, i32* @F_GETFL
%98 = tail call i64 @fcntl(i32 %12, i32 %97, i32 0)
%99 = trunc i64 %98 to i32
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %96
%102 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %103
103: ; preds = %101, %96
%104 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %92, i32 %99)
%105 = load i32, i32* @F_GETFD
%106 = tail call i64 @fcntl(i32 %17, i32 %105, i32 0)
%107 = trunc i64 %106 to i32
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %103
%110 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %111
111: ; preds = %109, %103
%112 = load i32, i32* @F_GETFL
%113 = tail call i64 @fcntl(i32 %17, i32 %112, i32 0)
%114 = trunc i64 %113 to i32
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %111
%117 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %118
118: ; preds = %116, %111
%119 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %107, i32 %114)
%120 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.19, i64 0, i64 0))
%121 = load i32, i32* @O_NONBLOCK
%122 = load i32, i32* @O_SYNC
%123 = or i32 %122, %121
%124 = load i32, i32* @O_TRUNC
%125 = or i32 %123, %124
%126 = load i32, i32* @F_SETFL
%127 = tail call i64 @fcntl(i32 %4, i32 %126, i32 %125)
%128 = icmp slt i64 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %118
%130 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0))
br label %131
131: ; preds = %129, %118
%132 = load i32, i32* @F_GETFD
%133 = tail call i64 @fcntl(i32 %4, i32 %132, i32 0)
%134 = trunc i64 %133 to i32
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %131
%137 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %138
138: ; preds = %136, %131
%139 = load i32, i32* @F_GETFL
%140 = tail call i64 @fcntl(i32 %4, i32 %139, i32 0)
%141 = trunc i64 %140 to i32
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %138
%144 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %145
145: ; preds = %143, %138
%146 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %134, i32 %141)
%147 = load i32, i32* @F_GETFD
%148 = tail call i64 @fcntl(i32 %12, i32 %147, i32 0)
%149 = trunc i64 %148 to i32
%150 = icmp slt i32 %149, 0
br i1 %150, label %151, label %153
151: ; preds = %145
%152 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
br label %153
153: ; preds = %151, %145
%154 = load i32, i32* @F_GETFL
%155 = tail call i64 @fcntl(i32 %12, i32 %154, i32 0)
%156 = trunc i64 %155 to i32
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %160
158: ; preds = %153
%159 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
br label %160
160: ; preds = %158, %153
%161 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %149, i32 %156)
%162 = load i32, i32* @F_GETFD
%163 = tail call i64 @fcntl(i32 %17, i32 %162, i32 0)
%164 = trunc i64 %163 to i32
%165 = icmp slt i32 %164, 0
br i1 %165, label %166, label %168
166: ; preds = %160
%167 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %168
168: ; preds = %166, %160
%169 = load i32, i32* @F_GETFL
%170 = tail call i64 @fcntl(i32 %17, i32 %169, i32 0)
%171 = trunc i64 %170 to i32
%172 = icmp slt i32 %171, 0
br i1 %172, label %173, label %175
173: ; preds = %168
%174 = tail call i32 (i8*, ...) @err_sys(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %175
175: ; preds = %173, %168
%176 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %164, i32 %171)
%177 = tail call i32 @close(i32 %4)
%178 = tail call i32 @close(i32 %12)
%179 = tail call i32 @close(i32 %17)
ret i32 0
}