#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 GET32(int);
int /*<<< orphan*/ position_irq_handler();
int /*<<< orphan*/ timer_irq_handler();
void c_irq_handler() {
  unsigned int irq_basic, irq_pending1, irq_pending2;
  irq_basic = GET32(0x2000B200);
  if (irq_basic & (1 << 8)) {
    irq_pending1 = GET32(0x2000B204);
    if (irq_pending1 & (1 << 1))
      timer_irq_handler();
  }
  if (irq_basic & (1 << 9)) {
    irq_pending2 = GET32(0x2000B208);
    if (irq_pending2 & (1 << (49 - 32)))
      position_irq_handler();
  }
}


x86 assembly (clang, -O0):
<c_irq_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2000b200,%edi
call   1040 <GET32@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     117e <c_irq_handler+0x4e>
mov    $0x2000b204,%edi
call   1040 <GET32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1179 <c_irq_handler+0x49>
mov    $0x0,%al
call   1030 <timer_irq_handler@plt>
jmp    117e <c_irq_handler+0x4e>
mov    -0x4(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     11b9 <c_irq_handler+0x89>
mov    $0x2000b208,%edi
call   1040 <GET32@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x20000,%eax
cmp    $0x0,%eax
je     11b4 <c_irq_handler+0x84>
mov    $0x0,%al
call   1050 <position_irq_handler@plt>
jmp    11b9 <c_irq_handler+0x89>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_irq_handler>:
push   %rbx
mov    $0x2000b200,%edi
call   1040 <GET32@plt>
mov    %eax,%ebx
test   $0x100,%eax
je     1159 <c_irq_handler+0x29>
mov    $0x2000b204,%edi
call   1040 <GET32@plt>
test   $0x2,%al
je     1159 <c_irq_handler+0x29>
xor    %eax,%eax
call   1030 <timer_irq_handler@plt>
test   $0x200,%ebx
je     1172 <c_irq_handler+0x42>
mov    $0x2000b208,%edi
call   1040 <GET32@plt>
test   $0x20000,%eax
jne    1174 <c_irq_handler+0x44>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1050 <position_irq_handler@plt>

LLVM IR (-O0):
define void @c_irq_handler() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @GET32(i32 536916480)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = and i32 %5, 256
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = call i32 @GET32(i32 536916484)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = and i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 (...) @timer_irq_handler()
br label %15
15: ; preds = %13, %8
br label %16
16: ; preds = %15, %0
%17 = load i32, i32* %1
%18 = and i32 %17, 512
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = call i32 @GET32(i32 536916488)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = and i32 %22, 131072
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 (...) @position_irq_handler()
br label %27
27: ; preds = %25, %20
br label %28
28: ; preds = %27, %16
ret void
}

LLVM IR (-O2):
define void @c_irq_handler() {
%1 = tail call i32 @GET32(i32 536916480)
%2 = and i32 %1, 256
%3 = icmp eq i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = tail call i32 @GET32(i32 536916484)
%6 = and i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 (...) @timer_irq_handler()
br label %10
10: ; preds = %4, %8, %0
%11 = and i32 %1, 512
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i32 @GET32(i32 536916488)
%15 = and i32 %14, 131072
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 (...) @position_irq_handler()
br label %19
19: ; preds = %13, %17, %10
ret void
}