#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 ioctl_prep_sq(int, int, int, int, int);
int ioctl_reap_inquiry(int, int /*<<< orphan*/);
int /*<<< orphan*/ ioctl_tst_ring_dbl(int, int /*<<< orphan*/);
int irq_cr_contig_io_sq(int, int, int, int);
int irq_cr_disc_io_sq(int, void *, int, int, int);
void set_sq_irq(int fd, void *addr) {
  int sq_id;
  int assoc_cq_id;
  int num;
  int ret_val;
  num = ioctl_reap_inquiry(fd, 0);
  sq_id = 31;
  assoc_cq_id = 20;
  ret_val = ioctl_prep_sq(fd, sq_id, assoc_cq_id, 4096, 0);
  if (ret_val < 0)
    return;
  ret_val = irq_cr_disc_io_sq(fd, addr, sq_id, assoc_cq_id, 4096);
  ioctl_tst_ring_dbl(fd, 0);
  sq_id = 32;
  assoc_cq_id = 21;
  ret_val = ioctl_prep_sq(fd, sq_id, assoc_cq_id, 4096, 1);
  if (ret_val < 0)
    return;
  ret_val = irq_cr_contig_io_sq(fd, sq_id, assoc_cq_id, 4096);
  sq_id = 33;
  assoc_cq_id = 22;
  ret_val = ioctl_prep_sq(fd, sq_id, assoc_cq_id, 4096, 1);
  if (ret_val < 0)
    return;
  ret_val = irq_cr_contig_io_sq(fd, sq_id, assoc_cq_id, 4096);
  sq_id = 34;
  assoc_cq_id = 23;
  ret_val = ioctl_prep_sq(fd, sq_id, assoc_cq_id, 4096, 1);
  if (ret_val < 0)
    return;
  ret_val = irq_cr_contig_io_sq(fd, sq_id, assoc_cq_id, 4096);
  ioctl_tst_ring_dbl(fd, 0);
}


x86 assembly (clang, -O0):
<set_sq_irq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <ioctl_reap_inquiry@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x1f,-0x14(%rbp)
movl   $0x14,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    11a2 <set_sq_irq+0x52>
jmp    12be <set_sq_irq+0x16e>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x1000,%r8d
call   1070 <irq_cr_disc_io_sq@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <ioctl_tst_ring_dbl@plt>
movl   $0x20,-0x14(%rbp)
movl   $0x15,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1200 <set_sq_irq+0xb0>
jmp    12be <set_sq_irq+0x16e>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %eax,-0x20(%rbp)
movl   $0x21,-0x14(%rbp)
movl   $0x16,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    124f <set_sq_irq+0xff>
jmp    12be <set_sq_irq+0x16e>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %eax,-0x20(%rbp)
movl   $0x22,-0x14(%rbp)
movl   $0x17,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    129e <set_sq_irq+0x14e>
jmp    12be <set_sq_irq+0x16e>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <ioctl_tst_ring_dbl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_sq_irq>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
xor    %esi,%esi
call   1030 <ioctl_reap_inquiry@plt>
mov    %ebx,%edi
mov    $0x1f,%esi
mov    $0x14,%edx
mov    $0x1000,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
test   %eax,%eax
js     125a <set_sq_irq+0x10a>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1f,%edx
mov    $0x14,%ecx
mov    $0x1000,%r8d
call   1070 <irq_cr_disc_io_sq@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <ioctl_tst_ring_dbl@plt>
mov    %ebx,%edi
mov    $0x20,%esi
mov    $0x15,%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
test   %eax,%eax
js     125a <set_sq_irq+0x10a>
mov    %ebx,%edi
mov    $0x20,%esi
mov    $0x15,%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %ebx,%edi
mov    $0x21,%esi
mov    $0x16,%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
test   %eax,%eax
js     125a <set_sq_irq+0x10a>
mov    %ebx,%edi
mov    $0x21,%esi
mov    $0x16,%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %ebx,%edi
mov    $0x22,%esi
mov    $0x17,%edx
mov    $0x1000,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
test   %eax,%eax
js     125a <set_sq_irq+0x10a>
mov    %ebx,%edi
mov    $0x22,%esi
mov    $0x17,%edx
mov    $0x1000,%ecx
call   1050 <irq_cr_contig_io_sq@plt>
mov    %ebx,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ioctl_tst_ring_dbl@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @set_sq_irq(i32 %0, i8* %1) {
%3 = tail call i32 @ioctl_reap_inquiry(i32 %0, i32 0)
%4 = tail call i32 @ioctl_prep_sq(i32 %0, i32 31, i32 20, i32 4096, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = tail call i32 @irq_cr_disc_io_sq(i32 %0, i8* %1, i32 31, i32 20, i32 4096)
%8 = tail call i32 @ioctl_tst_ring_dbl(i32 %0, i32 0)
%9 = tail call i32 @ioctl_prep_sq(i32 %0, i32 32, i32 21, i32 4096, i32 1)
%10 = icmp slt i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %6
%12 = tail call i32 @irq_cr_contig_io_sq(i32 %0, i32 32, i32 21, i32 4096)
%13 = tail call i32 @ioctl_prep_sq(i32 %0, i32 33, i32 22, i32 4096, i32 1)
%14 = icmp slt i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = tail call i32 @irq_cr_contig_io_sq(i32 %0, i32 33, i32 22, i32 4096)
%17 = tail call i32 @ioctl_prep_sq(i32 %0, i32 34, i32 23, i32 4096, i32 1)
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = tail call i32 @irq_cr_contig_io_sq(i32 %0, i32 34, i32 23, i32 4096)
%21 = tail call i32 @ioctl_tst_ring_dbl(i32 %0, i32 0)
br label %22
22: ; preds = %15, %11, %6, %2, %19
ret void
}