#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 */

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ F_RDLCK;
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_UNLCK;
int /*<<< orphan*/ F_WRLCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ Perror(char *);
int /*<<< orphan*/ SEEK_SET;
int close(int);
scalar_t__ errno;
int getpid();
int lock_reg(int, int /*<<< orphan*/, int /*<<< orphan*/, int,
             int /*<<< orphan*/, int);
int open(char const *, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, ...);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int write(int, char *, int);
void do_lock(const char *filename) {
  int fd;
  char ch = 'z';
  if ((fd = open(filename, O_RDONLY, NULL)) < 0) {
    Perror("open error");
  }
  if (lock_reg((fd), F_SETLK, F_RDLCK, (0), (SEEK_SET), (1)) == -1) {
    Perror("read_lock error");
  } else {
    printf("Process %d set read_lock successfully\n", getpid());
  }
  if (read(fd, &ch, 1) != 1) {
    Perror("read error");
  } else {
    printf("Process %d read %c from file\n", getpid(), ch);
  }
  if (close(fd) == -1) {
    Perror("close error");
  }
  ch = 'z';
  if ((fd = open(filename, O_WRONLY, NULL)) < 0) {
    Perror("open error");
  }
  do {
    if (lock_reg((fd), F_SETLK, F_WRLCK, (1), (SEEK_SET), (1)) == -1) {
      if (errno != EAGAIN) {
        Perror("write_lock error");
      }
    } else {
      printf("Process %d set write_lock successfully\n", getpid());
      break;
    }
  } while (1);
  if (write(fd, &ch, 1) != 1) {
    Perror("write error");
  }
  sleep(2);
  if (lock_reg((fd), F_SETLK, F_UNLCK, (1), (SEEK_SET), (1)) == -1) {
    Perror("un_lock error");
  } else {
    printf("Process %d unlock successfully\n", getpid());
  }
  if (close(fd) == -1) {
    Perror("close error");
  }
}


