#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__ EACCES;
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 || errno == EACCES) && !*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    0x2dd9(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    124c <crypt_loop_attach+0xfc>
mov    0x2db6(%rip),%rax
mov    (%rax),%rax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%rax
je     1217 <crypt_loop_attach+0xc7>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
mov    0x2daa(%rip),%rcx
cmp    (%rcx),%rax
jne    124c <crypt_loop_attach+0xfc>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    124c <crypt_loop_attach+0xfc>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
mov    0x2d66(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    125b <crypt_loop_attach+0x10b>
jmp    13aa <crypt_loop_attach+0x25a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1281 <crypt_loop_attach+0x131>
mov    0x2d59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
jmp    128d <crypt_loop_attach+0x13d>
mov    0x2d60(%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    12ab <crypt_loop_attach+0x15b>
jmp    13aa <crypt_loop_attach+0x25a>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12da <crypt_loop_attach+0x18a>
mov    -0x34(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2ca4(%rip),%rax
mov    (%rax),%esi
mov    -0x40(%rbp),%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    12ff <crypt_loop_attach+0x1af>
jmp    13aa <crypt_loop_attach+0x25a>
mov    -0x3c(%rbp),%edi
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    133a <crypt_loop_attach+0x1ea>
mov    -0x3c(%rbp),%edi
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
jmp    13aa <crypt_loop_attach+0x25a>
cmpl   $0x0,-0x18(%rbp)
je     13a3 <crypt_loop_attach+0x253>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    -0x3c(%rbp),%edi
mov    0x2c6a(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jl     1384 <crypt_loop_attach+0x234>
mov    -0x34(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    139e <crypt_loop_attach+0x24e>
mov    -0x3c(%rbp),%edi
mov    0x2c32(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
jmp    13aa <crypt_loop_attach+0x25a>
jmp    13a3 <crypt_loop_attach+0x253>
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     13c6 <crypt_loop_attach+0x276>
cmpl   $0x0,-0x3c(%rbp)
jl     13c6 <crypt_loop_attach+0x276>
mov    -0x3c(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x40(%rbp)
jl     13d8 <crypt_loop_attach+0x288>
mov    -0x40(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x44(%rbp)
je     13ef <crypt_loop_attach+0x29f>
mov    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    13f5 <crypt_loop_attach+0x2a5>
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    0x2e09(%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    121c <crypt_loop_attach+0xcc>
mov    0x2e2a(%rip),%rax
jmp    1223 <crypt_loop_attach+0xd3>
mov    0x2dd9(%rip),%rax
mov    (%rax),%rax
mov    0x2e07(%rip),%rcx
mov    $0xffffffff,%ebx
cmp    (%rcx),%rax
je     11eb <crypt_loop_attach+0x9b>
mov    0x2dd6(%rip),%rcx
cmp    (%rcx),%rax
jne    12f9 <crypt_loop_attach+0x1a9>
cmpl   $0x0,(%r14)
jne    12f9 <crypt_loop_attach+0x1a9>
movl   $0x1,(%r14)
mov    0x2dcd(%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    12f9 <crypt_loop_attach+0x1a9>
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1070 <open@plt>
test   %eax,%eax
js     12ec <crypt_loop_attach+0x19c>
mov    %eax,%ebx
mov    0x2da2(%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     1262 <crypt_loop_attach+0x112>
movl   $0x4,0x14(%rsp)
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12e5 <crypt_loop_attach+0x195>
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12d1 <crypt_loop_attach+0x181>
test   %ebp,%ebp
je     130a <crypt_loop_attach+0x1ba>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %rax,%rax
js     12d1 <crypt_loop_attach+0x181>
testb  $0x4,0x14(%rsp)
jne    130a <crypt_loop_attach+0x1ba>
mov    0x2ce8(%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    12f9 <crypt_loop_attach+0x1a9>

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

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
@EACCES = 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 %33
17: ; preds = %5
%18 = load i64, i64* @errno
%19 = load i64, i64* @EROFS
%20 = icmp eq i64 %18, %19
%21 = load i64, i64* @EACCES
%22 = icmp eq i64 %18, %21
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %24, label %78
24: ; preds = %17
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %78
27: ; preds = %24
store i32 1, i32* %4
%28 = load i32, i32* @O_RDONLY
%29 = load i32, i32* @O_EXCL
%30 = or i32 %29, %28
%31 = tail call i32 @open(i8* %1, i32 %30)
%32 = icmp slt i32 %31, 0
br i1 %32, label %78, label %33
33: ; preds = %5, %27
%34 = phi i32 [ %31, %27 ], [ %15, %5 ]
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
%37 = load i32, i32* @O_RDONLY
%38 = load i32, i32* @O_RDWR
%39 = select i1 %36, i32 %38, i32 %37
%40 = tail call i32 @open(i8* %0, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %76, label %42
42: ; preds = %33
%43 = load i32, i32* @LO_NAME_SIZE
%44 = tail call i32 @strncpy(i8* null, i8* %1, i32 %43)
%45 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 0
store i32 %2, i32* %45
%46 = icmp eq i32 %3, 0
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 1
store i32 4, i32* %48
br label %49
49: ; preds = %47, %42
%50 = load i32, i32* @LOOP_SET_FD
%51 = tail call i64 (i32, i32, ...) @ioctl(i32 %40, i32 %50, i32 %34)
%52 = icmp slt i64 %51, 0
br i1 %52, label %71, label %53
53: ; preds = %49
%54 = load i32, i32* @LOOP_SET_STATUS64
%55 = call i64 (i32, i32, ...) @ioctl(i32 %40, i32 %54, %struct.loop_info64* %6)
%56 = icmp slt i64 %55, 0
br i1 %56, label %68, label %57
57: ; preds = %53
br i1 %46, label %74, label %58
58: ; preds = %57
%59 = call i32 @memset(%struct.loop_info64* %6, i32 0, i32 24)
%60 = load i32, i32* @LOOP_GET_STATUS64
%61 = call i64 (i32, i32, ...) @ioctl(i32 %40, i32 %60, %struct.loop_info64* %6)
%62 = icmp slt i64 %61, 0
br i1 %62, label %68, label %63
63: ; preds = %58
%64 = getelementptr inbounds %struct.loop_info64, %struct.loop_info64* %6, i64 0, i32 1
%65 = load i32, i32* %64
%66 = and i32 %65, 4
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %58, %63, %53
%69 = load i32, i32* @LOOP_CLR_FD
%70 = call i64 (i32, i32, ...) @ioctl(i32 %40, i32 %69, i32 0)
br label %71
71: ; preds = %68, %49
%72 = call i32 @close(i32 %40)
%73 = call i32 @close(i32 %34)
br label %78
74: ; preds = %63, %57
%75 = call i32 @close(i32 %34)
br label %78
76: ; preds = %33
%77 = tail call i32 @close(i32 %34)
br label %78
78: ; preds = %17, %24, %27, %71, %76, %74
%79 = phi i32 [ %40, %74 ], [ -1, %76 ], [ -1, %71 ], [ -1, %27 ], [ -1, %24 ], [ -1, %17 ]
ret i32 %79
}