#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 scalar_t__ pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int mkfifo(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ stderr;
pid_t create_file_namepipe(FILE **fp_from, FILE **fp_to) {
  FILE *fp_r = NULL;
  FILE *fp_w = NULL;
  int flags = 0;
  pid_t pid;
  int ret;
  fprintf(stderr,
          "{ciut} "
          "create name pipe '%s' ...\n",
          "cuit-io-namedfifo");
  ret = mkfifo("cuit-io-namedfifo", S_IRWXU);
  if ((pid = fork()) < 0) {
    perror("{ciut} "
           "fork failed");
    goto err_create_npipe;
  }
  if (pid == (pid_t)0) {
    fprintf(stderr,
            "{ciut} "
            "child open pipe '%s' for writing ...\n",
            "cuit-io-namedfifo");
    fp_w = fopen("cuit-io-namedfifo", "w");
    if (!fp_w) {
      perror("{ciut} "
             "child fdopen write stream");
      exit(-1);
    }
    assert(NULL != fp_w);
    assert(NULL != fp_from);
    *fp_from = fp_w;
  } else {
    fprintf(stderr,
            "{ciut} "
            "parent open pipe '%s' for reading ...\n",
            "cuit-io-namedfifo");
    fp_r = fopen("cuit-io-namedfifo", "r");
    if (!fp_r) {
      perror("{ciut} "
             "parent fdopen read stream");
      goto err_create_npipe;
    }
    assert(NULL != fp_r);
    fprintf(stderr,
            "{ciut} "
            "parent change pipe '%s' flags ...\n",
            "cuit-io-namedfifo");
    if ((flags = fcntl(fileno(fp_r), F_GETFL)) == -1) {
      fprintf(stderr,
              "{ciut} "
              "parent fcntl returned -1 for %s\n",
              "cuit-io-namedfifo");
      goto err_create_npipe;
    }
    assert(NULL != fp_r);
    flags &= (O_NONBLOCK);
    if ((fcntl(fileno(fp_r), F_SETFL, flags)) == -1) {
      fprintf(stderr,
              "{ciut} "
              "parent fcntl returned -1 for %s\n",
              "cuit-io-namedfifo");
      goto err_create_npipe;
    }
    assert(NULL != fp_r);
    assert(NULL != fp_to);
    *fp_to = fp_r;
  }
  return pid;
err_create_npipe:
  remove("cuit-io-namedfifo");
  if (NULL != fp_r) {
    fclose(fp_r);
  }
  if (NULL != fp_w) {
    fclose(fp_w);
  }
  return -1;
}


