#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 */
unsigned int CheckIRQ();
int /*<<< orphan*/ DisableInterrupts();
int /*<<< orphan*/ EnableInterrupts();
int /*<<< orphan*/ cprintf(char *, ...);
void PrintPendingInterrupts() {
  const unsigned int enabled = CheckIRQ();
  if (enabled == 1) {
    DisableInterrupts();
  }
  {
    cprintf("Pending IRQs:\n");
    cprintf("  HIPND:  %x %x %x %x\n",
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD8C)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD88)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD84)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD80)))));
    cprintf("  PND:    %x %x %x %x\n",
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD0C)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD08)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD04)))),
            (*((volatile unsigned int *)(((0x0FFFC000) + 0xD00)))));
  }
  if (enabled == 1) {
    EnableInterrupts();
  }
}


x86 assembly (clang, -O0):
<PrintPendingInterrupts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <CheckIRQ@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1163 <PrintPendingInterrupts+0x23>
mov    $0x0,%al
call   1050 <DisableInterrupts@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
mov    $0xfffcd8c,%eax
mov    (%rax),%esi
mov    $0xfffcd88,%eax
mov    (%rax),%edx
mov    $0xfffcd84,%eax
mov    (%rax),%ecx
mov    $0xfffcd80,%eax
mov    (%rax),%r8d
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
mov    $0xfffcd0c,%eax
mov    (%rax),%esi
mov    $0xfffcd08,%eax
mov    (%rax),%edx
mov    $0xfffcd04,%eax
mov    (%rax),%ecx
mov    $0xfffcd00,%eax
mov    (%rax),%r8d
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11d8 <PrintPendingInterrupts+0x98>
mov    $0x0,%al
call   1060 <EnableInterrupts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintPendingInterrupts>:
push   %rbx
xor    %eax,%eax
call   1040 <CheckIRQ@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
jne    1156 <PrintPendingInterrupts+0x16>
xor    %eax,%eax
call   1050 <DisableInterrupts@plt>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
mov    0xfffcd8c,%esi
mov    0xfffcd88,%edx
mov    0xfffcd84,%ecx
mov    0xfffcd80,%r8d
0f
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
mov    0xfffcd0c,%esi
mov    0xfffcd08,%edx
mov    0xfffcd04,%ecx
mov    0xfffcd00,%r8d
0f
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
cmp    $0x1,%ebx
jne    11c7 <PrintPendingInterrupts+0x87>
xor    %eax,%eax
pop    %rbx
jmp    1060 <EnableInterrupts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Pending IRQs:\0A\00"
@.str.1 = [23 x i8] c" HIPND: %x %x %x %x\0A\00"
@.str.2 = [23 x i8] c" PND: %x %x %x %x\0A\00"
define void @PrintPendingInterrupts() {
%1 = alloca i32
%2 = call i32 (...) @CheckIRQ()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (...) @DisableInterrupts()
br label %7
7: ; preds = %5, %0
%8 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = load volatile i32, i32* inttoptr (i64 268422540 to i32*)
%10 = load volatile i32, i32* inttoptr (i64 268422536 to i32*)
%11 = load volatile i32, i32* inttoptr (i64 268422532 to i32*)
%12 = load volatile i32, i32* inttoptr (i64 268422528 to i32*)
%13 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10, i32 %11, i32 %12)
%14 = load volatile i32, i32* inttoptr (i64 268422412 to i32*)
%15 = load volatile i32, i32* inttoptr (i64 268422408 to i32*)
%16 = load volatile i32, i32* inttoptr (i64 268422404 to i32*)
%17 = load volatile i32, i32* inttoptr (i64 268422400 to i32*)
%18 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %7
%22 = call i32 (...) @EnableInterrupts()
br label %23
23: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Pending IRQs:\0A\00"
@.str.1 = [23 x i8] c" HIPND: %x %x %x %x\0A\00"
@.str.2 = [23 x i8] c" PND: %x %x %x %x\0A\00"
define void @PrintPendingInterrupts() {
%1 = tail call i32 (...) @CheckIRQ()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @DisableInterrupts()
br label %5
5: ; preds = %3, %0
%6 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load volatile i32, i32* inttoptr (i64 268422540 to i32*)
%8 = load volatile i32, i32* inttoptr (i64 268422536 to i32*)
%9 = load volatile i32, i32* inttoptr (i64 268422532 to i32*)
%10 = load volatile i32, i32* inttoptr (i64 268422528 to i32*)
%11 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8, i32 %9, i32 %10)
%12 = load volatile i32, i32* inttoptr (i64 268422412 to i32*)
%13 = load volatile i32, i32* inttoptr (i64 268422408 to i32*)
%14 = load volatile i32, i32* inttoptr (i64 268422404 to i32*)
%15 = load volatile i32, i32* inttoptr (i64 268422400 to i32*)
%16 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13, i32 %14, i32 %15)
br i1 %2, label %17, label %19
17: ; preds = %5
%18 = tail call i32 (...) @EnableInterrupts()
br label %19
19: ; preds = %17, %5
ret void
}