#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_dump(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_irq_msix(int);
int /*<<< orphan*/ set_irq_none(int);
void test_irq_review568(int fd) {
  int i;
  i = 10000;
  while (i) {
    printf("\nIRQ Loop Test = %d\n", i + 1);
    set_irq_msix(fd);
    i--;
  }
  set_irq_none(fd);
  printf("\nCalling Dump Metrics to irq_loop_test\n");
  ioctl_dump(fd, "/tmp/test_rev568.txt");
  printf("\nPressAny key..\n");
  getchar();
}


x86 assembly (clang, -O0):
<test_irq_review568>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2710,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1196 <test_irq_review568+0x46>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <set_irq_msix@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <test_irq_review568+0x12>
mov    -0x4(%rbp),%edi
call   1050 <set_irq_none@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
lea    0xe87(%rip),%rsi
call   1060 <ioctl_dump@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_irq_review568>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x2711,%ebp
lea    0xe8e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1080 <set_irq_msix@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jne    1180 <test_irq_review568+0x20>
mov    %ebx,%edi
call   1060 <set_irq_none@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe60(%rip),%rsi
mov    %ebx,%edi
call   1070 <ioctl_dump@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <getchar@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"\0AIRQ Loop Test = %d\0A\00"
@.str.1 = [40 x i8] c"\0ACalling Dump Metrics to irq_loop_test\0A\00"
@.str.2 = [21 x i8] c"/tmp/test_rev568.txt\00"
@.str.3 = [17 x i8] c"\0APressAny key..\0A\00"
define void @test_irq_review568(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 10000, i32* %3
br label %4
4: ; preds = %7, %1
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = call i32 @set_irq_msix(i32 %11)
%13 = load i32, i32* %3
%14 = add nsw i32 %13, -1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
%16 = load i32, i32* %2
%17 = call i32 @set_irq_none(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @ioctl_dump(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AIRQ Loop Test = %d\0A\00"
@.str.2 = [21 x i8] c"/tmp/test_rev568.txt\00"
@str = [39 x i8] c"\0ACalling Dump Metrics to irq_loop_test\00"
@str.4 = [16 x i8] c"\0APressAny key..\00"
define void @test_irq_review568(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 10000, %1 ], [ %7, %2 ]
%4 = add nuw nsw i32 %3, 1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @set_irq_msix(i32 %0)
%7 = add nsw i32 %3, -1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %2
9: ; preds = %2
%10 = tail call i32 @set_irq_none(i32 %0)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @ioctl_dump(i32 %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%14 = tail call i32 (...) @getchar()
ret void
}