#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 loop_info64 {
  int lo_offset;
  int lo_flags;
  scalar_t__ lo_file_name;
  int /*<<< orphan*/ member_0;
};
typedef int /*<<< orphan*/ lo64;

/* Variables and functions */
scalar_t__ EROFS;
int /*<<< orphan*/ LOOP_CLR_FD;
int /*<<< orphan*/ LOOP_GET_STATUS64;
int /*<<< orphan*/ LOOP_SET_FD;
int /*<<< orphan*/ LOOP_SET_STATUS64;
int /*<<< orphan*/ LO_NAME_SIZE;
int O_EXCL;
int O_RDONLY;
int O_RDWR;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(struct loop_info64 *, int /*<<< orphan*/, int);
int open(char const *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int /*<<< orphan*/);
int crypt_loop_attach(const char *loop, const char *file, int offset,
                      int autoclear, int *readonly) {
  struct loop_info64 lo64 = {0};
  int loop_fd = -1, file_fd = -1, r = 1;
  file_fd = open(file, (*readonly ? O_RDONLY : O_RDWR) | O_EXCL);
  if (file_fd < 0 && errno == EROFS && !*readonly) {
    *readonly = 1;
    file_fd = open(file, O_RDONLY | O_EXCL);
  }
  if (file_fd < 0)
    goto out;
  loop_fd = open(loop, *readonly ? O_RDONLY : O_RDWR);
  if (loop_fd < 0)
    goto out;
  strncpy((char *)lo64.lo_file_name, file, LO_NAME_SIZE);
  lo64.lo_offset = offset;
  if (autoclear)
    lo64.lo_flags |= 4;
  if (ioctl(loop_fd, LOOP_SET_FD, file_fd) < 0)
    goto out;
  if (ioctl(loop_fd, LOOP_SET_STATUS64, &lo64) < 0) {
    (void)ioctl(loop_fd, LOOP_CLR_FD, 0);
    goto out;
  }
  if (autoclear) {
    memset(&lo64, 0, sizeof(lo64));
    if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0 || !(lo64.lo_flags & 4)) {
      (void)ioctl(loop_fd, LOOP_CLR_FD, 0);
      goto out;
    }
  }
  r = 0;
out:
  if (r && loop_fd >= 0)
    close(loop_fd);
  if (file_fd >= 0)
    close(file_fd);
  return r ? -1 : loop_fd;
}


