#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 flock {
  scalar_t__ l_start;
  int l_len;
  scalar_t__ l_type;
  int l_pid;
  int /*<<< orphan*/ l_whence;
};

/* Variables and functions */
int /*<<< orphan*/ F_GETLK;
int /*<<< orphan*/ F_SETLK;
scalar_t__ F_WRLCK;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fcntl(int, int /*<<< orphan*/, struct flock *);
int fork();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ pause();
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ safe_waitpid(int);
scalar_t__ write(int, char *, int);
int test4(int fd, __attribute__((__unused__)) int argc,
          const __attribute__((__unused__)) char **argv) {
  int pid;
  int pfd[2];
  struct flock fl;
  char ch;
  if (pipe(pfd) < 0)
    err(1, "pipe");
  fl.l_start = 0;
  fl.l_len = 99;
  fl.l_type = F_WRLCK;
  fl.l_whence = SEEK_SET;
  pid = fork();
  if (pid < 0)
    err(1, "fork");
  if (pid == 0) {
    if (fcntl(fd, F_SETLK, &fl) < 0)
      err(1, "F_SETLK (child)");
    if (write(pfd[1], "a", 1) < 0)
      err(1, "writing to pipe (child)");
    pause();
    exit(0);
  }
  if (read(pfd[0], &ch, 1) != 1)
    err(1, "reading from pipe (child)");
  if (fcntl(fd, F_GETLK, &fl) < 0)
    err(1, "F_GETLK");
  printf("4 - F_GETLK on locked region: ");
  do {
    if (fl.l_start != 0) {
      printf("FAIL (%s)\n", "fl.l_start != 0");
      return -1;
    }
  } while (0);
  do {
    if (fl.l_len != 99) {
      printf("FAIL (%s)\n", "fl.l_len != 99");
      return -1;
    }
  } while (0);
  do {
    if (fl.l_type != F_WRLCK) {
      printf("FAIL (%s)\n", "fl.l_type != F_WRLCK");
      return -1;
    }
  } while (0);
  do {
    if (fl.l_pid != pid) {
      printf("FAIL (%s)\n", "fl.l_pid != pid");
      return -1;
    }
  } while (0);
  kill(pid, SIGTERM);
  safe_waitpid(pid);
  close(pfd[0]);
  close(pfd[1]);
  do {
    printf("SUCCEED\n");
    return 0;
  } while (0);
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0x0,%rax
jge    11f6 <test4+0x36>
mov    $0x1,%edi
lea    0xe0f(%rip),%rsi
call   10c0 <err@plt>
movq   $0x0,-0x48(%rbp)
movl   $0x63,-0x40(%rbp)
mov    0x2db4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1244 <test4+0x84>
mov    $0x1,%edi
lea    0xdc6(%rip),%rsi
call   10c0 <err@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12bb <test4+0xfb>
mov    -0x8(%rbp),%edi
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    127e <test4+0xbe>
mov    $0x1,%edi
lea    0xd91(%rip),%rsi
call   10c0 <err@plt>
mov    -0x20(%rbp),%edi
lea    0xd92(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    12ad <test4+0xed>
mov    $0x1,%edi
lea    0xd74(%rip),%rsi
call   10c0 <err@plt>
mov    $0x0,%al
call   10b0 <pause@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x49(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
je     12e6 <test4+0x126>
mov    $0x1,%edi
lea    0xd53(%rip),%rsi
call   10c0 <err@plt>
mov    -0x8(%rbp),%edi
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1040 <fcntl@plt>
cmp    $0x0,%rax
jge    1316 <test4+0x156>
mov    $0x1,%edi
lea    0xd3d(%rip),%rsi
call   10c0 <err@plt>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x48(%rbp)
je     1350 <test4+0x190>
lea    0xd3f(%rip),%rdi
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143e <test4+0x27e>
jmp    1355 <test4+0x195>
jmp    135a <test4+0x19a>
cmpl   $0x63,-0x40(%rbp)
je     1385 <test4+0x1c5>
lea    0xd0a(%rip),%rdi
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143e <test4+0x27e>
jmp    138a <test4+0x1ca>
jmp    138f <test4+0x1cf>
mov    -0x38(%rbp),%rax
mov    0x2c26(%rip),%rcx
cmp    (%rcx),%rax
je     13c4 <test4+0x204>
lea    0xccb(%rip),%rdi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143e <test4+0x27e>
jmp    13c9 <test4+0x209>
jmp    13ce <test4+0x20e>
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     13fb <test4+0x23b>
lea    0xc94(%rip),%rdi
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143e <test4+0x27e>
jmp    1400 <test4+0x240>
mov    -0x1c(%rbp),%edi
mov    0x2bde(%rip),%rax
mov    (%rax),%esi
call   10a0 <kill@plt>
mov    -0x1c(%rbp),%edi
call   1030 <safe_waitpid@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
lea    0xc94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
call   1090 <pipe@plt>
test   %rax,%rax
jns    11fa <test4+0x2a>
lea    0xe10(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
movq   $0x0,0x10(%rsp)
movl   $0x63,0x18(%rsp)
mov    0x2dae(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x20(%rsp)
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
xor    %eax,%eax
call   10f0 <fork@plt>
mov    %eax,%ebx
test   %eax,%eax
js     129a <test4+0xca>
jne    12ab <test4+0xdb>
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
call   1050 <fcntl@plt>
test   %rax,%rax
jns    1261 <test4+0x91>
lea    0xdb3(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
mov    0xc(%rsp),%edi
lea    0xdae(%rip),%rsi
mov    $0x1,%edx
call   1060 <write@plt>
test   %rax,%rax
jns    128c <test4+0xbc>
lea    0xd9a(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
xor    %eax,%eax
call   10c0 <pause@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xd64(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x1,%eax
je     12d4 <test4+0x104>
lea    0xd6a(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebp,%edi
call   1050 <fcntl@plt>
test   %rax,%rax
jns    12ff <test4+0x12f>
lea    0xd59(%rip),%rsi
mov    $0x1,%edi
call   10d0 <err@plt>
lea    0xd50(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmpq   $0x0,0x10(%rsp)
je     1325 <test4+0x155>
lea    0xd59(%rip),%rdi
lea    0xd5d(%rip),%rsi
jmp    13a3 <test4+0x1d3>
cmpl   $0x63,0x18(%rsp)
jne    1375 <test4+0x1a5>
mov    0x20(%rsp),%rax
cmp    (%r14),%rax
jne    1385 <test4+0x1b5>
cmp    %ebx,0x28(%rsp)
jne    1395 <test4+0x1c5>
mov    0x2ca5(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <kill@plt>
mov    %ebx,%edi
call   1040 <safe_waitpid@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
lea    0xd58(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    13af <test4+0x1df>
lea    0xcf9(%rip),%rdi
lea    0xd0d(%rip),%rsi
jmp    13a3 <test4+0x1d3>
lea    0xce9(%rip),%rdi
lea    0xd0c(%rip),%rsi
jmp    13a3 <test4+0x1d3>
lea    0xcd9(%rip),%rdi
lea    0xd11(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.flock = type { i64, i32, i64, i32, i32 }
@.str = [5 x i8] c"pipe\00"
@F_WRLCK = global i64 0
@SEEK_SET = global i32 0
@.str.1 = [5 x i8] c"fork\00"
@F_SETLK = global i32 0
@.str.2 = [16 x i8] c"F_SETLK (child)\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [24 x i8] c"writing to pipe (child)\00"
@.str.5 = [26 x i8] c"reading from pipe (child)\00"
@F_GETLK = global i32 0
@.str.6 = [8 x i8] c"F_GETLK\00"
@.str.7 = [31 x i8] c"4 - F_GETLK on locked region: \00"
@.str.8 = [11 x i8] c"FAIL (%s)\0A\00"
@.str.9 = [16 x i8] c"fl.l_start != 0\00"
@.str.10 = [15 x i8] c"fl.l_len != 99\00"
@.str.11 = [21 x i8] c"fl.l_type != F_WRLCK\00"
@.str.12 = [16 x i8] c"fl.l_pid != pid\00"
@SIGTERM = global i32 0
@.str.13 = [9 x i8] c"SUCCEED\0A\00"
define i32 @test4(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = alloca %struct.flock
%11 = alloca i8
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%13 = call i64 @pipe(i32* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 0
store i64 0, i64* %18
%19 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 1
store i32 99, i32* %19
%20 = load i64, i64* @F_WRLCK
%21 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 2
store i64 %20, i64* %21
%22 = load i32, i32* @SEEK_SET
%23 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 4
store i32 %22, i32* %23
%24 = call i32 (...) @fork()
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %17
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %49
32: ; preds = %29
%33 = load i32, i32* %5
%34 = load i32, i32* @F_SETLK
%35 = call i64 @fcntl(i32 %33, i32 %34, %struct.flock* %10)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @err(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i64 @write(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @err(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %39
%47 = call i32 (...) @pause()
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %29
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i32 @read(i32 %51, i8* %11, i32 1)
%53 = icmp ne i32 %52, 1
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @err(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = load i32, i32* %5
%58 = load i32, i32* @F_GETLK
%59 = call i64 @fcntl(i32 %57, i32 %58, %struct.flock* %10)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @err(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %65
65: ; preds = %63
%66 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 0
%67 = load i64, i64* %66
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %4
br label %112
71: ; preds = %65
br label %72
72: ; preds = %71
br label %73
73: ; preds = %72
%74 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 1
%75 = load i32, i32* %74
%76 = icmp ne i32 %75, 99
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %4
br label %112
79: ; preds = %73
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
%82 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 2
%83 = load i64, i64* %82
%84 = load i64, i64* @F_WRLCK
%85 = icmp ne i64 %83, %84
br i1 %85, label %86, label %88
86: ; preds = %81
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %4
br label %112
88: ; preds = %81
br label %89
89: ; preds = %88
br label %90
90: ; preds = %89
%91 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 3
%92 = load i32, i32* %91
%93 = load i32, i32* %8
%94 = icmp ne i32 %92, %93
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %4
br label %112
97: ; preds = %90
br label %98
98: ; preds = %97
%99 = load i32, i32* %8
%100 = load i32, i32* @SIGTERM
%101 = call i32 @kill(i32 %99, i32 %100)
%102 = load i32, i32* %8
%103 = call i32 @safe_waitpid(i32 %102)
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%105 = load i32, i32* %104
%106 = call i32 @close(i32 %105)
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%108 = load i32, i32* %107
%109 = call i32 @close(i32 %108)
br label %110
110: ; preds = %98
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %4
br label %112
112: ; preds = %69, %77, %86, %95, %110
%113 = load i32, i32* %4
ret i32 %113
}

LLVM IR (-O2):
%struct.flock = type { i64, i32, i64, i32, i32 }
@.str = [5 x i8] c"pipe\00"
@F_WRLCK = global i64 0
@SEEK_SET = global i32 0
@.str.1 = [5 x i8] c"fork\00"
@F_SETLK = global i32 0
@.str.2 = [16 x i8] c"F_SETLK (child)\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [24 x i8] c"writing to pipe (child)\00"
@.str.5 = [26 x i8] c"reading from pipe (child)\00"
@F_GETLK = global i32 0
@.str.6 = [8 x i8] c"F_GETLK\00"
@.str.7 = [31 x i8] c"4 - F_GETLK on locked region: \00"
@.str.8 = [11 x i8] c"FAIL (%s)\0A\00"
@.str.9 = [16 x i8] c"fl.l_start != 0\00"
@.str.10 = [15 x i8] c"fl.l_len != 99\00"
@.str.11 = [21 x i8] c"fl.l_type != F_WRLCK\00"
@.str.12 = [16 x i8] c"fl.l_pid != pid\00"
@SIGTERM = global i32 0
@str = [8 x i8] c"SUCCEED\00"
define i32 @test4(i32 %0, i32 %1, i8** nocapture readnone %2) {
%4 = alloca [2 x i32]
%5 = alloca %struct.flock
%6 = alloca i8
%7 = bitcast [2 x i32]* %4 to i8*
%8 = bitcast %struct.flock* %5 to i8*
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%10 = call i64 @pipe(i32* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %3
%15 = getelementptr inbounds %struct.flock, %struct.flock* %5, i64 0, i32 0
store i64 0, i64* %15
%16 = getelementptr inbounds %struct.flock, %struct.flock* %5, i64 0, i32 1
store i32 99, i32* %16
%17 = load i64, i64* @F_WRLCK
%18 = getelementptr inbounds %struct.flock, %struct.flock* %5, i64 0, i32 2
store i64 %17, i64* %18
%19 = load i32, i32* @SEEK_SET
%20 = getelementptr inbounds %struct.flock, %struct.flock* %5, i64 0, i32 4
store i32 %19, i32* %20
%21 = call i32 (...) @fork()
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %43
25: ; preds = %14
%26 = icmp eq i32 %21, 0
br i1 %26, label %27, label %43
27: ; preds = %25
%28 = load i32, i32* @F_SETLK
%29 = call i64 @fcntl(i32 %0, i32 %28, %struct.flock* %5)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @err(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%35 = load i32, i32* %34
%36 = call i64 @write(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @err(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %33
%41 = call i32 (...) @pause()
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %23, %25
%44 = load i32, i32* %9
%45 = call i32 @read(i32 %44, i8* %6, i32 1)
%46 = icmp eq i32 %45, 1
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = call i32 @err(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = load i32, i32* @F_GETLK
%51 = call i64 @fcntl(i32 %0, i32 %50, %struct.flock* %5)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 @err(i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%57 = load i64, i64* %15
%58 = icmp eq i64 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %88
61: ; preds = %55
%62 = load i32, i32* %16
%63 = icmp eq i32 %62, 99
br i1 %63, label %66, label %64
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %88
66: ; preds = %61
%67 = load i64, i64* %18
%68 = load i64, i64* @F_WRLCK
%69 = icmp eq i64 %67, %68
br i1 %69, label %72, label %70
70: ; preds = %66
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %88
72: ; preds = %66
%73 = getelementptr inbounds %struct.flock, %struct.flock* %5, i64 0, i32 3
%74 = load i32, i32* %73
%75 = icmp eq i32 %74, %21
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %88
78: ; preds = %72
%79 = load i32, i32* @SIGTERM
%80 = call i32 @kill(i32 %21, i32 %79)
%81 = call i32 @safe_waitpid(i32 %21)
%82 = load i32, i32* %9
%83 = call i32 @close(i32 %82)
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%85 = load i32, i32* %84
%86 = call i32 @close(i32 %85)
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %88
88: ; preds = %78, %76, %70, %64, %59
%89 = phi i32 [ -1, %59 ], [ -1, %64 ], [ -1, %70 ], [ -1, %76 ], [ 0, %78 ]
ret i32 %89
}