x86 assembly (clang, -O0):
<do_lock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x7a,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1090 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11ce <do_lock+0x3e>
lea    0xe37(%rip),%rdi
call   10b0 <Perror@plt>
mov    -0xc(%rbp),%edi
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
mov    0x2db7(%rip),%rax
mov    (%rax),%edx
mov    0x2dd6(%rip),%rax
mov    (%rax),%r8d
xor    %ecx,%ecx
mov    $0x1,%r9d
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
jne    1214 <do_lock+0x84>
lea    0xe01(%rip),%rdi
call   10b0 <Perror@plt>
jmp    122b <do_lock+0x9b>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
je     1256 <do_lock+0xc6>
lea    0xdf6(%rip),%rdi
call   10b0 <Perror@plt>
jmp    1271 <do_lock+0xe1>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
movsbl -0xd(%rbp),%edx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    128e <do_lock+0xfe>
lea    0xde2(%rip),%rdi
call   10b0 <Perror@plt>
movb   $0x7a,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1090 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    12c0 <do_lock+0x130>
lea    0xd45(%rip),%rdi
call   10b0 <Perror@plt>
jmp    12c5 <do_lock+0x135>
mov    -0xc(%rbp),%edi
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
mov    0x2ce0(%rip),%rax
mov    (%rax),%edx
mov    0x2cdf(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
jne    1326 <do_lock+0x196>
mov    0x2cc6(%rip),%rax
mov    (%rax),%rax
mov    0x2c94(%rip),%rcx
cmp    (%rcx),%rax
je     1321 <do_lock+0x191>
lea    0xd5b(%rip),%rdi
call   10b0 <Perror@plt>
jmp    1342 <do_lock+0x1b2>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1356 <do_lock+0x1c6>
jmp    1347 <do_lock+0x1b7>
mov    $0x1,%al
test   $0x1,%al
jne    12c5 <do_lock+0x135>
jmp    1356 <do_lock+0x1c6>
mov    -0xc(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     137c <do_lock+0x1ec>
lea    0xd39(%rip),%rdi
call   10b0 <Perror@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    -0xc(%rbp),%edi
mov    0x2c50(%rip),%rax
mov    (%rax),%esi
mov    0x2c3f(%rip),%rax
mov    (%rax),%edx
mov    0x2c1e(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
jne    13cd <do_lock+0x23d>
lea    0xcf9(%rip),%rdi
call   10b0 <Perror@plt>
jmp    13e4 <do_lock+0x254>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1401 <do_lock+0x271>
lea    0xc6f(%rip),%rdi
call   10b0 <Perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_lock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
movb   $0x7a,0x7(%rsp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11c5 <do_lock+0x35>
lea    0xe40(%rip),%rdi
call   10b0 <Perror@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
mov    0x2de2(%rip),%r15
mov    (%r15),%r8d
mov    %ebp,%edi
xor    %ecx,%ecx
mov    $0x1,%r9d
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
je     120e <do_lock+0x7e>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe18(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    121a <do_lock+0x8a>
lea    0xdf6(%rip),%rdi
call   10b0 <Perror@plt>
lea    0x7(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
jne    124e <do_lock+0xbe>
xor    %eax,%eax
call   1040 <getpid@plt>
movsbl 0x7(%rsp),%edx
lea    0xe0a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    125a <do_lock+0xca>
lea    0xded(%rip),%rdi
call   10b0 <Perror@plt>
mov    %ebp,%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
jne    1272 <do_lock+0xe2>
lea    0xdfe(%rip),%rdi
call   10b0 <Perror@plt>
movb   $0x7a,0x7(%rsp)
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1090 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    129c <do_lock+0x10c>
lea    0xd69(%rip),%rdi
call   10b0 <Perror@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
mov    0x2d0c(%rip),%r13
mov    0x0(%r13),%edx
mov    (%r15),%r8d
mov    %ebx,%edi
mov    $0x1,%ecx
mov    $0x1,%r9d
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
je     1356 <do_lock+0x1c6>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdac(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     1307 <do_lock+0x177>
lea    0xdae(%rip),%rdi
call   10b0 <Perror@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    0x2cb7(%rip),%rax
mov    (%rax),%edx
mov    (%r15),%r8d
mov    %ebx,%edi
mov    $0x1,%ecx
mov    $0x1,%r9d
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
je     13ae <do_lock+0x21e>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xd7f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13ba <do_lock+0x22a>
mov    0x2c6b(%rip),%rbp
mov    0x2c3c(%rip),%r14
lea    0xd0c(%rip),%r12
jmp    139b <do_lock+0x20b>
nopl   (%rax)
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
mov    0x0(%r13),%edx
mov    (%r15),%r8d
mov    %ebx,%edi
mov    $0x1,%ecx
mov    $0x1,%r9d
call   1050 <lock_reg@plt>
cmp    $0xffffffff,%eax
jne    12ce <do_lock+0x13e>
mov    0x0(%rbp),%rax
cmp    (%r14),%rax
je     1370 <do_lock+0x1e0>
mov    %r12,%rdi
call   10b0 <Perror@plt>
jmp    1370 <do_lock+0x1e0>
lea    0xd07(%rip),%rdi
call   10b0 <Perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
cmp    $0xffffffff,%eax
je     13d5 <do_lock+0x245>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc8f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <Perror@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [11 x i8] c"open error\00"
@F_SETLK = global i32 0
@F_RDLCK = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [16 x i8] c"read_lock error\00"
@.str.2 = [39 x i8] c"Process %d set read_lock successfully\0A\00"
@.str.3 = [11 x i8] c"read error\00"
@.str.4 = [30 x i8] c"Process %d read %c from file\0A\00"
@.str.5 = [12 x i8] c"close error\00"
@O_WRONLY = global i32 0
@F_WRLCK = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str.6 = [17 x i8] c"write_lock error\00"
@.str.7 = [40 x i8] c"Process %d set write_lock successfully\0A\00"
@.str.8 = [12 x i8] c"write error\00"
@F_UNLCK = global i32 0
@.str.9 = [14 x i8] c"un_lock error\00"
@.str.10 = [32 x i8] c"Process %d unlock successfully\0A\00"
define void @do_lock(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i8 122, i8* %4
%5 = load i8*, i8** %2
%6 = load i32, i32* @O_RDONLY
%7 = call i32 @open(i8* %5, i32 %6, i32* null)
store i32 %7, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = load i32, i32* %3
%13 = load i32, i32* @F_SETLK
%14 = load i32, i32* @F_RDLCK
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @lock_reg(i32 %12, i32 %13, i32 %14, i32 0, i32 %15, i32 1)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @Perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %23
20: ; preds = %11
%21 = call i32 (...) @getpid()
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %18
%24 = load i32, i32* %3
%25 = call i32 @read(i32 %24, i8* %4, i32 1)
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %34
29: ; preds = %23
%30 = call i32 (...) @getpid()
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %32)
br label %34
34: ; preds = %29, %27
%35 = load i32, i32* %3
%36 = call i32 @close(i32 %35)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
store i8 122, i8* %4
%41 = load i8*, i8** %2
%42 = load i32, i32* @O_WRONLY
%43 = call i32 @open(i8* %41, i32 %42, i32* null)
store i32 %43, i32* %3
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %47
47: ; preds = %45, %40
br label %48
48: ; preds = %66, %47
%49 = load i32, i32* %3
%50 = load i32, i32* @F_SETLK
%51 = load i32, i32* @F_WRLCK
%52 = load i32, i32* @SEEK_SET
%53 = call i32 @lock_reg(i32 %49, i32 %50, i32 %51, i32 1, i32 %52, i32 1)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %62
55: ; preds = %48
%56 = load i64, i64* @errno
%57 = load i64, i64* @EAGAIN
%58 = icmp ne i64 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @Perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
br label %65
62: ; preds = %48
%63 = call i32 (...) @getpid()
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %63)
br label %67
65: ; preds = %61
br label %66
66: ; preds = %65
br i1 true, label %48, label %67
67: ; preds = %66, %62
%68 = load i32, i32* %3
%69 = call i32 @write(i32 %68, i8* %4, i32 1)
%70 = icmp ne i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
br label %73
73: ; preds = %71, %67
%74 = call i32 @sleep(i32 2)
%75 = load i32, i32* %3
%76 = load i32, i32* @F_SETLK
%77 = load i32, i32* @F_UNLCK
%78 = load i32, i32* @SEEK_SET
%79 = call i32 @lock_reg(i32 %75, i32 %76, i32 %77, i32 1, i32 %78, i32 1)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %73
%82 = call i32 @Perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %86
83: ; preds = %73
%84 = call i32 (...) @getpid()
%85 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %83, %81
%87 = load i32, i32* %3
%88 = call i32 @close(i32 %87)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %86
ret void
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [11 x i8] c"open error\00"
@F_SETLK = global i32 0
@F_RDLCK = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [16 x i8] c"read_lock error\00"
@.str.2 = [39 x i8] c"Process %d set read_lock successfully\0A\00"
@.str.3 = [11 x i8] c"read error\00"
@.str.4 = [30 x i8] c"Process %d read %c from file\0A\00"
@.str.5 = [12 x i8] c"close error\00"
@O_WRONLY = global i32 0
@F_WRLCK = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str.6 = [17 x i8] c"write_lock error\00"
@.str.7 = [40 x i8] c"Process %d set write_lock successfully\0A\00"
@.str.8 = [12 x i8] c"write error\00"
@F_UNLCK = global i32 0
@.str.9 = [14 x i8] c"un_lock error\00"
@.str.10 = [32 x i8] c"Process %d unlock successfully\0A\00"
define void @do_lock(i8* nocapture %0) {
%2 = alloca i8
store i8 122, i8* %2
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* %0, i32 %3, i32* null)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* @F_SETLK
%10 = load i32, i32* @F_RDLCK
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @lock_reg(i32 %4, i32 %9, i32 %10, i32 0, i32 %11, i32 1)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @Perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %19
16: ; preds = %8
%17 = tail call i32 (...) @getpid()
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14
%20 = call i32 @read(i32 %4, i8* %2, i32 1)
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %29
24: ; preds = %19
%25 = tail call i32 (...) @getpid()
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %27)
br label %29
29: ; preds = %24, %22
%30 = tail call i32 @close(i32 %4)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = tail call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
store i8 122, i8* %2
%35 = load i32, i32* @O_WRONLY
%36 = tail call i32 @open(i8* %0, i32 %35, i32* null)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = tail call i32 @Perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i32, i32* @F_SETLK
%42 = load i32, i32* @F_WRLCK
%43 = load i32, i32* @SEEK_SET
%44 = tail call i32 @lock_reg(i32 %36, i32 %41, i32 %42, i32 1, i32 %43, i32 1)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %52
46: ; preds = %40, %57
%47 = load i64, i64* @errno
%48 = load i64, i64* @EAGAIN
%49 = icmp eq i64 %47, %48
br i1 %49, label %57, label %50
50: ; preds = %46
%51 = tail call i32 @Perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %57
52: ; preds = %57, %40
%53 = tail call i32 (...) @getpid()
%54 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = call i32 @write(i32 %36, i8* %2, i32 1)
%56 = icmp eq i32 %55, 1
br i1 %56, label %65, label %63
57: ; preds = %50, %46
%58 = load i32, i32* @F_SETLK
%59 = load i32, i32* @F_WRLCK
%60 = load i32, i32* @SEEK_SET
%61 = tail call i32 @lock_reg(i32 %36, i32 %58, i32 %59, i32 1, i32 %60, i32 1)
%62 = icmp eq i32 %61, -1
br i1 %62, label %46, label %52
63: ; preds = %52
%64 = tail call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
br label %65
65: ; preds = %63, %52
%66 = tail call i32 @sleep(i32 2)
%67 = load i32, i32* @F_SETLK
%68 = load i32, i32* @F_UNLCK
%69 = load i32, i32* @SEEK_SET
%70 = tail call i32 @lock_reg(i32 %36, i32 %67, i32 %68, i32 1, i32 %69, i32 1)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %74
72: ; preds = %65
%73 = tail call i32 @Perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %77
74: ; preds = %65
%75 = tail call i32 (...) @getpid()
%76 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74, %72
%78 = tail call i32 @close(i32 %36)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = tail call i32 @Perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
ret void
}