#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 {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ mkfifo(char *, int);
int open(char *, int, ...);
int read(int, char *, int);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int add_reach_runlevel_mark() {
  int fd, found, len, ret;
  char buf[4096];
  struct stat st;
  unlink("/.vzfifo");
  if (mkfifo("/.vzfifo", 0644)) {
    fprintf(stderr,
            "Unable to create "
            "/.vzfifo"
            " %s\n",
            strerror(errno));
    return -1;
  }
  if (!stat("/etc/event.d/", &st)) {
    if ((fd = open("/etc/event.d/"
                   "vz_init_done",
                   O_WRONLY | O_TRUNC | O_CREAT, 0644))) {
      write(fd,
            "# This task runs if default runlevel is reached\n"
            "# Added by OpenVZ vzctl\n"
            "start on stopped rc2\n"
            "start on stopped rc3\n"
            "start on stopped rc4\n"
            "start on stopped rc5\n"
            "exec touch "
            "/.vzfifo"
            "\n",
            sizeof("# This task runs if default runlevel is reached\n"
                   "# Added by OpenVZ vzctl\n"
                   "start on stopped rc2\n"
                   "start on stopped rc3\n"
                   "start on stopped rc4\n"
                   "start on stopped rc5\n"
                   "exec touch "
                   "/.vzfifo"
                   "\n") -
                1);
      close(fd);
      return 0;
    }
  }
  if ((fd = open("/etc/inittab", O_RDWR | O_APPEND)) == -1) {
    fprintf(stderr,
            "Unable to open "
            "/etc/inittab"
            " %s\n",
            strerror(errno));
    return -1;
  }
  ret = 0;
  found = 0;
  while (1) {
    len = read(fd, buf, sizeof(buf));
    if (len == 0)
      break;
    if (len < 0) {
      fprintf(stderr,
              "Unable to read from "
              "/etc/inittab"
              " %s\n",
              strerror(errno));
      ret = -1;
      break;
    }
    buf[len] = 0;
    if (strstr(buf, "\n"
                    "vz:") != NULL) {
      found = 1;
      break;
    }
  }
  if (!found) {
    if (write(fd,
              "vz:"
              "2345:once:touch "
              "/.vzfifo"
              "\n",
              sizeof("vz:"
                     "2345:once:touch "
                     "/.vzfifo"
                     "\n") -
                  1) == -1) {
      fprintf(stderr,
              "Unable to write to "
              "/etc/inittab"
              " %s\n",
              strerror(errno));
      ret = -1;
    }
  }
  close(fd);
  return ret;
}


