#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ F_RDLCK;
int /*<<< orphan*/ F_UNLCK;
int /*<<< orphan*/ F_WRLCK;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
scalar_t__ setLock(int, int /*<<< orphan*/);
main(int argc, char **argv) {
  int fd;
  char buffer[86];
  if ((fd = open("dummy_file.txt", O_RDWR)) < 0) {
    perror("open");
    exit(EXIT_FAILURE);
  }
  if (setLock(fd, F_RDLCK) == 0) {
    printf("Read lock has been acquired, as expected.\n\nHit ENTER... ");
    getchar();
  } else {
    printf("Unable to set read lock.  Program is terminating.\n");
    close(fd);
    exit(EXIT_FAILURE);
  }
  if (setLock(fd, F_UNLCK) == 0)
    printf("Read lock has been released\n\n");
  else {
    printf("Unable to release read lock.  Program is terminating.\n");
    close(fd);
    exit(EXIT_FAILURE);
  }
  if (setLock(fd, F_WRLCK) == 0) {
    printf("Acquired a write lock--this shouldn't happen! Program is "
           "terminating.\n");
    setLock(fd, F_UNLCK);
    close(fd);
    exit(EXIT_FAILURE);
  }
  printf("Failed to acquire the write lock, as expected.\n\n");
  printf("Go hit ENTER in the locker terminal to let it switch to\n");
  printf("a write lock, then come back here and hit ENTER.\n");
  getchar();
  if (setLock(fd, F_RDLCK) == 0) {
    printf("Acquired a read lock--this shouldn't happen! Program is "
           "terminating.\n");
    setLock(fd, F_UNLCK);
    close(fd);
    exit(EXIT_FAILURE);
  }
  printf("Failed to acquire the write lock, as expected.\n\n");
  printf("Hit ENTER and we'll try to read the file.  This call should\n");
  printf("block and hang this program until locker releases its lock\n");
  printf("on the file.  Once this program hangs, go hit ENTER in the\n");
  printf("locker terminal.\n");
  getchar();
  printf("Attempting to read file... \n\n");
  if (read(fd, buffer, 86) == 86) {
    printf("Successfully read from the file.\n");
    buffer[86 - 1] = '\0';
    printf("Data read: \"%s\"\n", buffer);
  } else
    printf("Could not read from the file.\n");
  close(fd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
lea    0xe5a(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11d1 <main+0x51>
lea    0xe51(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
cmp    $0x0,%rax
jne    1206 <main+0x86>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    122a <main+0xaa>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2dac(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
cmp    $0x0,%rax
jne    1258 <main+0xd8>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127c <main+0xfc>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
cmp    $0x0,%rax
jne    12cc <main+0x14c>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x14(%rbp),%edi
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
cmp    $0x0,%rax
jne    134d <main+0x1cd>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
call   1090 <setLock@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x56,%edx
call   1050 <read@plt>
cmp    $0x56,%eax
jne    13eb <main+0x26b>
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x1b(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f9 <main+0x279>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2bb8(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    0xe57(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     1311 <main+0x181>
mov    %eax,%ebx
mov    0x2df1(%rip),%r14
mov    (%r14),%esi
mov    %eax,%edi
call   10a0 <setLock@plt>
test   %rax,%rax
jne    131f <main+0x18f>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2df2(%rip),%r15
mov    (%r15),%esi
mov    %ebx,%edi
call   10a0 <setLock@plt>
test   %rax,%rax
jne    1328 <main+0x198>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10a0 <setLock@plt>
test   %rax,%rax
je     1336 <main+0x1a6>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    (%r14),%esi
mov    %ebx,%edi
call   10a0 <setLock@plt>
test   %rax,%rax
je     133f <main+0x1af>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xf64(%rip),%rdi
call   1030 <puts@plt>
lea    0xf93(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xf91(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x56,%edx
call   1060 <read@plt>
cmp    $0x56,%eax
jne    12eb <main+0x15b>
lea    0xfac(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0x55(%rsp)
lea    0xd6e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12f7 <main+0x167>
lea    0xf6a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xcf7(%rip),%rdi
call   1090 <perror@plt>
jmp    135c <main+0x1cc>
lea    0xd38(%rip),%rdi
jmp    132f <main+0x19f>
lea    0xd61(%rip),%rdi
call   1030 <puts@plt>
jmp    1355 <main+0x1c5>
lea    0xfa3(%rip),%rdi
jmp    1346 <main+0x1b6>
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%esi
mov    %ebx,%edi
call   10a0 <setLock@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"dummy_file.txt\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@F_RDLCK = global i32 0
@.str.2 = [57 x i8] c"Read lock has been acquired, as expected.\0A\0AHit ENTER... \00"
@.str.3 = [51 x i8] c"Unable to set read lock. Program is terminating.\0A\00"
@F_UNLCK = global i32 0
@.str.4 = [30 x i8] c"Read lock has been released\0A\0A\00"
@.str.5 = [55 x i8] c"Unable to release read lock. Program is terminating.\0A\00"
@F_WRLCK = global i32 0
@.str.6 = [71 x i8] c"Acquired a write lock--this shouldn't happen! Program is terminating.\0A\00"
@.str.7 = [49 x i8] c"Failed to acquire the write lock, as expected.\0A\0A\00"
@.str.8 = [57 x i8] c"Go hit ENTER in the locker terminal to let it switch to\0A\00"
@.str.9 = [50 x i8] c"a write lock, then come back here and hit ENTER.\0A\00"
@.str.10 = [70 x i8] c"Acquired a read lock--this shouldn't happen! Program is terminating.\0A\00"
@.str.11 = [61 x i8] c"Hit ENTER and we'll try to read the file. This call should\0A\00"
@.str.12 = [60 x i8] c"block and hang this program until locker releases its lock\0A\00"
@.str.13 = [60 x i8] c"on the file. Once this program hangs, go hit ENTER in the\0A\00"
@.str.14 = [18 x i8] c"locker terminal.\0A\00"
@.str.15 = [30 x i8] c"Attempting to read file... \0A\0A\00"
@.str.16 = [34 x i8] c"Successfully read from the file.\0A\00"
@.str.17 = [17 x i8] c"Data read: \22%s\22\0A\00"
@.str.18 = [31 x i8] c"Could not read from the file.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [86 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i32, i32* @F_RDLCK
%18 = call i64 @setLock(i32 %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (...) @getchar()
br label %29
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* %6
%26 = call i32 @close(i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %20
%30 = load i32, i32* %6
%31 = load i32, i32* @F_UNLCK
%32 = call i64 @setLock(i32 %30, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %42
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32, i32* %6
%39 = call i32 @close(i32 %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %34
%43 = load i32, i32* %6
%44 = load i32, i32* @F_WRLCK
%45 = call i64 @setLock(i32 %43, i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %56
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.6, i64 0, i64 0))
%49 = load i32, i32* %6
%50 = load i32, i32* @F_UNLCK
%51 = call i64 @setLock(i32 %49, i32 %50)
%52 = load i32, i32* %6
%53 = call i32 @close(i32 %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %42
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.8, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0))
%60 = call i32 (...) @getchar()
%61 = load i32, i32* %6
%62 = load i32, i32* @F_RDLCK
%63 = call i64 @setLock(i32 %61, i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %56
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.10, i64 0, i64 0))
%67 = load i32, i32* %6
%68 = load i32, i32* @F_UNLCK
%69 = call i64 @setLock(i32 %67, i32 %68)
%70 = load i32, i32* %6
%71 = call i32 @close(i32 %70)
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %56
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.11, i64 0, i64 0))
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.12, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.13, i64 0, i64 0))
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
%80 = call i32 (...) @getchar()
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.15, i64 0, i64 0))
%82 = load i32, i32* %6
%83 = getelementptr inbounds [86 x i8], [86 x i8]* %7, i64 0, i64 0
%84 = call i32 @read(i32 %82, i8* %83, i32 86)
%85 = icmp eq i32 %84, 86
br i1 %85, label %86, label %91
86: ; preds = %74
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.16, i64 0, i64 0))
%88 = getelementptr inbounds [86 x i8], [86 x i8]* %7, i64 0, i64 85
store i8 0, i8* %88
%89 = getelementptr inbounds [86 x i8], [86 x i8]* %7, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8* %89)
br label %93
91: ; preds = %74
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0))
br label %93
93: ; preds = %91, %86
%94 = load i32, i32* %6
%95 = call i32 @close(i32 %94)
%96 = load i32, i32* @EXIT_SUCCESS
ret i32 %96
}

