#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 {
  void *l_type;
  scalar_t__ l_len;
  scalar_t__ l_start;
  int /*<<< orphan*/ l_whence;
};
typedef long ssize_t;
typedef scalar_t__ off_t;

/* Variables and functions */
void *F_RDLCK;
int /*<<< orphan*/ F_SETLKW;
void *F_UNLCK;
void *F_WRLCK;
int /*<<< orphan*/ SEEK_SET;
int fcntl(int, int /*<<< orphan*/, struct flock *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ lseek(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ printoffset(int, scalar_t__, scalar_t__);
long read(int, char *, size_t);
int readoffset(int, scalar_t__ *, scalar_t__ *);
int /*<<< orphan*/ stderr;
int readlocked(int fd, int fdadm, char *buffer, size_t size, off_t *off) {
  ssize_t wres = -1;
  long i;
  off_t sres;
  off_t offset;
  off_t newoffset;
  int fres;
  struct flock flock;
  char rbuffer[25];
  char *endnum;
  int res;
  flock.l_whence = SEEK_SET;
  flock.l_start = 0;
  flock.l_len = 0;
  flock.l_type = F_WRLCK;
  fres = fcntl(fdadm, F_SETLKW, &flock);
  if (fres < 0)
    goto RETURN;
  flock.l_type = F_RDLCK;
  fres = fcntl(fd, F_SETLKW, &flock);
  if (fres < 0)
    goto RETURN;
  sres = lseek(fdadm, 0, SEEK_SET);
  if (sres < 0)
    goto RETURN;
  res = readoffset(fdadm, &offset, &newoffset);
  if (res < 0)
    goto RETURN;
  if (newoffset != 0) {
    wres = 0;
    goto RETURN;
  }
  sres = lseek(fd, offset, SEEK_SET);
  if (sres < 0) {
    fprintf(stderr, "lseek error: %s\n", rbuffer);
    wres = -1;
    goto RETURN;
  }
  wres = read(fd, buffer, size);
  if (wres <= 0)
    goto RETURN;
  endnum = NULL;
  for (i = 0; i < wres; ++i) {
    if (buffer[i] == '\n') {
      endnum = buffer + i;
      break;
    }
  }
  if (endnum == NULL) {
    endnum = buffer + wres;
  } else {
    wres = (endnum - buffer) + 1;
  }
  *off = offset;
  offset += wres;
RETURN:
  flock.l_type = F_UNLCK;
  fcntl(fd, F_SETLKW, &flock);
  if (wres > 0) {
    printoffset(fdadm, *off, offset);
  }
  flock.l_type = F_UNLCK;
  fcntl(fdadm, F_SETLKW, &flock);
  return wres;
}


x86 assembly (clang, -O0):
<readlocked>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
lea    -0x70(%rbp),%rdx
call   1030 <fcntl@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    11d6 <readlocked+0x76>
jmp    1394 <readlocked+0x234>
mov    0x2dd3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    -0x70(%rbp),%rdx
call   1030 <fcntl@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    120b <readlocked+0xab>
jmp    1394 <readlocked+0x234>
mov    -0x8(%rbp),%edi
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <lseek@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jge    1234 <readlocked+0xd4>
jmp    1394 <readlocked+0x234>
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1070 <readoffset@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
jge    125c <readlocked+0xfc>
jmp    1394 <readlocked+0x234>
cmpq   $0x0,-0x48(%rbp)
je     1274 <readlocked+0x114>
movq   $0x0,-0x28(%rbp)
jmp    1394 <readlocked+0x234>
mov    -0x4(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jge    12c1 <readlocked+0x161>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xd51(%rip),%rsi
call   1060 <fprintf@plt>
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
jmp    1394 <readlocked+0x234>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <read@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jg     12e5 <readlocked+0x185>
jmp    1394 <readlocked+0x234>
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    1345 <readlocked+0x1e5>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    132f <readlocked+0x1cf>
mov    -0x10(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    1345 <readlocked+0x1e5>
jmp    1334 <readlocked+0x1d4>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12f8 <readlocked+0x198>
cmpq   $0x0,-0x98(%rbp)
jne    1367 <readlocked+0x207>
mov    -0x10(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    137d <readlocked+0x21d>
mov    -0x98(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c45(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2c3c(%rip),%rax
mov    (%rax),%esi
lea    -0x70(%rbp),%rdx
call   1030 <fcntl@plt>
cmpq   $0x0,-0x28(%rbp)
jle    13d5 <readlocked+0x275>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x40(%rbp),%rdx
call   1080 <printoffset@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bfb(%rip),%rax
mov    (%rax),%esi
lea    -0x70(%rbp),%rdx
call   1030 <fcntl@plt>
mov    -0x28(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readlocked>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,0x8(%rsp)
mov    %rcx,0x30(%rsp)
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %edi,%r15d
mov    0x2e40(%rip),%r13
mov    0x0(%r13),%eax
mov    %eax,0x28(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
mov    0x2e21(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    0x2e3a(%rip),%r14
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
call   1030 <fcntl@plt>
mov    $0xffffffffffffffff,%rbp
test   %eax,%eax
js     121d <readlocked+0xbd>
mov    0x2de0(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
call   1030 <fcntl@plt>
test   %eax,%eax
js     121d <readlocked+0xbd>
mov    0x0(%r13),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
test   %rax,%rax
js     121d <readlocked+0xbd>
mov    %rsp,%rsi
lea    0x38(%rsp),%rdx
mov    %r12d,%edi
call   1070 <readoffset@plt>
test   %eax,%eax
js     121d <readlocked+0xbd>
cmpq   $0x0,0x38(%rsp)
je     127e <readlocked+0x11e>
xor    %ebp,%ebp
mov    0x2dbc(%rip),%rbx
mov    (%rbx),%rax
mov    %rax,0x10(%rsp)
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
call   1030 <fcntl@plt>
test   %rbp,%rbp
jle    1255 <readlocked+0xf5>
mov    0x8(%rsp),%rax
mov    (%rax),%rsi
mov    (%rsp),%rdx
mov    %r12d,%edi
call   1080 <printoffset@plt>
mov    (%rbx),%rax
mov    %rax,0x10(%rsp)
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
call   1030 <fcntl@plt>
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rsi
mov    0x0(%r13),%edx
mov    %r15d,%edi
call   1040 <lseek@plt>
test   %rax,%rax
js     12c1 <readlocked+0x161>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    0x30(%rsp),%rdx
call   1050 <read@plt>
test   %rax,%rax
jle    12e0 <readlocked+0x180>
xor    %ecx,%ecx
xor    %edx,%edx
nopl   0x0(%rax)
cmpb   $0xa,(%rbx,%rdx,1)
je     12e8 <readlocked+0x188>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    12b0 <readlocked+0x150>
jmp    12ee <readlocked+0x18e>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
lea    0xd2f(%rip),%rsi
lea    0x40(%rsp),%rdx
call   1060 <fprintf@plt>
jmp    121d <readlocked+0xbd>
mov    %rax,%rbp
jmp    121d <readlocked+0xbd>
add    %rbx,%rdx
mov    %rdx,%rcx
mov    %rcx,%rbp
sub    %rbx,%rbp
add    $0x1,%rbp
test   %rcx,%rcx
cmove  %rax,%rbp
mov    (%rsp),%rax
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
add    %rbp,%rax
mov    %rax,(%rsp)
jmp    121d <readlocked+0xbd>

LLVM IR (-O0):
%struct.flock = type { i8*, i64, i64, i32 }
@SEEK_SET = global i32 0
@F_WRLCK = global i8* null
@F_SETLKW = global i32 0
@F_RDLCK = global i8* null
@stderr = global i32 0
@.str = [17 x i8] c"lseek error: %s\0A\00"
@F_UNLCK = global i8* null
define i32 @readlocked(i32 %0, i32 %1, i8* %2, i64 %3, i64* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca %struct.flock
%18 = alloca [25 x i8]
%19 = alloca i8*
%20 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i64* %4, i64** %10
store i64 -1, i64* %11
%21 = load i32, i32* @SEEK_SET
%22 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 3
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 2
store i64 0, i64* %23
%24 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 1
store i64 0, i64* %24
%25 = load i8*, i8** @F_WRLCK
%26 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 0
store i8* %25, i8** %26
%27 = load i32, i32* %7
%28 = load i32, i32* @F_SETLKW
%29 = call i32 @fcntl(i32 %27, i32 %28, %struct.flock* %17)
store i32 %29, i32* %16
%30 = load i32, i32* %16
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %5
br label %118
33: ; preds = %5
%34 = load i8*, i8** @F_RDLCK
%35 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 0
store i8* %34, i8** %35
%36 = load i32, i32* %6
%37 = load i32, i32* @F_SETLKW
%38 = call i32 @fcntl(i32 %36, i32 %37, %struct.flock* %17)
store i32 %38, i32* %16
%39 = load i32, i32* %16
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33
br label %118
42: ; preds = %33
%43 = load i32, i32* %7
%44 = load i32, i32* @SEEK_SET
%45 = call i64 @lseek(i32 %43, i64 0, i32 %44)
store i64 %45, i64* %13
%46 = load i64, i64* %13
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %42
br label %118
49: ; preds = %42
%50 = load i32, i32* %7
%51 = call i32 @readoffset(i32 %50, i64* %14, i64* %15)
store i32 %51, i32* %20
%52 = load i32, i32* %20
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %49
br label %118
55: ; preds = %49
%56 = load i64, i64* %15
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %55
store i64 0, i64* %11
br label %118
59: ; preds = %55
%60 = load i32, i32* %6
%61 = load i64, i64* %14
%62 = load i32, i32* @SEEK_SET
%63 = call i64 @lseek(i32 %60, i64 %61, i32 %62)
store i64 %63, i64* %13
%64 = load i64, i64* %13
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %59
%67 = load i32, i32* @stderr
%68 = getelementptr inbounds [25 x i8], [25 x i8]* %18, i64 0, i64 0
%69 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %68)
store i64 -1, i64* %11
br label %118
70: ; preds = %59
%71 = load i32, i32* %6
%72 = load i8*, i8** %8
%73 = load i64, i64* %9
%74 = call i64 @read(i32 %71, i8* %72, i64 %73)
store i64 %74, i64* %11
%75 = load i64, i64* %11
%76 = icmp sle i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %70
br label %118
78: ; preds = %70
store i8* null, i8** %19
store i64 0, i64* %12
br label %79
79: ; preds = %95, %78
%80 = load i64, i64* %12
%81 = load i64, i64* %11
%82 = icmp slt i64 %80, %81
br i1 %82, label %83, label %98
83: ; preds = %79
%84 = load i8*, i8** %8
%85 = load i64, i64* %12
%86 = getelementptr inbounds i8, i8* %84, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 10
br i1 %89, label %90, label %94
90: ; preds = %83
%91 = load i8*, i8** %8
%92 = load i64, i64* %12
%93 = getelementptr inbounds i8, i8* %91, i64 %92
store i8* %93, i8** %19
br label %98
94: ; preds = %83
br label %95
95: ; preds = %94
%96 = load i64, i64* %12
%97 = add nsw i64 %96, 1
store i64 %97, i64* %12
br label %79
98: ; preds = %90, %79
%99 = load i8*, i8** %19
%100 = icmp eq i8* %99, null
br i1 %100, label %101, label %105
101: ; preds = %98
%102 = load i8*, i8** %8
%103 = load i64, i64* %11
%104 = getelementptr inbounds i8, i8* %102, i64 %103
store i8* %104, i8** %19
br label %112
105: ; preds = %98
%106 = load i8*, i8** %19
%107 = load i8*, i8** %8
%108 = ptrtoint i8* %106 to i64
%109 = ptrtoint i8* %107 to i64
%110 = sub i64 %108, %109
%111 = add nsw i64 %110, 1
store i64 %111, i64* %11
br label %112
112: ; preds = %105, %101
%113 = load i64, i64* %14
%114 = load i64*, i64** %10
store i64 %113, i64* %114
%115 = load i64, i64* %11
%116 = load i64, i64* %14
%117 = add nsw i64 %116, %115
store i64 %117, i64* %14
br label %118
118: ; preds = %112, %77, %66, %58, %54, %48, %41, %32
%119 = load i8*, i8** @F_UNLCK
%120 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 0
store i8* %119, i8** %120
%121 = load i32, i32* %6
%122 = load i32, i32* @F_SETLKW
%123 = call i32 @fcntl(i32 %121, i32 %122, %struct.flock* %17)
%124 = load i64, i64* %11
%125 = icmp sgt i64 %124, 0
br i1 %125, label %126, label %132
126: ; preds = %118
%127 = load i32, i32* %7
%128 = load i64*, i64** %10
%129 = load i64, i64* %128
%130 = load i64, i64* %14
%131 = call i32 @printoffset(i32 %127, i64 %129, i64 %130)
br label %132
132: ; preds = %126, %118
%133 = load i8*, i8** @F_UNLCK
%134 = getelementptr inbounds %struct.flock, %struct.flock* %17, i32 0, i32 0
store i8* %133, i8** %134
%135 = load i32, i32* %7
%136 = load i32, i32* @F_SETLKW
%137 = call i32 @fcntl(i32 %135, i32 %136, %struct.flock* %17)
%138 = load i64, i64* %11
%139 = trunc i64 %138 to i32
ret i32 %139
}

LLVM IR (-O2):
%struct.flock = type { i8*, i64, i64, i32 }
@SEEK_SET = global i32 0
@F_WRLCK = global i8* null
@F_SETLKW = global i32 0
@F_RDLCK = global i8* null
@stderr = global i32 0
@.str = [17 x i8] c"lseek error: %s\0A\00"
@F_UNLCK = global i8* null
define i32 @readlocked(i32 %0, i32 %1, i8* %2, i64 %3, i64* nocapture %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca %struct.flock
%9 = alloca [25 x i8]
%10 = bitcast i64* %6 to i8*
%11 = bitcast i64* %7 to i8*
%12 = bitcast %struct.flock* %8 to i8*
%13 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%14 = load i32, i32* @SEEK_SET
%15 = getelementptr inbounds %struct.flock, %struct.flock* %8, i64 0, i32 3
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.flock, %struct.flock* %8, i64 0, i32 1
%17 = bitcast i64* %16 to i8*
%18 = load i8*, i8** @F_WRLCK
%19 = getelementptr inbounds %struct.flock, %struct.flock* %8, i64 0, i32 0
store i8* %18, i8** %19
%20 = load i32, i32* @F_SETLKW
%21 = call i32 @fcntl(i32 %1, i32 %20, %struct.flock* %8)
%22 = icmp slt i32 %21, 0
br i1 %22, label %69, label %23
23: ; preds = %5
%24 = load i8*, i8** @F_RDLCK
store i8* %24, i8** %19
%25 = load i32, i32* @F_SETLKW
%26 = call i32 @fcntl(i32 %0, i32 %25, %struct.flock* %8)
%27 = icmp slt i32 %26, 0
br i1 %27, label %69, label %28
28: ; preds = %23
%29 = load i32, i32* @SEEK_SET
%30 = call i64 @lseek(i32 %1, i64 0, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %69, label %32
32: ; preds = %28
%33 = call i32 @readoffset(i32 %1, i64* %6, i64* %7)
%34 = icmp slt i32 %33, 0
br i1 %34, label %69, label %35
35: ; preds = %32
%36 = load i64, i64* %7
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %69
38: ; preds = %35
%39 = load i64, i64* %6
%40 = load i32, i32* @SEEK_SET
%41 = call i64 @lseek(i32 %0, i64 %39, i32 %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %69
46: ; preds = %38
%47 = call i64 @read(i32 %0, i8* %2, i64 %3)
%48 = icmp slt i64 %47, 1
br i1 %48, label %69, label %49
49: ; preds = %46, %54
%50 = phi i64 [ %55, %54 ], [ 0, %46 ]
%51 = getelementptr inbounds i8, i8* %2, i64 %50
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 10
br i1 %53, label %57, label %54
54: ; preds = %49
%55 = add nuw nsw i64 %50, 1
%56 = icmp eq i64 %55, %47
br i1 %56, label %59, label %49
57: ; preds = %49
%58 = getelementptr inbounds i8, i8* %2, i64 %50
br label %59
59: ; preds = %54, %57
%60 = phi i8* [ %58, %57 ], [ null, %54 ]
%61 = icmp eq i8* %60, null
%62 = ptrtoint i8* %60 to i64
%63 = ptrtoint i8* %2 to i64
%64 = sub i64 1, %63
%65 = add i64 %64, %62
%66 = select i1 %61, i64 %47, i64 %65
%67 = load i64, i64* %6
store i64 %67, i64* %4
%68 = add nsw i64 %66, %67
store i64 %68, i64* %6
br label %69
69: ; preds = %35, %46, %32, %28, %23, %5, %59, %43
%70 = phi i64 [ -1, %5 ], [ -1, %23 ], [ -1, %28 ], [ -1, %32 ], [ -1, %43 ], [ %47, %46 ], [ %66, %59 ], [ 0, %35 ]
%71 = load i8*, i8** @F_UNLCK
store i8* %71, i8** %19
%72 = load i32, i32* @F_SETLKW
%73 = call i32 @fcntl(i32 %0, i32 %72, %struct.flock* %8)
%74 = icmp sgt i64 %70, 0
br i1 %74, label %75, label %79
75: ; preds = %69
%76 = load i64, i64* %4
%77 = load i64, i64* %6
%78 = call i32 @printoffset(i32 %1, i64 %76, i64 %77)
br label %79
79: ; preds = %75, %69
%80 = load i8*, i8** @F_UNLCK
store i8* %80, i8** %19
%81 = load i32, i32* @F_SETLKW
%82 = call i32 @fcntl(i32 %1, i32 %81, %struct.flock* %8)
%83 = trunc i64 %70 to i32
ret i32 %83
}