#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 lxc_lock {
  int dummy;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGKILL;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ WNOHANG;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
struct lxc_lock *lxc_newlock(char *, char *);
int /*<<< orphan*/ lxc_putlock(struct lxc_lock *);
scalar_t__ lxclock(struct lxc_lock *, int /*<<< orphan*/);
int /*<<< orphan*/ lxcunlock(struct lxc_lock *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int *);
int waitpid(int, int *, int /*<<< orphan*/);
scalar_t__ write(int, char *, int);
void test_two_locks(void) {
  struct lxc_lock *l;
  pid_t pid;
  int ret, status;
  int p[2];
  char c;
  if (pipe(p) < 0)
    exit(1);
  if ((pid = fork()) < 0)
    exit(1);
  if (pid == 0) {
    if (read(p[0], &c, 1) < 0) {
      perror("read");
      exit(1);
    }
    l = lxc_newlock("/tmp", "lxctest-sem");
    if (!l) {
      fprintf(stderr, "%d: child: failed to create lock\n", 49);
      exit(1);
    }
    if (lxclock(l, 0) < 0) {
      fprintf(stderr, "%d: child: failed to grab lock\n", 53);
      exit(1);
    }
    fprintf(stderr, "%d: child: grabbed lock\n", 56);
    exit(0);
  }
  l = lxc_newlock("/tmp", "lxctest-sem");
  if (!l) {
    fprintf(stderr, "%d: failed to create lock\n", 61);
    exit(1);
  }
  if (lxclock(l, 0) < 0) {
    fprintf(stderr, "%d; failed to get lock\n", 65);
    exit(1);
  }
  if (write(p[1], &c, 1) < 0) {
    perror("write");
    exit(1);
  }
  sleep(3);
  ret = waitpid(pid, &status, WNOHANG);
  if (ret == pid) {
    if (WIFEXITED(status)) {
      printf("%d exited normally with exit code %d\n", pid,
             WEXITSTATUS(status));
      if (WEXITSTATUS(status) == 0)
        exit(1);
    } else
      printf("%d did not exit normally\n", pid);
    return;
  } else if (ret < 0) {
    perror("waitpid");
    exit(1);
  }
  kill(pid, SIGKILL);
  wait(&status);
  close(p[1]);
  close(p[0]);
  lxcunlock(l);
  lxc_putlock(l);
}


