#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*/ exit(int);
int ioctl_prep_cq(int, int, int, int);
int ioctl_reap_inquiry(int, int /*<<< orphan*/);
int /*<<< orphan*/ ioctl_tst_ring_dbl(int, int /*<<< orphan*/);
int irq_for_io_contig(int, int, int, int, int);
int irq_for_io_discontig(int, int, int, int, int, void *);
void set_cq_irq(int fd, void *p_dcq_buf) {
  int ret_val;
  int cq_id;
  int irq_no;
  int cq_flags;
  int num;
  cq_id = 20;
  irq_no = 1;
  cq_flags = 0x2;
  num = ioctl_reap_inquiry(fd, 0);
  ret_val = ioctl_prep_cq(fd, cq_id, 4096, 0);
  if (ret_val < 0)
    exit(-1);
  ret_val = irq_for_io_discontig(fd, cq_id, irq_no, cq_flags, 4096, p_dcq_buf);
  ioctl_tst_ring_dbl(fd, 0);
  cq_id = 21;
  irq_no = 2;
  cq_flags = 0x3;
  ret_val = ioctl_prep_cq(fd, cq_id, 4096, 1);
  if (ret_val < 0)
    exit(-1);
  ret_val = irq_for_io_contig(fd, cq_id, irq_no, cq_flags, 4096);
  cq_id = 22;
  irq_no = 2;
  cq_flags = 0x3;
  ret_val = ioctl_prep_cq(fd, cq_id, 4096, 1);
  if (ret_val < 0)
    exit(-1);
  ret_val = irq_for_io_contig(fd, cq_id, irq_no, cq_flags, 4096);
  cq_id = 23;
  irq_no = 3;
  cq_flags = 0x3;
  ret_val = ioctl_prep_cq(fd, cq_id, 4096, 1);
  if (ret_val < 0)
    exit(-1);
  ret_val = irq_for_io_contig(fd, cq_id, irq_no, cq_flags, 4096);
  ioctl_tst_ring_dbl(fd, 0);
}


