#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_type;
  int l_len;
  void *l_pid;
  scalar_t__ l_start;
  scalar_t__ l_whence;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ F_GETLK;
int /*<<< orphan*/ F_SETLK;
scalar_t__ F_UNLCK;
void *F_WRLCK;
int O_CREAT;
int O_EXCL;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int /*<<< orphan*/ alarm(int);
int /*<<< orphan*/ chdir(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, struct flock *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
void *getpid();
int open(char *, int, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct flock lock;
  int fd, ret, status = 1;
  pid_t pid;
  char *testdir = NULL;
  testdir = getenv("TESTDIR");
  if (testdir)
    chdir(testdir);
  alarm(10);
  if (!(pid = fork())) {
    sleep(2);
    fd = open("conftest.fcntl", O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "ERROR: failed to open %s (errno=%d)\n", "conftest.fcntl",
              (int)errno);
      exit(1);
    }
    lock.l_type = F_WRLCK;
    lock.l_whence = 0;
    lock.l_start = 0;
    lock.l_len = 4;
    lock.l_pid = getpid();
    lock.l_type = F_WRLCK;
    ret = fcntl(fd, F_GETLK, &lock);
    if ((ret == -1) || (lock.l_type == F_UNLCK)) {
      fprintf(stderr, "ERROR: lock test failed (ret=%d errno=%d)\n", ret,
              (int)errno);
      exit(1);
    } else {
      exit(0);
    }
  }
  unlink("conftest.fcntl");
  fd = open("conftest.fcntl", O_RDWR | O_CREAT | O_EXCL, 0600);
  if (fd == -1) {
    fprintf(stderr, "ERROR: failed to open %s (errno=%d)\n", "conftest.fcntl",
            (int)errno);
    exit(1);
  }
  lock.l_type = F_WRLCK;
  lock.l_whence = 0;
  lock.l_start = 0;
  lock.l_len = 4;
  lock.l_pid = getpid();
  fcntl(fd, F_SETLK, &lock);
  waitpid(pid, &status, 0);
  unlink("conftest.fcntl");
  status = (status == 0) ? 0 : 1;
  if (status) {
    fprintf(stderr, "ERROR: lock test failed with status=%d\n", status);
  }
  exit(status);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe14(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1209 <main+0x49>
mov    -0x50(%rbp),%rdi
call   1070 <chdir@plt>
mov    $0xa,%edi
call   1080 <alarm@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
jne    1333 <main+0x173>
mov    $0x2,%edi
call   10d0 <sleep@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1288 <main+0xc8>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    0x2d3c(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    0xda7(%rip),%rsi
lea    0xd91(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d09(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x4,-0x30(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %rax,-0x28(%rbp)
mov    0x2cd9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
je     12fc <main+0x13c>
mov    -0x38(%rbp),%rax
mov    0x2ccd(%rip),%rcx
cmp    (%rcx),%rax
jne    132c <main+0x16c>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
mov    0x2c91(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0xcce(%rip),%rdi
call   1040 <unlink@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%esi
mov    0x2ca9(%rip),%rax
or     (%rax),%esi
mov    0x2c50(%rip),%rax
or     (%rax),%esi
lea    0xca7(%rip),%rdi
mov    $0x180,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    13ae <main+0x1ee>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    0x2c16(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    0xc81(%rip),%rsi
lea    0xc6b(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2be3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x4,-0x30(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %rax,-0x28(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2be8(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    -0x48(%rbp),%edi
lea    -0x44(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
lea    0xc00(%rip),%rdi
call   1040 <unlink@plt>
mov    -0x44(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     1444 <main+0x284>
mov    0x2b7f(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xc2a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x44(%rbp),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movl   $0x1,0x4(%rsp)
lea    0xe29(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11e9 <main+0x29>
mov    %rax,%rdi
call   1070 <chdir@plt>
mov    $0xa,%edi
call   1080 <alarm@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
jne    12b4 <main+0xf4>
mov    $0x2,%edi
call   10d0 <sleep@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     12f7 <main+0x137>
mov    %eax,%ebx
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rsp)
movl   $0x4,0x10(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %rax,0x18(%rsp)
mov    0x2d47(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1050 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1288 <main+0xc8>
mov    0x8(%rsp),%rcx
mov    0x2d41(%rip),%rdx
cmp    (%rdx),%rcx
jne    13bd <main+0x1fd>
mov    0x2d21(%rip),%rcx
mov    (%rcx),%edi
mov    0x2d08(%rip),%rcx
mov    (%rcx),%ecx
lea    0xd9b(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %eax,%ebp
lea    0xd4b(%rip),%rbx
mov    %rbx,%rdi
call   1040 <unlink@plt>
mov    0x2d14(%rip),%rax
mov    0x2d25(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2cca(%rip),%rax
or     (%rax),%esi
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    $0x180,%edx
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
jne    1328 <main+0x168>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    0x2c99(%rip),%rax
mov    (%rax),%ecx
lea    0xd07(%rip),%rsi
lea    0xcf1(%rip),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %eax,%ebx
mov    0x2c67(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rsp)
movl   $0x4,0x10(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %rax,0x18(%rsp)
mov    0x2c74(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1050 <fcntl@plt>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   10a0 <waitpid@plt>
lea    0xc89(%rip),%rdi
call   1040 <unlink@plt>
xor    %eax,%eax
cmpl   $0x0,0x4(%rsp)
setne  %al
mov    %eax,0x4(%rsp)
je     13b5 <main+0x1f5>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x4(%rsp),%r14d
mov    %r14d,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.flock = type { i64, i32, i8*, i64, i64 }
@.str = [8 x i8] c"TESTDIR\00"
@.str.1 = [15 x i8] c"conftest.fcntl\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [37 x i8] c"ERROR: failed to open %s (errno=%d)\0A\00"
@errno = global i64 0
@F_WRLCK = global i8* null
@F_GETLK = global i32 0
@F_UNLCK = global i64 0
@.str.3 = [43 x i8] c"ERROR: lock test failed (ret=%d errno=%d)\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@F_SETLK = global i32 0
@.str.4 = [40 x i8] c"ERROR: lock test failed with status=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.flock
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
store i8* null, i8** %11
%12 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %11
%13 = load i8*, i8** %11
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %11
%17 = call i32 @chdir(i8* %16)
br label %18
18: ; preds = %15, %2
%19 = call i32 @alarm(i32 10)
%20 = call i32 (...) @fork()
store i32 %20, i32* %10
%21 = icmp ne i32 %20, 0
br i1 %21, label %65, label %22
22: ; preds = %18
%23 = call i32 @sleep(i32 2)
%24 = load i32, i32* @O_RDONLY
%25 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i64, i64* @errno
%31 = trunc i64 %30 to i32
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
%35 = load i8*, i8** @F_WRLCK
%36 = ptrtoint i8* %35 to i64
%37 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i64 %36, i64* %37
%38 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 4
store i64 0, i64* %38
%39 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 3
store i64 0, i64* %39
%40 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 1
store i32 4, i32* %40
%41 = call i8* (...) @getpid()
%42 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 2
store i8* %41, i8** %42
%43 = load i8*, i8** @F_WRLCK
%44 = ptrtoint i8* %43 to i64
%45 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i64 %44, i64* %45
%46 = load i32, i32* %7
%47 = load i32, i32* @F_GETLK
%48 = call i32 @fcntl(i32 %46, i32 %47, %struct.flock* %6)
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, -1
br i1 %50, label %56, label %51
51: ; preds = %34
%52 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
%53 = load i64, i64* %52
%54 = load i64, i64* @F_UNLCK
%55 = icmp eq i64 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %51, %34
%57 = load i32, i32* @stderr
%58 = load i32, i32* %8
%59 = load i64, i64* @errno
%60 = trunc i64 %59 to i32
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %58, i32 %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %51
%64 = call i32 @exit(i32 0)
unreachable
65: ; preds = %18
%66 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%67 = load i32, i32* @O_RDWR
%68 = load i32, i32* @O_CREAT
%69 = or i32 %67, %68
%70 = load i32, i32* @O_EXCL
%71 = or i32 %69, %70
%72 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %71, i32 384)
store i32 %72, i32* %7
%73 = load i32, i32* %7
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %81
75: ; preds = %65
%76 = load i32, i32* @stderr
%77 = load i64, i64* @errno
%78 = trunc i64 %77 to i32
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %78)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %65
%82 = load i8*, i8** @F_WRLCK
%83 = ptrtoint i8* %82 to i64
%84 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i64 %83, i64* %84
%85 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 4
store i64 0, i64* %85
%86 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 3
store i64 0, i64* %86
%87 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 1
store i32 4, i32* %87
%88 = call i8* (...) @getpid()
%89 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 2
store i8* %88, i8** %89
%90 = load i32, i32* %7
%91 = load i32, i32* @F_SETLK
%92 = call i32 @fcntl(i32 %90, i32 %91, %struct.flock* %6)
%93 = load i32, i32* %10
%94 = call i32 @waitpid(i32 %93, i32* %9, i32 0)
%95 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%96 = load i32, i32* %9
%97 = icmp eq i32 %96, 0
%98 = zext i1 %97 to i64
%99 = select i1 %97, i32 0, i32 1
store i32 %99, i32* %9
%100 = load i32, i32* %9
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %106
102: ; preds = %81
%103 = load i32, i32* @stderr
%104 = load i32, i32* %9
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %104)
br label %106
106: ; preds = %102, %81
%107 = load i32, i32* %9
%108 = call i32 @exit(i32 %107)
unreachable
}

LLVM IR (-O2):
%struct.flock = type { i64, i32, i8*, i64, i64 }
@.str = [8 x i8] c"TESTDIR\00"
@.str.1 = [15 x i8] c"conftest.fcntl\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [37 x i8] c"ERROR: failed to open %s (errno=%d)\0A\00"
@errno = global i64 0
@F_WRLCK = global i8* null
@F_GETLK = global i32 0
@F_UNLCK = global i64 0
@.str.3 = [43 x i8] c"ERROR: lock test failed (ret=%d errno=%d)\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@F_SETLK = global i32 0
@.str.4 = [40 x i8] c"ERROR: lock test failed with status=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.flock
%4 = alloca i32
%5 = bitcast %struct.flock* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @chdir(i8* %7)
br label %11
11: ; preds = %9, %2
%12 = tail call i32 @alarm(i32 10)
%13 = tail call i32 (...) @fork()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %50
15: ; preds = %11
%16 = tail call i32 @sleep(i32 2)
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = load i64, i64* @errno
%23 = trunc i64 %22 to i32
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %15
%27 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
%28 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 3
%29 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
%30 = bitcast i64* %28 to i8*
store i32 4, i32* %29
%31 = tail call i8* (...) @getpid()
%32 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 2
store i8* %31, i8** %32
%33 = load i8*, i8** @F_WRLCK
%34 = ptrtoint i8* %33 to i64
store i64 %34, i64* %27
%35 = load i32, i32* @F_GETLK
%36 = call i32 @fcntl(i32 %18, i32 %35, %struct.flock* %3)
%37 = icmp eq i32 %36, -1
br i1 %37, label %42, label %38
38: ; preds = %26
%39 = load i64, i64* %27
%40 = load i64, i64* @F_UNLCK
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %48
42: ; preds = %38, %26
%43 = load i32, i32* @stderr
%44 = load i64, i64* @errno
%45 = trunc i64 %44 to i32
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %36, i32 %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %11
%51 = tail call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* @O_RDWR
%53 = load i32, i32* @O_CREAT
%54 = or i32 %53, %52
%55 = load i32, i32* @O_EXCL
%56 = or i32 %54, %55
%57 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 384)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %65
59: ; preds = %50
%60 = load i32, i32* @stderr
%61 = load i64, i64* @errno
%62 = trunc i64 %61 to i32
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = tail call i32 @exit(i32 1)
unreachable
65: ; preds = %50
%66 = load i8*, i8** @F_WRLCK
%67 = ptrtoint i8* %66 to i64
%68 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
store i64 %67, i64* %68
%69 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 3
%70 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
%71 = bitcast i64* %69 to i8*
store i32 4, i32* %70
%72 = tail call i8* (...) @getpid()
%73 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 2
store i8* %72, i8** %73
%74 = load i32, i32* @F_SETLK
%75 = call i32 @fcntl(i32 %57, i32 %74, %struct.flock* %3)
%76 = call i32 @waitpid(i32 %13, i32* %4, i32 0)
%77 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%78 = load i32, i32* %4
%79 = icmp ne i32 %78, 0
%80 = zext i1 %79 to i32
store i32 %80, i32* %4
br i1 %79, label %81, label %85
81: ; preds = %65
%82 = load i32, i32* @stderr
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 1)
%84 = load i32, i32* %4
br label %85
85: ; preds = %81, %65
%86 = phi i32 [ %84, %81 ], [ 0, %65 ]
%87 = call i32 @exit(i32 %86)
unreachable
}