x86 assembly (clang, -O0):
<add_reach_runlevel_mark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
lea    0xe4e(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe42(%rip),%rdi
mov    $0x1a4,%esi
call   1080 <mkfifo@plt>
cmp    $0x0,%rax
je     1210 <add_reach_runlevel_mark+0x70>
mov    0x2def(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x102c(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x102c(%rbp),%edi
mov    %rax,%rdx
lea    0xe0a(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1426 <add_reach_runlevel_mark+0x286>
lea    0xe10(%rip),%rdi
lea    -0x1028(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%eax
jne    1293 <add_reach_runlevel_mark+0xf3>
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
mov    0x2db4(%rip),%rax
or     (%rax),%esi
mov    0x2db3(%rip),%rax
or     (%rax),%esi
lea    0xde7(%rip),%rdi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     128e <add_reach_runlevel_mark+0xee>
mov    -0x8(%rbp),%edi
lea    0xddf(%rip),%rsi
mov    $0xb0,%edx
call   1040 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1426 <add_reach_runlevel_mark+0x286>
jmp    1293 <add_reach_runlevel_mark+0xf3>
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
mov    0x2d05(%rip),%rax
or     (%rax),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    12fd <add_reach_runlevel_mark+0x15d>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1030(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x1030(%rbp),%edi
mov    %rax,%rdx
lea    0xe21(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1426 <add_reach_runlevel_mark+0x286>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1331 <add_reach_runlevel_mark+0x191>
jmp    13b3 <add_reach_runlevel_mark+0x213>
cmpl   $0x0,-0x10(%rbp)
jge    1379 <add_reach_runlevel_mark+0x1d9>
mov    0x2c86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1034(%rbp)
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x1034(%rbp),%edi
mov    %rax,%rdx
lea    0xdc5(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    13b3 <add_reach_runlevel_mark+0x213>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     13ae <add_reach_runlevel_mark+0x20e>
movl   $0x1,-0xc(%rbp)
jmp    13b3 <add_reach_runlevel_mark+0x213>
jmp    130b <add_reach_runlevel_mark+0x16b>
cmpl   $0x0,-0xc(%rbp)
jne    1418 <add_reach_runlevel_mark+0x278>
mov    -0x8(%rbp),%edi
lea    0xd90(%rip),%rsi
mov    $0x1c,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1413 <add_reach_runlevel_mark+0x273>
mov    0x2be7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1038(%rbp)
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x1038(%rbp),%edi
mov    %rax,%rdx
lea    0xd6d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1418 <add_reach_runlevel_mark+0x278>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_reach_runlevel_mark>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
lea    0xe4e(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rbx,%rdi
mov    $0x1a4,%esi
call   1080 <mkfifo@plt>
test   %rax,%rax
je     11fe <add_reach_runlevel_mark+0x5e>
mov    0x2df5(%rip),%rax
mov    (%rax),%ebx
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe1f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    137d <add_reach_runlevel_mark+0x1dd>
lea    0xe22(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1090 <stat@plt>
test   %eax,%eax
je     128b <add_reach_runlevel_mark+0xeb>
mov    0x2dbe(%rip),%rax
mov    0x2d87(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     12dd <add_reach_runlevel_mark+0x13d>
mov    %eax,%ebx
lea    0x10(%rsp),%rbp
lea    0xf08(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
test   %eax,%eax
je     1300 <add_reach_runlevel_mark+0x160>
js     1304 <add_reach_runlevel_mark+0x164>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
je     1250 <add_reach_runlevel_mark+0xb0>
xor    %ebp,%ebp
jmp    1376 <add_reach_runlevel_mark+0x1d6>
mov    0x2d1e(%rip),%rax
mov    0x2d57(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d54(%rip),%rax
or     (%rax),%esi
lea    0xd88(%rip),%rdi
xor    %ebp,%ebp
mov    $0x1a4,%edx
xor    %eax,%eax
call   10a0 <open@plt>
test   %eax,%eax
je     1213 <add_reach_runlevel_mark+0x73>
mov    %eax,%ebx
lea    0xd83(%rip),%rsi
mov    %eax,%edi
mov    $0xb0,%edx
call   1040 <write@plt>
jmp    1376 <add_reach_runlevel_mark+0x1d6>
mov    0x2ce4(%rip),%rax
mov    (%rax),%ebx
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe12(%rip),%rsi
jmp    11ea <add_reach_runlevel_mark+0x4a>
xor    %ebp,%ebp
jmp    1331 <add_reach_runlevel_mark+0x191>
mov    0x2cbd(%rip),%rax
mov    (%rax),%ebp
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe0b(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
lea    0xe1f(%rip),%rsi
mov    %ebx,%edi
mov    $0x1c,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1376 <add_reach_runlevel_mark+0x1d6>
mov    0x2c78(%rip),%rax
mov    (%rax),%ebp
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe0d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebx,%edi
call   1050 <close@plt>
mov    %ebp,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [9 x i8] c"/.vzfifo\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Unable to create /.vzfifo %s\0A\00"
@errno = global i32 0
@.str.2 = [14 x i8] c"/etc/event.d/\00"
@.str.3 = [26 x i8] c"/etc/event.d/vz_init_done\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.4 = [177 x i8] c"# This task runs if default runlevel is reached\0A# Added by OpenVZ vzctl\0Astart on stopped rc2\0Astart on stopped rc3\0Astart on stopped rc4\0Astart on stopped rc5\0Aexec touch /.vzfifo\0A\00"
@.str.5 = [13 x i8] c"/etc/inittab\00"
@O_RDWR = global i32 0
@O_APPEND = global i32 0
@.str.6 = [32 x i8] c"Unable to open /etc/inittab %s\0A\00"
@.str.7 = [37 x i8] c"Unable to read from /etc/inittab %s\0A\00"
@.str.8 = [5 x i8] c"\0Avz:\00"
@.str.9 = [29 x i8] c"vz:2345:once:touch /.vzfifo\0A\00"
@.str.10 = [36 x i8] c"Unable to write to /etc/inittab %s\0A\00"
define i32 @add_reach_runlevel_mark() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4096 x i8]
%7 = alloca %struct.stat
%8 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 -1, i32* %1
br label %86
16: ; preds = %0
%17 = call i32 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %7)
%18 = icmp ne i32 %17, 0
br i1 %18, label %33, label %19
19: ; preds = %16
%20 = load i32, i32* @O_WRONLY
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = load i32, i32* @O_CREAT
%24 = or i32 %22, %23
%25 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 420)
store i32 %25, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = load i32, i32* %2
%29 = call i32 @write(i32 %28, i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.4, i64 0, i64 0), i32 176)
%30 = load i32, i32* %2
%31 = call i32 @close(i32 %30)
store i32 0, i32* %1
br label %86
32: ; preds = %19
br label %33
33: ; preds = %32, %16
%34 = load i32, i32* @O_RDWR
%35 = load i32, i32* @O_APPEND
%36 = or i32 %34, %35
%37 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %36)
store i32 %37, i32* %2
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %42)
store i32 -1, i32* %1
br label %86
44: ; preds = %33
store i32 0, i32* %5
store i32 0, i32* %3
br label %45
45: ; preds = %44, %68
%46 = load i32, i32* %2
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%48 = call i32 @read(i32 %46, i8* %47, i32 4096)
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %45
br label %69
52: ; preds = %45
%53 = load i32, i32* %4
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %58)
store i32 -1, i32* %5
br label %69
60: ; preds = %52
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %62
store i8 0, i8* %63
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%65 = call i32* @strstr(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %68
67: ; preds = %60
store i32 1, i32* %3
br label %69
68: ; preds = %60
br label %45
69: ; preds = %67, %55, %51
%70 = load i32, i32* %3
%71 = icmp ne i32 %70, 0
br i1 %71, label %82, label %72
72: ; preds = %69
%73 = load i32, i32* %2
%74 = call i32 @write(i32 %73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 28)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %81
76: ; preds = %72
%77 = load i32, i32* @stderr
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i8* %79)
store i32 -1, i32* %5
br label %81
81: ; preds = %76, %72
br label %82
82: ; preds = %81, %69
%83 = load i32, i32* %2
%84 = call i32 @close(i32 %83)
%85 = load i32, i32* %5
store i32 %85, i32* %1
br label %86
86: ; preds = %82, %39, %27, %11
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [9 x i8] c"/.vzfifo\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Unable to create /.vzfifo %s\0A\00"
@errno = global i32 0
@.str.2 = [14 x i8] c"/etc/event.d/\00"
@.str.3 = [26 x i8] c"/etc/event.d/vz_init_done\00"
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@.str.4 = [177 x i8] c"# This task runs if default runlevel is reached\0A# Added by OpenVZ vzctl\0Astart on stopped rc2\0Astart on stopped rc3\0Astart on stopped rc4\0Astart on stopped rc5\0Aexec touch /.vzfifo\0A\00"
@.str.5 = [13 x i8] c"/etc/inittab\00"
@O_RDWR = global i32 0
@O_APPEND = global i32 0
@.str.6 = [32 x i8] c"Unable to open /etc/inittab %s\0A\00"
@.str.7 = [37 x i8] c"Unable to read from /etc/inittab %s\0A\00"
@.str.8 = [5 x i8] c"\0Avz:\00"
@.str.9 = [29 x i8] c"vz:2345:once:touch /.vzfifo\0A\00"
@.str.10 = [36 x i8] c"Unable to write to /etc/inittab %s\0A\00"
define i32 @add_reach_runlevel_mark() {
%1 = alloca [4096 x i8]
%2 = alloca %struct.stat
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.stat* %2 to i8*
%5 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %65
13: ; preds = %0
%14 = call i32 @stat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %struct.stat* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i32, i32* @O_WRONLY
%18 = load i32, i32* @O_TRUNC
%19 = or i32 %18, %17
%20 = load i32, i32* @O_CREAT
%21 = or i32 %19, %20
%22 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 420)
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %16
%25 = tail call i32 @write(i32 %22, i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.4, i64 0, i64 0), i32 176)
%26 = tail call i32 @close(i32 %22)
br label %65
27: ; preds = %16, %13
%28 = load i32, i32* @O_RDWR
%29 = load i32, i32* @O_APPEND
%30 = or i32 %29, %28
%31 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = load i32, i32* @errno
%36 = tail call i8* @strerror(i32 %35)
%37 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %36)
br label %65
38: ; preds = %27, %48
%39 = call i32 @read(i32 %31, i8* %3, i32 4096)
%40 = icmp eq i32 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %38
%42 = icmp slt i32 %39, 0
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %46)
br label %53
48: ; preds = %41
%49 = zext i32 %39 to i64
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i32* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%52 = icmp eq i32* %51, null
br i1 %52, label %38, label %62
53: ; preds = %38, %43
%54 = phi i32 [ -1, %43 ], [ 0, %38 ]
%55 = call i32 @write(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 28)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %62
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %48, %53, %57
%63 = phi i32 [ -1, %57 ], [ %54, %53 ], [ 0, %48 ]
%64 = call i32 @close(i32 %31)
br label %65
65: ; preds = %62, %33, %24, %8
%66 = phi i32 [ -1, %8 ], [ -1, %33 ], [ %63, %62 ], [ 0, %24 ]
ret i32 %66
}