x86 assembly (clang, -O0):
<create_file_namepipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
lea    0xe34(%rip),%rdx
call   1070 <fprintf@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe1f(%rip),%rdi
call   1080 <mkfifo@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jge    1231 <create_file_namepipe+0x81>
lea    0xe0d(%rip),%rdi
call   10b0 <perror@plt>
jmp    1434 <create_file_namepipe+0x284>
cmpq   $0x0,-0x38(%rbp)
jne    12c6 <create_file_namepipe+0x116>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
lea    0xdcf(%rip),%rdx
call   1070 <fprintf@plt>
lea    0xdc3(%rip),%rdi
lea    0xe0e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1290 <create_file_namepipe+0xe0>
lea    0xdf5(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1427 <create_file_namepipe+0x277>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
lea    0xd45(%rip),%rdx
call   1070 <fprintf@plt>
lea    0xd39(%rip),%rdi
lea    0xdd5(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1315 <create_file_namepipe+0x165>
lea    0xdbc(%rip),%rdi
call   10b0 <perror@plt>
jmp    1434 <create_file_namepipe+0x284>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
lea    0xce3(%rip),%rdx
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
mov    0x2c6a(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1040 <fcntl@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    138c <create_file_namepipe+0x1dc>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
lea    0xca0(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1434 <create_file_namepipe+0x284>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
and    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
mov    0x2c08(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    $0x0,%al
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    13f6 <create_file_namepipe+0x246>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xd2d(%rip),%rsi
lea    0xc36(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1434 <create_file_namepipe+0x284>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1472 <create_file_namepipe+0x2c2>
lea    0xbe7(%rip),%rdi
call   1030 <remove@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
je     1455 <create_file_namepipe+0x2a5>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     146a <create_file_namepipe+0x2ba>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_file_namepipe>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e0b(%rip),%r12
mov    (%r12),%edi
lea    0xe30(%rip),%rsi
lea    0xe4b(%rip),%rbx
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <mkfifo@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %rax,%rax
js     1354 <create_file_namepipe+0x1a4>
mov    (%r12),%edi
je     12d8 <create_file_namepipe+0x128>
mov    %rax,%rbx
lea    0xe83(%rip),%rsi
lea    0xe07(%rip),%rbp
mov    %rbp,%rdx
call   1070 <fprintf@plt>
lea    0xe9b(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     135d <create_file_namepipe+0x1ad>
mov    %rax,%r15
mov    $0x1,%edi
call   1060 <assert@plt>
mov    (%r12),%edi
lea    0xe95(%rip),%rsi
lea    0xdc8(%rip),%rdx
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1090 <fileno@plt>
mov    0x2d52(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %eax,%eax
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1328 <create_file_namepipe+0x178>
mov    %eax,%ebp
mov    $0x1,%edi
call   1060 <assert@plt>
mov    0x2d4b(%rip),%rax
and    (%rax),%ebp
mov    %r15,%rdi
call   1090 <fileno@plt>
mov    0x2d22(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1328 <create_file_namepipe+0x178>
mov    $0x1,%edi
call   1060 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1060 <assert@plt>
mov    %r15,(%r14)
jmp    137c <create_file_namepipe+0x1cc>
lea    0xd68(%rip),%rsi
lea    0xd3c(%rip),%rbx
mov    %rbx,%rdx
call   1070 <fprintf@plt>
lea    0xd7f(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1388 <create_file_namepipe+0x1d8>
mov    %rax,%rbx
mov    $0x1,%edi
call   1060 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1060 <assert@plt>
mov    %rbx,(%r15)
xor    %ebx,%ebx
jmp    137c <create_file_namepipe+0x1cc>
mov    (%r12),%edi
lea    0xddf(%rip),%rsi
lea    0xce8(%rip),%rbx
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
jmp    1375 <create_file_namepipe+0x1c5>
lea    0xcd9(%rip),%rdi
jmp    1364 <create_file_namepipe+0x1b4>
lea    0xd63(%rip),%rdi
call   10b0 <perror@plt>
lea    0xcb2(%rip),%rdi
call   1030 <remove@plt>
mov    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce7(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"{ciut} create name pipe '%s' ...\0A\00"
@.str.1 = [18 x i8] c"cuit-io-namedfifo\00"
@S_IRWXU = global i32 0
@.str.2 = [19 x i8] c"{ciut} fork failed\00"
@.str.3 = [45 x i8] c"{ciut} child open pipe '%s' for writing ...\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [33 x i8] c"{ciut} child fdopen write stream\00"
@.str.6 = [46 x i8] c"{ciut} parent open pipe '%s' for reading ...\0A\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [33 x i8] c"{ciut} parent fdopen read stream\00"
@.str.9 = [42 x i8] c"{ciut} parent change pipe '%s' flags ...\0A\00"
@F_GETFL = global i32 0
@.str.10 = [40 x i8] c"{ciut} parent fcntl returned -1 for %s\0A\00"
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
define i64 @create_file_namepipe(i32** %0, i32** %1) {
%3 = alloca i64
%4 = alloca i32**
%5 = alloca i32**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i32** %0, i32*** %4
store i32** %1, i32*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @S_IRWXU
%14 = call i32 @mkfifo(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13)
store i32 %14, i32* %10
%15 = call i64 (...) @fork()
store i64 %15, i64* %9
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %95
19: ; preds = %2
%20 = load i64, i64* %9
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %42
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = icmp ne i32* %26, null
br i1 %27, label %31, label %28
28: ; preds = %22
%29 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %22
%32 = load i32*, i32** %7
%33 = icmp ne i32* null, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32**, i32*** %4
%37 = icmp ne i32** null, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i32*, i32** %7
%41 = load i32**, i32*** %4
store i32* %40, i32** %41
br label %93
42: ; preds = %19
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %45, i32** %6
%46 = load i32*, i32** %6
%47 = icmp ne i32* %46, null
br i1 %47, label %50, label %48
48: ; preds = %42
%49 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %95
50: ; preds = %42
%51 = load i32*, i32** %6
%52 = icmp ne i32* null, %51
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32*, i32** %6
%58 = call i32 @fileno(i32* %57)
%59 = load i32, i32* @F_GETFL
%60 = call i32 (i32, i32, ...) @fcntl(i32 %58, i32 %59)
store i32 %60, i32* %8
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %65
62: ; preds = %50
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %95
65: ; preds = %50
%66 = load i32*, i32** %6
%67 = icmp ne i32* null, %66
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = load i32, i32* @O_NONBLOCK
%71 = load i32, i32* %8
%72 = and i32 %71, %70
store i32 %72, i32* %8
%73 = load i32*, i32** %6
%74 = call i32 @fileno(i32* %73)
%75 = load i32, i32* @F_SETFL
%76 = load i32, i32* %8
%77 = call i32 (i32, i32, ...) @fcntl(i32 %74, i32 %75, i32 %76)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %82
79: ; preds = %65
%80 = load i32, i32* @stderr
%81 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %95
82: ; preds = %65
%83 = load i32*, i32** %6
%84 = icmp ne i32* null, %83
%85 = zext i1 %84 to i32
%86 = call i32 @assert(i32 %85)
%87 = load i32**, i32*** %5
%88 = icmp ne i32** null, %87
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
%91 = load i32*, i32** %6
%92 = load i32**, i32*** %5
store i32* %91, i32** %92
br label %93
93: ; preds = %82, %31
%94 = load i64, i64* %9
store i64 %94, i64* %3
br label %109
95: ; preds = %79, %62, %48, %17
%96 = call i32 @remove(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%97 = load i32*, i32** %6
%98 = icmp ne i32* null, %97
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = load i32*, i32** %6
%101 = call i32 @fclose(i32* %100)
br label %102
102: ; preds = %99, %95
%103 = load i32*, i32** %7
%104 = icmp ne i32* null, %103
br i1 %104, label %105, label %108
105: ; preds = %102
%106 = load i32*, i32** %7
%107 = call i32 @fclose(i32* %106)
br label %108
108: ; preds = %105, %102
store i64 -1, i64* %3
br label %109
109: ; preds = %108, %93
%110 = load i64, i64* %3
ret i64 %110
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"{ciut} create name pipe '%s' ...\0A\00"
@.str.1 = [18 x i8] c"cuit-io-namedfifo\00"
@S_IRWXU = global i32 0
@.str.2 = [19 x i8] c"{ciut} fork failed\00"
@.str.3 = [45 x i8] c"{ciut} child open pipe '%s' for writing ...\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [33 x i8] c"{ciut} child fdopen write stream\00"
@.str.6 = [46 x i8] c"{ciut} parent open pipe '%s' for reading ...\0A\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [33 x i8] c"{ciut} parent fdopen read stream\00"
@.str.9 = [42 x i8] c"{ciut} parent change pipe '%s' flags ...\0A\00"
@F_GETFL = global i32 0
@.str.10 = [40 x i8] c"{ciut} parent fcntl returned -1 for %s\0A\00"
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
define i64 @create_file_namepipe(i32** writeonly %0, i32** writeonly %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @S_IRWXU
%6 = tail call i32 @mkfifo(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i64 (...) @fork()
%8 = icmp slt i64 %7, 0
br i1 %8, label %49, label %9
9: ; preds = %2
%10 = icmp eq i64 %7, 0
%11 = load i32, i32* @stderr
br i1 %10, label %12, label %24
12: ; preds = %9
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = tail call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %12
%20 = tail call i32 @assert(i32 1)
%21 = icmp ne i32** %0, null
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
store i32* %14, i32** %0
br label %58
24: ; preds = %9
%25 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %49, label %28
28: ; preds = %24
%29 = tail call i32 @assert(i32 1)
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%32 = tail call i32 @fileno(i32* %26)
%33 = load i32, i32* @F_GETFL
%34 = tail call i32 (i32, i32, ...) @fcntl(i32 %32, i32 %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %53, label %36
36: ; preds = %28
%37 = tail call i32 @assert(i32 1)
%38 = load i32, i32* @O_NONBLOCK
%39 = and i32 %38, %34
%40 = tail call i32 @fileno(i32* %26)
%41 = load i32, i32* @F_SETFL
%42 = tail call i32 (i32, i32, ...) @fcntl(i32 %40, i32 %41, i32 %39)
%43 = icmp eq i32 %42, -1
br i1 %43, label %53, label %44
44: ; preds = %36
%45 = tail call i32 @assert(i32 1)
%46 = icmp ne i32** %1, null
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
store i32* %26, i32** %1
br label %58
49: ; preds = %24, %2
%50 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), %24 ]
%51 = tail call i32 @perror(i8* %50)
%52 = tail call i32 @remove(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %58
53: ; preds = %36, %28
%54 = load i32, i32* @stderr
%55 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%56 = tail call i32 @remove(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%57 = tail call i32 @fclose(i32* %26)
br label %58
58: ; preds = %49, %53, %19, %44
%59 = phi i64 [ %7, %44 ], [ 0, %19 ], [ -1, %53 ], [ -1, %49 ]
ret i64 %59
}