#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*/ ioctl_reap_cq(int, int, int, int, int /*<<< orphan*/);
int ioctl_reap_inquiry(int, int);
int /*<<< orphan*/ ioctl_tst_ring_dbl(int, int);
int /*<<< orphan*/ send_nvme_read(int, int, void *);
void test_discontig_io_irq(int fd, void *addr) {
  int sq_id, num, assoc_cq_id;
  sq_id = 31;
  assoc_cq_id = 20;
  num = ioctl_reap_inquiry(fd, assoc_cq_id);
  send_nvme_read(fd, sq_id, addr);
  ioctl_tst_ring_dbl(fd, sq_id);
  while (ioctl_reap_inquiry(fd, assoc_cq_id) != num + 1)
    ;
  ioctl_reap_cq(fd, assoc_cq_id, 1, 16, 0);
}


x86 assembly (clang, -O0):
<test_discontig_io_irq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1f,-0x14(%rbp)
movl   $0x14,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <ioctl_reap_inquiry@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <send_nvme_read@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <ioctl_tst_ring_dbl@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <ioctl_reap_inquiry@plt>
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     11a3 <test_discontig_io_irq+0x63>
jmp    1185 <test_discontig_io_irq+0x45>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    $0x1,%edx
mov    $0x10,%ecx
xor    %r8d,%r8d
call   1050 <ioctl_reap_cq@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_discontig_io_irq>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
mov    $0x14,%esi
call   1040 <ioctl_reap_inquiry@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x1f,%esi
mov    %r14,%rdx
call   1030 <send_nvme_read@plt>
mov    %ebx,%edi
mov    $0x1f,%esi
call   1060 <ioctl_tst_ring_dbl@plt>
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    $0x14,%esi
call   1040 <ioctl_reap_inquiry@plt>
cmp    %ebp,%eax
jne    1180 <test_discontig_io_irq+0x40>
mov    %ebx,%edi
mov    $0x14,%esi
mov    $0x1,%edx
mov    $0x10,%ecx
xor    %r8d,%r8d
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ioctl_reap_cq@plt>

LLVM IR (-O0):
define void @test_discontig_io_irq(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 31, i32* %5
store i32 20, i32* %7
%8 = load i32, i32* %3
%9 = load i32, i32* %7
%10 = call i32 @ioctl_reap_inquiry(i32 %8, i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = load i8*, i8** %4
%14 = call i32 @send_nvme_read(i32 %11, i32 %12, i8* %13)
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = call i32 @ioctl_tst_ring_dbl(i32 %15, i32 %16)
br label %18
18: ; preds = %25, %2
%19 = load i32, i32* %3
%20 = load i32, i32* %7
%21 = call i32 @ioctl_reap_inquiry(i32 %19, i32 %20)
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
%24 = icmp ne i32 %21, %23
br i1 %24, label %25, label %26
25: ; preds = %18
br label %18
26: ; preds = %18
%27 = load i32, i32* %3
%28 = load i32, i32* %7
%29 = call i32 @ioctl_reap_cq(i32 %27, i32 %28, i32 1, i32 16, i32 0)
ret void
}

LLVM IR (-O2):
define void @test_discontig_io_irq(i32 %0, i8* %1) {
%3 = tail call i32 @ioctl_reap_inquiry(i32 %0, i32 20)
%4 = tail call i32 @send_nvme_read(i32 %0, i32 31, i8* %1)
%5 = tail call i32 @ioctl_tst_ring_dbl(i32 %0, i32 31)
%6 = add nsw i32 %3, 1
br label %7
7: ; preds = %7, %2
%8 = tail call i32 @ioctl_reap_inquiry(i32 %0, i32 20)
%9 = icmp eq i32 %8, %6
br i1 %9, label %10, label %7
10: ; preds = %7
%11 = tail call i32 @ioctl_reap_cq(i32 %0, i32 20, i32 1, i32 16, i32 0)
ret void
}