#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 */
typedef struct my_scsi_idlun TYPE_1__;

/* Type definitions */
struct my_scsi_idlun {
  int dev_id;
  int host_unique_id;
};

/* Variables and functions */
scalar_t__ ioctl(int, int, TYPE_1__ *);
int lx_chk_id(int dev_fd, int host, int channel, int id, int lun) {
  {
    struct my_scsi_idlun {
      int dev_id;
      int host_unique_id;
    } my_idlun;
    if (ioctl(dev_fd, 0x5382, &my_idlun) >= 0) {
      if (((my_idlun.dev_id & 0xff) == id) &&
          (((my_idlun.dev_id >> 8) & 0xff) == lun) &&
          (((my_idlun.dev_id >> 16) & 0xff) == channel))
        return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<lx_chk_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x5382,%esi
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jl     118d <lx_chk_id+0x7d>
mov    -0x20(%rbp),%eax
and    $0xff,%eax
cmp    -0x14(%rbp),%eax
jne    1188 <lx_chk_id+0x78>
mov    -0x20(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cmp    -0x18(%rbp),%eax
jne    1188 <lx_chk_id+0x78>
mov    -0x20(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cmp    -0x10(%rbp),%eax
jne    1188 <lx_chk_id+0x78>
movl   $0x1,-0x4(%rbp)
jmp    1194 <lx_chk_id+0x84>
jmp    118d <lx_chk_id+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lx_chk_id>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %edx,%r14d
lea    0x8(%rsp),%rdx
mov    $0x5382,%esi
call   1030 <ioctl@plt>
test   %rax,%rax
js     1158 <lx_chk_id+0x48>
mov    0x8(%rsp),%eax
movzbl %al,%ecx
cmp    %ebx,%ecx
jne    1158 <lx_chk_id+0x48>
movzbl %ah,%ecx
cmp    %ebp,%ecx
jne    1158 <lx_chk_id+0x48>
shr    $0x10,%eax
movzbl %al,%eax
cmp    %r14d,%eax
jne    1158 <lx_chk_id+0x48>
mov    $0x1,%eax
jmp    115a <lx_chk_id+0x4a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.my_scsi_idlun = type { i32, i32 }
%struct.my_scsi_idlun.0 = type { i32, i32 }
define i32 @lx_chk_id(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.my_scsi_idlun
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = load i32, i32* %7
%14 = bitcast %struct.my_scsi_idlun* %12 to %struct.my_scsi_idlun.0*
%15 = call i64 @ioctl(i32 %13, i32 21378, %struct.my_scsi_idlun.0* %14)
%16 = icmp sge i64 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %5
%18 = getelementptr inbounds %struct.my_scsi_idlun, %struct.my_scsi_idlun* %12, i32 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, 255
%21 = load i32, i32* %10
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %17
%24 = getelementptr inbounds %struct.my_scsi_idlun, %struct.my_scsi_idlun* %12, i32 0, i32 0
%25 = load i32, i32* %24
%26 = ashr i32 %25, 8
%27 = and i32 %26, 255
%28 = load i32, i32* %11
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %23
%31 = getelementptr inbounds %struct.my_scsi_idlun, %struct.my_scsi_idlun* %12, i32 0, i32 0
%32 = load i32, i32* %31
%33 = ashr i32 %32, 16
%34 = and i32 %33, 255
%35 = load i32, i32* %9
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %38
37: ; preds = %30
store i32 1, i32* %6
br label %40
38: ; preds = %30, %23, %17
br label %39
39: ; preds = %38, %5
store i32 0, i32* %6
br label %40
40: ; preds = %39, %37
%41 = load i32, i32* %6
ret i32 %41
}

LLVM IR (-O2):
%struct.my_scsi_idlun = type { i32, i32 }
%struct.my_scsi_idlun.0 = type { i32, i32 }
define i32 @lx_chk_id(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.my_scsi_idlun
%7 = bitcast %struct.my_scsi_idlun* %6 to i8*
%8 = bitcast %struct.my_scsi_idlun* %6 to %struct.my_scsi_idlun.0*
%9 = call i64 @ioctl(i32 %0, i32 21378, %struct.my_scsi_idlun.0* %8)
%10 = icmp sgt i64 %9, -1
br i1 %10, label %11, label %25
11: ; preds = %5
%12 = getelementptr inbounds %struct.my_scsi_idlun, %struct.my_scsi_idlun* %6, i64 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, 255
%15 = icmp eq i32 %14, %3
br i1 %15, label %16, label %25
16: ; preds = %11
%17 = lshr i32 %13, 8
%18 = and i32 %17, 255
%19 = icmp eq i32 %18, %4
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = lshr i32 %13, 16
%22 = and i32 %21, 255
%23 = icmp eq i32 %22, %2
br i1 %23, label %24, label %25
24: ; preds = %20
br label %26
25: ; preds = %5, %20, %16, %11
br label %26
26: ; preds = %24, %25
%27 = phi i32 [ 0, %25 ], [ 1, %24 ]
ret i32 %27
}