LLVM IR (-O2):
@.str = [15 x i8] c"dummy_file.txt\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@F_RDLCK = global i32 0
@.str.2 = [57 x i8] c"Read lock has been acquired, as expected.\0A\0AHit ENTER... \00"
@F_UNLCK = global i32 0
@F_WRLCK = global i32 0
@.str.17 = [17 x i8] c"Data read: \22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [50 x i8] c"Unable to set read lock. Program is terminating.\00"
@str.19 = [54 x i8] c"Unable to release read lock. Program is terminating.\00"
@str.20 = [29 x i8] c"Read lock has been released\0A\00"
@str.22 = [56 x i8] c"Go hit ENTER in the locker terminal to let it switch to\00"
@str.23 = [49 x i8] c"a write lock, then come back here and hit ENTER.\00"
@str.24 = [48 x i8] c"Failed to acquire the write lock, as expected.\0A\00"
@str.25 = [60 x i8] c"Hit ENTER and we'll try to read the file. This call should\00"
@str.26 = [59 x i8] c"block and hang this program until locker releases its lock\00"
@str.27 = [59 x i8] c"on the file. Once this program hangs, go hit ENTER in the\00"
@str.28 = [17 x i8] c"locker terminal.\00"
@str.29 = [29 x i8] c"Attempting to read file... \0A\00"
@str.30 = [30 x i8] c"Could not read from the file.\00"
@str.31 = [33 x i8] c"Successfully read from the file.\00"
@str.32 = [69 x i8] c"Acquired a read lock--this shouldn't happen! Program is terminating.\00"
@str.33 = [70 x i8] c"Acquired a write lock--this shouldn't happen! Program is terminating.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [86 x i8]
%4 = getelementptr inbounds [86 x i8], [86 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDWR
%6 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = load i32, i32* @F_RDLCK
%14 = tail call i64 @setLock(i32 %6, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 (...) @getchar()
%19 = load i32, i32* @F_UNLCK
%20 = tail call i64 @setLock(i32 %6, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %32
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @close(i32 %6)
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @exit(i32 %25)
unreachable
27: ; preds = %16
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.20, i64 0, i64 0))
%29 = load i32, i32* @F_WRLCK
%30 = tail call i64 @setLock(i32 %6, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %44
32: ; preds = %16
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.19, i64 0, i64 0))
%34 = tail call i32 @close(i32 %6)
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %27
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.33, i64 0, i64 0))
%39 = load i32, i32* @F_UNLCK
%40 = tail call i64 @setLock(i32 %6, i32 %39)
%41 = tail call i32 @close(i32 %6)
%42 = load i32, i32* @EXIT_FAILURE
%43 = tail call i32 @exit(i32 %42)
unreachable
44: ; preds = %27
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.24, i64 0, i64 0))
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.22, i64 0, i64 0))
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.23, i64 0, i64 0))
%48 = tail call i32 (...) @getchar()
%49 = load i32, i32* @F_RDLCK
%50 = tail call i64 @setLock(i32 %6, i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %44
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.32, i64 0, i64 0))
%54 = load i32, i32* @F_UNLCK
%55 = tail call i64 @setLock(i32 %6, i32 %54)
%56 = tail call i32 @close(i32 %6)
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %44
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.24, i64 0, i64 0))
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.25, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.26, i64 0, i64 0))
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.27, i64 0, i64 0))
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.28, i64 0, i64 0))
%65 = tail call i32 (...) @getchar()
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.29, i64 0, i64 0))
%67 = call i32 @read(i32 %6, i8* %4, i32 86)
%68 = icmp eq i32 %67, 86
br i1 %68, label %69, label %73
69: ; preds = %59
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.31, i64 0, i64 0))
%71 = getelementptr inbounds [86 x i8], [86 x i8]* %3, i64 0, i64 85
store i8 0, i8* %71
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8* %4)
br label %75
73: ; preds = %59
%74 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.30, i64 0, i64 0))
br label %75
75: ; preds = %73, %69
%76 = call i32 @close(i32 %6)
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}