x86 assembly (clang, -O0):
<set_cq_irq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x14,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <ioctl_reap_inquiry@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1040 <ioctl_prep_cq@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ba <set_cq_irq+0x5a>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%r9
mov    $0x1000,%r8d
call   1030 <irq_for_io_discontig@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <ioctl_tst_ring_dbl@plt>
movl   $0x15,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x3,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1223 <set_cq_irq+0xc3>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %eax,-0x14(%rbp)
movl   $0x16,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x3,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    127e <set_cq_irq+0x11e>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %eax,-0x14(%rbp)
movl   $0x17,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x3,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12d9 <set_cq_irq+0x179>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <ioctl_tst_ring_dbl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_cq_irq>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
xor    %esi,%esi
call   1050 <ioctl_reap_inquiry@plt>
mov    %ebx,%edi
mov    $0x14,%esi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1040 <ioctl_prep_cq@plt>
test   %eax,%eax
js     1269 <set_cq_irq+0x109>
mov    %ebx,%edi
mov    $0x14,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    $0x1000,%r8d
mov    %r14,%r9
call   1030 <irq_for_io_discontig@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <ioctl_tst_ring_dbl@plt>
mov    %ebx,%edi
mov    $0x15,%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
test   %eax,%eax
js     1269 <set_cq_irq+0x109>
mov    %ebx,%edi
mov    $0x15,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %ebx,%edi
mov    $0x16,%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
test   %eax,%eax
js     1269 <set_cq_irq+0x109>
mov    %ebx,%edi
mov    $0x16,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %ebx,%edi
mov    $0x17,%esi
mov    $0x1000,%edx
mov    $0x1,%ecx
call   1040 <ioctl_prep_cq@plt>
test   %eax,%eax
js     1269 <set_cq_irq+0x109>
mov    %ebx,%edi
mov    $0x17,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0x1000,%r8d
call   1060 <irq_for_io_contig@plt>
mov    %ebx,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <ioctl_tst_ring_dbl@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
define void @set_cq_irq(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 20, i32* %6
store i32 1, i32* %7
store i32 2, i32* %8
%10 = load i32, i32* %3
%11 = call i32 @ioctl_reap_inquiry(i32 %10, i32 0)
store i32 %11, i32* %9
%12 = load i32, i32* %3
%13 = load i32, i32* %6
%14 = call i32 @ioctl_prep_cq(i32 %12, i32 %13, i32 4096, i32 0)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i32, i32* %3
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i8*, i8** %4
%25 = call i32 @irq_for_io_discontig(i32 %20, i32 %21, i32 %22, i32 %23, i32 4096, i8* %24)
store i32 %25, i32* %5
%26 = load i32, i32* %3
%27 = call i32 @ioctl_tst_ring_dbl(i32 %26, i32 0)
store i32 21, i32* %6
store i32 2, i32* %7
store i32 3, i32* %8
%28 = load i32, i32* %3
%29 = load i32, i32* %6
%30 = call i32 @ioctl_prep_cq(i32 %28, i32 %29, i32 4096, i32 1)
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %19
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %19
%36 = load i32, i32* %3
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = call i32 @irq_for_io_contig(i32 %36, i32 %37, i32 %38, i32 %39, i32 4096)
store i32 %40, i32* %5
store i32 22, i32* %6
store i32 2, i32* %7
store i32 3, i32* %8
%41 = load i32, i32* %3
%42 = load i32, i32* %6
%43 = call i32 @ioctl_prep_cq(i32 %41, i32 %42, i32 4096, i32 1)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %35
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %35
%49 = load i32, i32* %3
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32 @irq_for_io_contig(i32 %49, i32 %50, i32 %51, i32 %52, i32 4096)
store i32 %53, i32* %5
store i32 23, i32* %6
store i32 3, i32* %7
store i32 3, i32* %8
%54 = load i32, i32* %3
%55 = load i32, i32* %6
%56 = call i32 @ioctl_prep_cq(i32 %54, i32 %55, i32 4096, i32 1)
store i32 %56, i32* %5
%57 = load i32, i32* %5
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %48
%60 = call i32 @exit(i32 -1)
unreachable
61: ; preds = %48
%62 = load i32, i32* %3
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = load i32, i32* %8
%66 = call i32 @irq_for_io_contig(i32 %62, i32 %63, i32 %64, i32 %65, i32 4096)
store i32 %66, i32* %5
%67 = load i32, i32* %3
%68 = call i32 @ioctl_tst_ring_dbl(i32 %67, i32 0)
ret void
}

LLVM IR (-O2):
define void @set_cq_irq(i32 %0, i8* %1) {
%3 = tail call i32 @ioctl_reap_inquiry(i32 %0, i32 0)
%4 = tail call i32 @ioctl_prep_cq(i32 %0, i32 20, i32 4096, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = tail call i32 @irq_for_io_discontig(i32 %0, i32 20, i32 1, i32 2, i32 4096, i8* %1)
%10 = tail call i32 @ioctl_tst_ring_dbl(i32 %0, i32 0)
%11 = tail call i32 @ioctl_prep_cq(i32 %0, i32 21, i32 4096, i32 1)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %8
%16 = tail call i32 @irq_for_io_contig(i32 %0, i32 21, i32 2, i32 3, i32 4096)
%17 = tail call i32 @ioctl_prep_cq(i32 %0, i32 22, i32 4096, i32 1)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %15
%22 = tail call i32 @irq_for_io_contig(i32 %0, i32 22, i32 2, i32 3, i32 4096)
%23 = tail call i32 @ioctl_prep_cq(i32 %0, i32 23, i32 4096, i32 1)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %21
%28 = tail call i32 @irq_for_io_contig(i32 %0, i32 23, i32 3, i32 3, i32 4096)
%29 = tail call i32 @ioctl_tst_ring_dbl(i32 %0, i32 0)
ret void
}