x86 assembly (clang, -O0):
<test_two_locks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x1c(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    1255 <test_two_locks+0x25>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    $0x0,%al
call   1150 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1272 <test_two_locks+0x42>
mov    $0x1,%edi
call   1120 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    134d <test_two_locks+0x11d>
mov    -0x1c(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jge    12ad <test_two_locks+0x7d>
lea    0xd62(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xd51(%rip),%rdi
lea    0xd4f(%rip),%rsi
call   10d0 <lxc_newlock@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    12f3 <test_two_locks+0xc3>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
mov    $0x31,%edx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <lxclock@plt>
cmp    $0x0,%rax
jge    132c <test_two_locks+0xfc>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
mov    $0x35,%edx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
mov    $0x38,%edx
call   1090 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    0xcb1(%rip),%rdi
lea    0xcaf(%rip),%rsi
call   10d0 <lxc_newlock@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1393 <test_two_locks+0x163>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    $0x3d,%edx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <lxclock@plt>
cmp    $0x0,%rax
jge    13cc <test_two_locks+0x19c>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
lea    0xcd4(%rip),%rsi
mov    $0x41,%edx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    13fd <test_two_locks+0x1cd>
lea    0xcb6(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    -0xc(%rbp),%edi
mov    0x2bd7(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rsi
call   10f0 <waitpid@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1496 <test_two_locks+0x266>
mov    -0x14(%rbp),%edi
call   1110 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1480 <test_two_locks+0x250>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    -0x24(%rbp),%esi
mov    %rax,%rdx
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
jne    147b <test_two_locks+0x24b>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1491 <test_two_locks+0x261>
mov    -0xc(%rbp),%esi
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14f7 <test_two_locks+0x2c7>
cmpl   $0x0,-0x10(%rbp)
jge    14b6 <test_two_locks+0x286>
lea    0xc43(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    14bb <test_two_locks+0x28b>
mov    -0xc(%rbp),%edi
mov    0x2b0b(%rip),%rax
mov    (%rax),%esi
call   10b0 <kill@plt>
lea    -0x14(%rbp),%rdi
call   1140 <wait@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%rdi
call   10c0 <lxcunlock@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <lxc_putlock@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_two_locks>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     130a <test_two_locks+0xda>
xor    %eax,%eax
call   1150 <fork@plt>
test   %eax,%eax
js     130a <test_two_locks+0xda>
je     1372 <test_two_locks+0x142>
mov    %eax,%ebx
lea    0xd9d(%rip),%rdi
lea    0xd9b(%rip),%rsi
call   10d0 <lxc_newlock@plt>
test   %rax,%rax
je     1393 <test_two_locks+0x163>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <lxclock@plt>
test   %rax,%rax
js     13aa <test_two_locks+0x17a>
mov    0x14(%rsp),%edi
lea    0xb(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
test   %rax,%rax
js     13ce <test_two_locks+0x19e>
mov    $0x3,%edi
call   1130 <sleep@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
call   10f0 <waitpid@plt>
cmp    %ebx,%eax
jne    1314 <test_two_locks+0xe4>
mov    0xc(%rsp),%edi
call   1110 <WIFEXITED@plt>
test   %rax,%rax
je     135a <test_two_locks+0x12a>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
lea    0xdba(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
test   %rax,%rax
jne    136a <test_two_locks+0x13a>
mov    $0x1,%edi
call   1120 <exit@plt>
test   %eax,%eax
js     13d7 <test_two_locks+0x1a7>
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <kill@plt>
lea    0xc(%rsp),%rdi
call   1140 <wait@plt>
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    %r14,%rdi
call   10c0 <lxcunlock@plt>
mov    %r14,%rdi
call   10a0 <lxc_putlock@plt>
jmp    136a <test_two_locks+0x13a>
lea    0xd6f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x10(%rsp),%edi
lea    0xb(%rsp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
test   %rax,%rax
jns    13ed <test_two_locks+0x1bd>
lea    0xc6f(%rip),%rdi
jmp    13de <test_two_locks+0x1ae>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
mov    $0x3d,%edx
jmp    13bf <test_two_locks+0x18f>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
lea    0xcd2(%rip),%rsi
mov    $0x41,%edx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xccf(%rip),%rdi
jmp    13de <test_two_locks+0x1ae>
lea    0xd0c(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xc11(%rip),%rdi
lea    0xc0f(%rip),%rsi
call   10d0 <lxc_newlock@plt>
test   %rax,%rax
jne    141c <test_two_locks+0x1ec>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
lea    0xc01(%rip),%rsi
mov    $0x31,%edx
jmp    13bf <test_two_locks+0x18f>
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <lxclock@plt>
mov    0x2bab(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
jns    1445 <test_two_locks+0x215>
lea    0xbfd(%rip),%rsi
mov    $0x35,%edx
jmp    13bf <test_two_locks+0x18f>
lea    0xc0c(%rip),%rsi
mov    $0x38,%edx
call   1090 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.lxc_lock = type { i32 }
@.str = [5 x i8] c"read\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [12 x i8] c"lxctest-sem\00"
@stderr = global i32 0
@.str.3 = [34 x i8] c"%d: child: failed to create lock\0A\00"
@.str.4 = [32 x i8] c"%d: child: failed to grab lock\0A\00"
@.str.5 = [25 x i8] c"%d: child: grabbed lock\0A\00"
@.str.6 = [27 x i8] c"%d: failed to create lock\0A\00"
@.str.7 = [24 x i8] c"%d; failed to get lock\0A\00"
@.str.8 = [6 x i8] c"write\00"
@WNOHANG = global i32 0
@.str.9 = [38 x i8] c"%d exited normally with exit code %d\0A\00"
@.str.10 = [26 x i8] c"%d did not exit normally\0A\00"
@.str.11 = [8 x i8] c"waitpid\00"
@SIGKILL = global i32 0
define void @test_two_locks() {
%1 = alloca %struct.lxc_lock*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i8
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%8 = call i64 @pipe(i32* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = call i32 (...) @fork()
store i32 %13, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %12
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %48
20: ; preds = %17
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%22 = load i32, i32* %21
%23 = call i64 @read(i32 %22, i8* %6, i32 1)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %20
%29 = call %struct.lxc_lock* @lxc_newlock(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store %struct.lxc_lock* %29, %struct.lxc_lock** %1
%30 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%31 = icmp ne %struct.lxc_lock* %30, null
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 49)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%38 = call i64 @lxclock(%struct.lxc_lock* %37, i32 0)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 53)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %36
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 56)
%47 = call i32 @exit(i32 0)
unreachable
48: ; preds = %17
%49 = call %struct.lxc_lock* @lxc_newlock(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store %struct.lxc_lock* %49, %struct.lxc_lock** %1
%50 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%51 = icmp ne %struct.lxc_lock* %50, null
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 61)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %48
%57 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%58 = call i64 @lxclock(%struct.lxc_lock* %57, i32 0)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 65)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %56
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%66 = load i32, i32* %65
%67 = call i64 @write(i32 %66, i8* %6, i32 1)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %64
%73 = call i32 @sleep(i32 3)
%74 = load i32, i32* %2
%75 = load i32, i32* @WNOHANG
%76 = call i32 @waitpid(i32 %74, i32* %4, i32 %75)
store i32 %76, i32* %3
%77 = load i32, i32* %3
%78 = load i32, i32* %2
%79 = icmp eq i32 %77, %78
br i1 %79, label %80, label %99
80: ; preds = %72
%81 = load i32, i32* %4
%82 = call i64 @WIFEXITED(i32 %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %95
84: ; preds = %80
%85 = load i32, i32* %2
%86 = load i32, i32* %4
%87 = call i64 @WEXITSTATUS(i32 %86)
%88 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %85, i64 %87)
%89 = load i32, i32* %4
%90 = call i64 @WEXITSTATUS(i32 %89)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %84
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %84
br label %98
95: ; preds = %80
%96 = load i32, i32* %2
%97 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %95, %94
br label %121
99: ; preds = %72
%100 = load i32, i32* %3
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %99
br label %106
106: ; preds = %105
%107 = load i32, i32* %2
%108 = load i32, i32* @SIGKILL
%109 = call i32 @kill(i32 %107, i32 %108)
%110 = call i32 @wait(i32* %4)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
%117 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%118 = call i32 @lxcunlock(%struct.lxc_lock* %117)
%119 = load %struct.lxc_lock*, %struct.lxc_lock** %1
%120 = call i32 @lxc_putlock(%struct.lxc_lock* %119)
br label %121
121: ; preds = %106, %98
ret void
}

LLVM IR (-O2):
%struct.lxc_lock = type { i32 }
@.str = [5 x i8] c"read\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [12 x i8] c"lxctest-sem\00"
@stderr = global i32 0
@.str.3 = [34 x i8] c"%d: child: failed to create lock\0A\00"
@.str.4 = [32 x i8] c"%d: child: failed to grab lock\0A\00"
@.str.5 = [25 x i8] c"%d: child: grabbed lock\0A\00"
@.str.6 = [27 x i8] c"%d: failed to create lock\0A\00"
@.str.7 = [24 x i8] c"%d; failed to get lock\0A\00"
@.str.8 = [6 x i8] c"write\00"
@WNOHANG = global i32 0
@.str.9 = [38 x i8] c"%d exited normally with exit code %d\0A\00"
@.str.10 = [26 x i8] c"%d did not exit normally\0A\00"
@.str.11 = [8 x i8] c"waitpid\00"
@SIGKILL = global i32 0
define void @test_two_locks() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
%5 = bitcast [2 x i32]* %2 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%7 = call i64 @pipe(i32* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 (...) @fork()
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %11
%17 = icmp eq i32 %12, 0
br i1 %17, label %18, label %42
18: ; preds = %16
%19 = load i32, i32* %6
%20 = call i64 @read(i32 %19, i8* %3, i32 1)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = call %struct.lxc_lock* @lxc_newlock(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq %struct.lxc_lock* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 49)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = call i64 @lxclock(%struct.lxc_lock* %26, i32 0)
%34 = icmp slt i64 %33, 0
%35 = load i32, i32* @stderr
br i1 %34, label %36, label %39
36: ; preds = %32
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 53)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %32
%40 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 56)
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %16
%43 = call %struct.lxc_lock* @lxc_newlock(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq %struct.lxc_lock* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 61)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %42
%50 = call i64 @lxclock(%struct.lxc_lock* %43, i32 0)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 65)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %49
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%58 = load i32, i32* %57
%59 = call i64 @write(i32 %58, i8* %3, i32 1)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %56
%65 = call i32 @sleep(i32 3)
%66 = load i32, i32* @WNOHANG
%67 = call i32 @waitpid(i32 %12, i32* %1, i32 %66)
%68 = icmp eq i32 %67, %12
br i1 %68, label %69, label %84
69: ; preds = %64
%70 = load i32, i32* %1
%71 = call i64 @WIFEXITED(i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %82, label %73
73: ; preds = %69
%74 = load i32, i32* %1
%75 = call i64 @WEXITSTATUS(i32 %74)
%76 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %12, i64 %75)
%77 = load i32, i32* %1
%78 = call i64 @WEXITSTATUS(i32 %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %99
80: ; preds = %73
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %69
%83 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %12)
br label %99
84: ; preds = %64
%85 = icmp slt i32 %67, 0
br i1 %85, label %86, label %89
86: ; preds = %84
%87 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %84
%90 = load i32, i32* @SIGKILL
%91 = call i32 @kill(i32 %12, i32 %90)
%92 = call i32 @wait(i32* %1)
%93 = load i32, i32* %57
%94 = call i32 @close(i32 %93)
%95 = load i32, i32* %6
%96 = call i32 @close(i32 %95)
%97 = call i32 @lxcunlock(%struct.lxc_lock* %43)
%98 = call i32 @lxc_putlock(%struct.lxc_lock* %43)
br label %99
99: ; preds = %82, %73, %89
ret void
}