#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ cmd_irq();
int /*<<< orphan*/ data_irq();
int /*<<< orphan*/ reset_irq();
void IRQ3_vect(void) {
  uint8_t devcon = (*(volatile uint8_t *)(void *)(0xfffef018)) & 0x3c;
  (*(volatile uint8_t *)(void *)(0xfffef018)) = devcon;
  if (devcon & 0x0c)
    reset_irq();
  else if (devcon & 0x10)
    cmd_irq();
  else if (devcon & 0x20)
    data_irq();
}


x86 assembly (clang, -O0):
<IRQ3_vect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xfffef018,%eax
mov    (%rax),%eax
and    $0x3c,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0xfffef018,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
and    $0xc,%eax
cmp    $0x0,%eax
je     116a <IRQ3_vect+0x3a>
mov    $0x0,%al
call   1040 <reset_irq@plt>
jmp    11a5 <IRQ3_vect+0x75>
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1185 <IRQ3_vect+0x55>
mov    $0x0,%al
call   1050 <cmd_irq@plt>
jmp    11a0 <IRQ3_vect+0x70>
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     119b <IRQ3_vect+0x6b>
mov    $0x0,%al
call   1030 <data_irq@plt>
jmp    11a0 <IRQ3_vect+0x70>
jmp    11a5 <IRQ3_vect+0x75>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IRQ3_vect>:
mov    $0xfffef018,%ecx
mov    (%rcx),%eax
mov    %eax,%edx
and    $0x3c,%edx
mov    %edx,(%rcx)
test   $0xc,%al
je     1149 <IRQ3_vect+0x19>
xor    %eax,%eax
jmp    1040 <reset_irq@plt>
test   $0x10,%al
jne    1152 <IRQ3_vect+0x22>
test   $0x20,%al
jne    1159 <IRQ3_vect+0x29>
ret
xor    %eax,%eax
jmp    1050 <cmd_irq@plt>
xor    %eax,%eax
jmp    1030 <data_irq@plt>

LLVM IR (-O0):
define void @IRQ3_vect() {
%1 = alloca i32
%2 = load volatile i32, i32* inttoptr (i64 4294897688 to i32*)
%3 = and i32 %2, 60
store i32 %3, i32* %1
%4 = load i32, i32* %1
store volatile i32 %4, i32* inttoptr (i64 4294897688 to i32*)
%5 = load i32, i32* %1
%6 = and i32 %5, 12
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (...) @reset_irq()
br label %24
10: ; preds = %0
%11 = load i32, i32* %1
%12 = and i32 %11, 16
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (...) @cmd_irq()
br label %23
16: ; preds = %10
%17 = load i32, i32* %1
%18 = and i32 %17, 32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @data_irq()
br label %22
22: ; preds = %20, %16
br label %23
23: ; preds = %22, %14
br label %24
24: ; preds = %23, %8
ret void
}

LLVM IR (-O2):
define void @IRQ3_vect() {
%1 = load volatile i32, i32* inttoptr (i64 4294897688 to i32*)
%2 = and i32 %1, 60
store volatile i32 %2, i32* inttoptr (i64 4294897688 to i32*)
%3 = and i32 %1, 12
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (...) @reset_irq()
br label %17
7: ; preds = %0
%8 = and i32 %1, 16
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (...) @cmd_irq()
br label %17
12: ; preds = %7
%13 = and i32 %1, 32
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (...) @data_irq()
br label %17
17: ; preds = %10, %15, %12, %5
ret void
}