#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*/ getchar();
int /*<<< orphan*/ ioctl_prep_sq(int, int, int, int, int);
int /*<<< orphan*/ printf(char *);
void test_prep_sq(int file_desc) {
  printf(
      "\nTEST 2.2.1: Allocating 3 IO Contiguous SQs with different sizes...\n");
  printf("\n\tSD_ID : CQ ID = 1 : 1\n");
  ioctl_prep_sq(file_desc, 1, 1, 256, 0);
  printf("\nPress any key to continue..");
  getchar();
  printf("\n\tSD_ID : CQ ID = 2 : 3\n");
  ioctl_prep_sq(file_desc, 2, 3, 200, 1);
  printf("\nPress any key to continue..");
  getchar();
  printf("\n\tSD_ID : CQ ID = 3 : 6\n");
  ioctl_prep_sq(file_desc, 3, 6, 120, 1);
  printf("\nPress any key to continue..");
  getchar();
  printf("\nTEST 2.2.2: Allocating 3 Non-Contiguous IO SQs with different "
         "sizes...\n");
  printf("\n\tSD_ID : CQ ID = 4 : 6\n");
  ioctl_prep_sq(file_desc, 4, 6, 10, 0);
  printf("\nPress any key to continue..");
  getchar();
  printf("\n\tSD_ID : CQ ID = 5 : 1\n");
  ioctl_prep_sq(file_desc, 5, 1, 15, 0);
  printf("\nPress any key to continue..");
  getchar();
  printf("\n\tSD_ID : CQ ID = 6 : 3\n");
  ioctl_prep_sq(file_desc, 6, 3, 32, 0);
  printf("\nPress any key to continue..");
  getchar();
}


x86 assembly (clang, -O0):
<test_prep_sq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%edx
mov    $0x100,%ecx
xor    %r8d,%r8d
mov    %edx,%esi
call   1050 <ioctl_prep_sq@plt>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0xc8,%ecx
mov    $0x1,%r8d
call   1050 <ioctl_prep_sq@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x6,%edx
mov    $0x78,%ecx
mov    $0x1,%r8d
call   1050 <ioctl_prep_sq@plt>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
mov    $0x6,%edx
mov    $0xa,%ecx
xor    %r8d,%r8d
call   1050 <ioctl_prep_sq@plt>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x5,%esi
mov    $0x1,%edx
mov    $0xf,%ecx
xor    %r8d,%r8d
call   1050 <ioctl_prep_sq@plt>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x6,%esi
mov    $0x3,%edx
mov    $0x20,%ecx
xor    %r8d,%r8d
call   1050 <ioctl_prep_sq@plt>
lea    0xdbe(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_prep_sq>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x100,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
lea    0xe82(%rip),%r14
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0xc8,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x3,%esi
mov    $0x6,%edx
mov    $0x78,%ecx
mov    $0x1,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x4,%esi
mov    $0x6,%edx
mov    $0xa,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x5,%esi
mov    $0x1,%edx
mov    $0xf,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x6,%esi
mov    $0x3,%edx
mov    $0x20,%ecx
xor    %r8d,%r8d
call   1060 <ioctl_prep_sq@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <getchar@plt>

LLVM IR (-O0):
@.str = [69 x i8] c"\0ATEST 2.2.1: Allocating 3 IO Contiguous SQs with different sizes...\0A\00"
@.str.1 = [25 x i8] c"\0A\09SD_ID : CQ ID = 1 : 1\0A\00"
@.str.2 = [29 x i8] c"\0APress any key to continue..\00"
@.str.3 = [25 x i8] c"\0A\09SD_ID : CQ ID = 2 : 3\0A\00"
@.str.4 = [25 x i8] c"\0A\09SD_ID : CQ ID = 3 : 6\0A\00"
@.str.5 = [73 x i8] c"\0ATEST 2.2.2: Allocating 3 Non-Contiguous IO SQs with different sizes...\0A\00"
@.str.6 = [25 x i8] c"\0A\09SD_ID : CQ ID = 4 : 6\0A\00"
@.str.7 = [25 x i8] c"\0A\09SD_ID : CQ ID = 5 : 1\0A\00"
@.str.8 = [25 x i8] c"\0A\09SD_ID : CQ ID = 6 : 3\0A\00"
define void @test_prep_sq(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @ioctl_prep_sq(i32 %5, i32 1, i32 1, i32 256, i32 0)
%7 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (...) @getchar()
%9 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 @ioctl_prep_sq(i32 %10, i32 2, i32 3, i32 200, i32 1)
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (...) @getchar()
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = call i32 @ioctl_prep_sq(i32 %15, i32 3, i32 6, i32 120, i32 1)
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @getchar()
%19 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = call i32 @ioctl_prep_sq(i32 %21, i32 4, i32 6, i32 10, i32 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (...) @getchar()
%25 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = call i32 @ioctl_prep_sq(i32 %26, i32 5, i32 1, i32 15, i32 0)
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 (...) @getchar()
%30 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = call i32 @ioctl_prep_sq(i32 %31, i32 6, i32 3, i32 32, i32 0)
%33 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str.2 = [29 x i8] c"\0APress any key to continue..\00"
@str = [68 x i8] c"\0ATEST 2.2.1: Allocating 3 IO Contiguous SQs with different sizes...\00"
@str.9 = [24 x i8] c"\0A\09SD_ID : CQ ID = 1 : 1\00"
@str.10 = [24 x i8] c"\0A\09SD_ID : CQ ID = 2 : 3\00"
@str.11 = [24 x i8] c"\0A\09SD_ID : CQ ID = 3 : 6\00"
@str.12 = [72 x i8] c"\0ATEST 2.2.2: Allocating 3 Non-Contiguous IO SQs with different sizes...\00"
@str.13 = [24 x i8] c"\0A\09SD_ID : CQ ID = 4 : 6\00"
@str.14 = [24 x i8] c"\0A\09SD_ID : CQ ID = 5 : 1\00"
@str.15 = [24 x i8] c"\0A\09SD_ID : CQ ID = 6 : 3\00"
define void @test_prep_sq(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 @ioctl_prep_sq(i32 %0, i32 1, i32 1, i32 256, i32 0)
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (...) @getchar()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @ioctl_prep_sq(i32 %0, i32 2, i32 3, i32 200, i32 1)
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (...) @getchar()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%12 = tail call i32 @ioctl_prep_sq(i32 %0, i32 3, i32 6, i32 120, i32 1)
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 (...) @getchar()
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
%17 = tail call i32 @ioctl_prep_sq(i32 %0, i32 4, i32 6, i32 10, i32 0)
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (...) @getchar()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
%21 = tail call i32 @ioctl_prep_sq(i32 %0, i32 5, i32 1, i32 15, i32 0)
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 (...) @getchar()
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.15, i64 0, i64 0))
%25 = tail call i32 @ioctl_prep_sq(i32 %0, i32 6, i32 3, i32 32, i32 0)
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 (...) @getchar()
ret void
}