x86 assembly (clang, -O0):
<crypt_loop_attach>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0xffffffff,-0x3c(%rbp)
movl   $0xffffffff,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     11b5 <crypt_loop_attach+0x65>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
jmp    11c1 <crypt_loop_attach+0x71>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    0x2de1(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1232 <crypt_loop_attach+0xe2>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%rax
jne    1232 <crypt_loop_attach+0xe2>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1232 <crypt_loop_attach+0xe2>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
mov    0x2d88(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1241 <crypt_loop_attach+0xf1>
jmp    1390 <crypt_loop_attach+0x240>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1267 <crypt_loop_attach+0x117>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
jmp    1273 <crypt_loop_attach+0x123>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1070 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1291 <crypt_loop_attach+0x141>
jmp    1390 <crypt_loop_attach+0x240>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12c0 <crypt_loop_attach+0x170>
mov    -0x34(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2cc6(%rip),%rax
mov    (%rax),%esi
mov    -0x40(%rbp),%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    12e5 <crypt_loop_attach+0x195>
jmp    1390 <crypt_loop_attach+0x240>
mov    -0x3c(%rbp),%edi
mov    0x2cb1(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1320 <crypt_loop_attach+0x1d0>
mov    -0x3c(%rbp),%edi
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
jmp    1390 <crypt_loop_attach+0x240>
cmpl   $0x0,-0x18(%rbp)
je     1389 <crypt_loop_attach+0x239>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    -0x3c(%rbp),%edi
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jl     136a <crypt_loop_attach+0x21a>
mov    -0x34(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    1384 <crypt_loop_attach+0x234>
mov    -0x3c(%rbp),%edi
mov    0x2c4c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
jmp    1390 <crypt_loop_attach+0x240>
jmp    1389 <crypt_loop_attach+0x239>
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     13ac <crypt_loop_attach+0x25c>
cmpl   $0x0,-0x3c(%rbp)
jl     13ac <crypt_loop_attach+0x25c>
mov    -0x3c(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x40(%rbp)
jl     13be <crypt_loop_attach+0x26e>
mov    -0x40(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x44(%rbp)
je     13d5 <crypt_loop_attach+0x285>
mov    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    13db <crypt_loop_attach+0x28b>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt_loop_attach>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %ecx,0xc(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r13
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
cmpl   $0x0,(%r8)
mov    %edx,0x8(%rsp)
jne    118f <crypt_loop_attach+0x3f>
mov    0x2e5b(%rip),%rax
jmp    1196 <crypt_loop_attach+0x46>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
mov    0x2e11(%rip),%r15
or     (%r15),%esi
mov    %rbp,%rdi
call   1070 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
js     11c0 <crypt_loop_attach+0x70>
cmpl   $0x0,(%r14)
jne    1210 <crypt_loop_attach+0xc0>
mov    0x2e2a(%rip),%rax
jmp    1217 <crypt_loop_attach+0xc7>
mov    0x2de1(%rip),%rax
mov    (%rax),%rax
mov    0x2e07(%rip),%rcx
mov    $0xffffffff,%ebx
cmp    (%rcx),%rax
jne    12ed <crypt_loop_attach+0x19d>
cmpl   $0x0,(%r14)
jne    12ed <crypt_loop_attach+0x19d>
movl   $0x1,(%r14)
mov    0x2dd9(%rip),%rax
mov    (%r15),%esi
or     (%rax),%esi
mov    %rbp,%rdi
call   1070 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    11b1 <crypt_loop_attach+0x61>
jmp    12ed <crypt_loop_attach+0x19d>
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1070 <open@plt>
test   %eax,%eax
js     12e0 <crypt_loop_attach+0x190>
mov    %eax,%ebx
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
mov    0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
je     1256 <crypt_loop_attach+0x106>
movl   $0x4,0x14(%rsp)
mov    0x2d33(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12d9 <crypt_loop_attach+0x189>
mov    0x2d29(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12c5 <crypt_loop_attach+0x175>
test   %ebp,%ebp
je     12fe <crypt_loop_attach+0x1ae>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12c5 <crypt_loop_attach+0x175>
testb  $0x4,0x14(%rsp)
jne    12fe <crypt_loop_attach+0x1ae>
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <ioctl@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    %r12d,%edi
call   1060 <close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12d,%edi
call   1060 <close@plt>
jmp    12ed <crypt_loop_attach+0x19d>

LLVM IR (-O0):
%struct.loop_info64 = type { i32, i32, i64, i32 }
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@errno = global i64 0
@EROFS = global i64 0
@LO_NAME_SIZE = global i32 0
@LOOP_SET_FD = global i32 0
@LOOP_SET_STATUS64 = global i32 0
@LOOP_CLR_FD = global i32 0
@LOOP_GET_STATUS64 = global i32 0
define i32 @crypt_loop_attach(i8* %0, i8* %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca %struct.loop_info64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%15 = bitcast %struct.loop_info64* %11 to i8*
store i32 -1, i32* %12
store i32 -1, i32* %13
store i32 1, i32* %14
%16 = load i8*, i8** %7
%17 = load i32*, i32** %10
%18 = load i32, i32* %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %5
%21 = load i32, i32* @O_RDONLY
br label %24
22: ; preds = %5
%23 = load i32, i32* @O_RDWR
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ %21, %20 ], [ %23, %22 ]
%26 = load i32, i32* @O_EXCL
%27 = or i32 %25, %26
%28 = call i32 @open(i8* %16, i32 %27)
store i32 %28, i32* %13
%29 = load i32, i32* %13
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %46
31: ; preds = %24
%32 = load i64, i64* @errno
%33 = load i64, i64* @EROFS
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %46
35: ; preds = %31
%36 = load i32*, i32** %10
%37 = load i32, i32* %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %46, label %39
39: ; preds = %35
%40 = load i32*, i32** %10
store i32 1, i32* %40
%41 = load i8*, i8** %7
%42 = load i32, i32* @O_RDONLY
%43 = load i32, i32* @O_EXCL
%44 = or i32 %42, %43
%45 = call i32 @open(i8* %41, i32 %44)
store i32 %45, i32* %13
br label %46
46: ; preds = %39, %35, %31, %24
%47 = load i32, i32* %13
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
br label %116
50: ; preds = %46
%51 = load i8*, i8** %6
%52 = load i32*, i32** %10
%53 = load i32, i32* %52
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = load i32, i32* @O_RDONLY
br label %59
57: ; preds = %50
%58 = load i32, i32* @O_RDWR
br label %59
59: ; preds = %57, %55
%60 = phi i32 [ %56, %55 ], [ %58, %57 ]
%61 = call i32 @open(i8* %51, i32 %60)
store i32 %61, i32* %12
%62 = load i32, i32* %12
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %59
br label %116
65: ; preds = %59
%66 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %11, i32 0, i32 2
%67 = load i64, i64* %66
%68 = inttoptr i64 %67 to i8*
%69 = load i8*, i8** %7
%70 = load i32, i32* @LO_NAME_SIZE
%71 = call i32 @strncpy(i8* %68, i8* %69, i32 %70)
%72 = load i32, i32* %8
%73 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %11, i32 0, i32 0
store i32 %72, i32* %73
%74 = load i32, i32* %9
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %65
%77 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %11, i32 0, i32 1
%78 = load i32, i32* %77
%79 = or i32 %78, 4
store i32 %79, i32* %77
br label %80
80: ; preds = %76, %65
%81 = load i32, i32* %12
%82 = load i32, i32* @LOOP_SET_FD
%83 = load i32, i32* %13
%84 = call i64 (i32, i32, ...) @ioctl(i32 %81, i32 %82, i32 %83)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %80
br label %116
87: ; preds = %80
%88 = load i32, i32* %12
%89 = load i32, i32* @LOOP_SET_STATUS64
%90 = call i64 (i32, i32, ...) @ioctl(i32 %88, i32 %89, %struct.loop_info64* %11)
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = load i32, i32* %12
%94 = load i32, i32* @LOOP_CLR_FD
%95 = call i64 (i32, i32, ...) @ioctl(i32 %93, i32 %94, i32 0)
br label %116
96: ; preds = %87
%97 = load i32, i32* %9
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %115
99: ; preds = %96
%100 = call i32 @memset(%struct.loop_info64* %11, i32 0, i32 24)
%101 = load i32, i32* %12
%102 = load i32, i32* @LOOP_GET_STATUS64
%103 = call i64 (i32, i32, ...) @ioctl(i32 %101, i32 %102, %struct.loop_info64* %11)
%104 = icmp slt i64 %103, 0
br i1 %104, label %110, label %105
105: ; preds = %99
%106 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %11, i32 0, i32 1
%107 = load i32, i32* %106
%108 = and i32 %107, 4
%109 = icmp ne i32 %108, 0
br i1 %109, label %114, label %110
110: ; preds = %105, %99
%111 = load i32, i32* %12
%112 = load i32, i32* @LOOP_CLR_FD
%113 = call i64 (i32, i32, ...) @ioctl(i32 %111, i32 %112, i32 0)
br label %116
114: ; preds = %105
br label %115
115: ; preds = %114, %96
store i32 0, i32* %14
br label %116
116: ; preds = %115, %110, %92, %86, %64, %49
%117 = load i32, i32* %14
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %125
119: ; preds = %116
%120 = load i32, i32* %12
%121 = icmp sge i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %119
%123 = load i32, i32* %12
%124 = call i32 @close(i32 %123)
br label %125
125: ; preds = %122, %119, %116
%126 = load i32, i32* %13
%127 = icmp sge i32 %126, 0
br i1 %127, label %128, label %131
128: ; preds = %125
%129 = load i32, i32* %13
%130 = call i32 @close(i32 %129)
br label %131
131: ; preds = %128, %125
%132 = load i32, i32* %14
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %135
134: ; preds = %131
br label %137
135: ; preds = %131
%136 = load i32, i32* %12
br label %137
137: ; preds = %135, %134
%138 = phi i32 [ -1, %134 ], [ %136, %135 ]
ret i32 %138
}

LLVM IR (-O2):
%struct.loop_info64 = type { i32, i32, i64, i32 }
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@errno = global i64 0
@EROFS = global i64 0
@LO_NAME_SIZE = global i32 0
@LOOP_SET_FD = global i32 0
@LOOP_SET_STATUS64 = global i32 0
@LOOP_CLR_FD = global i32 0
@LOOP_GET_STATUS64 = global i32 0
define i32 @crypt_loop_attach(i8* nocapture %0, i8* %1, i32 %2, i32 %3, i32* nocapture %4) {
%6 = alloca %struct.loop_info64
%7 = bitcast %struct.loop_info64* %6 to i8*
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @O_RDONLY
%11 = load i32, i32* @O_RDWR
%12 = select i1 %9, i32 %11, i32 %10
%13 = load i32, i32* @O_EXCL
%14 = or i32 %12, %13
%15 = tail call i32 @open(i8* %1, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %5
%18 = load i64, i64* @errno
%19 = load i64, i64* @EROFS
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %75
21: ; preds = %17
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %75
24: ; preds = %21
store i32 1, i32* %4
%25 = load i32, i32* @O_RDONLY
%26 = load i32, i32* @O_EXCL
%27 = or i32 %26, %25
%28 = tail call i32 @open(i8* %1, i32 %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %75, label %30
30: ; preds = %5, %24
%31 = phi i32 [ %28, %24 ], [ %15, %5 ]
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 0
%34 = load i32, i32* @O_RDONLY
%35 = load i32, i32* @O_RDWR
%36 = select i1 %33, i32 %35, i32 %34
%37 = tail call i32 @open(i8* %0, i32 %36)
%38 = icmp slt i32 %37, 0
br i1 %38, label %73, label %39
39: ; preds = %30
%40 = load i32, i32* @LO_NAME_SIZE
%41 = tail call i32 @strncpy(i8* null, i8* %1, i32 %40)
%42 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 0
store i32 %2, i32* %42
%43 = icmp eq i32 %3, 0
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 1
store i32 4, i32* %45
br label %46
46: ; preds = %44, %39
%47 = load i32, i32* @LOOP_SET_FD
%48 = tail call i64 (i32, i32, ...) @ioctl(i32 %37, i32 %47, i32 %31)
%49 = icmp slt i64 %48, 0
br i1 %49, label %68, label %50
50: ; preds = %46
%51 = load i32, i32* @LOOP_SET_STATUS64
%52 = call i64 (i32, i32, ...) @ioctl(i32 %37, i32 %51, %struct.loop_info64* %6)
%53 = icmp slt i64 %52, 0
br i1 %53, label %65, label %54
54: ; preds = %50
br i1 %43, label %71, label %55
55: ; preds = %54
%56 = call i32 @memset(%struct.loop_info64* %6, i32 0, i32 24)
%57 = load i32, i32* @LOOP_GET_STATUS64
%58 = call i64 (i32, i32, ...) @ioctl(i32 %37, i32 %57, %struct.loop_info64* %6)
%59 = icmp slt i64 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %55
%61 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 1
%62 = load i32, i32* %61
%63 = and i32 %62, 4
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %55, %60, %50
%66 = load i32, i32* @LOOP_CLR_FD
%67 = call i64 (i32, i32, ...) @ioctl(i32 %37, i32 %66, i32 0)
br label %68
68: ; preds = %65, %46
%69 = call i32 @close(i32 %37)
%70 = call i32 @close(i32 %31)
br label %75
71: ; preds = %60, %54
%72 = call i32 @close(i32 %31)
br label %75
73: ; preds = %30
%74 = tail call i32 @close(i32 %31)
br label %75
75: ; preds = %17, %21, %24, %68, %73, %71
%76 = phi i32 [ %37, %71 ], [ -1, %73 ], [ -1, %68 ], [ -1, %24 ], [ -1, %21 ], [ -1, %17 ]
ret i32 %76
}