#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 char USBNRead(int);
int /*<<< orphan*/ USBNWrite(int, unsigned char);
int /*<<< orphan*/ _USBNAlternateEvent();
int /*<<< orphan*/ _USBNNackEvent();
int /*<<< orphan*/ _USBNReceiveEvent();
int /*<<< orphan*/ _USBNTransmitEvent();
void USBNInterrupt(void) {
  unsigned char maev, mask;
  maev = USBNRead(0x06);
  if (maev & 0x40)
    _USBNReceiveEvent();
  else if (maev & 0x04)
    _USBNTransmitEvent();
  else if (maev & 0x02)
    _USBNAlternateEvent();
  else if (maev & 0x10)
    _USBNNackEvent();
  mask = USBNRead(0x07);
  USBNWrite(0x07, 0x00);
  USBNWrite(0x07, mask);
}


x86 assembly (clang, -O0):
<USBNInterrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x6,%edi
call   1030 <USBNRead@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1191 <USBNInterrupt+0x31>
mov    $0x0,%al
call   1060 <_USBNReceiveEvent@plt>
jmp    11ef <USBNInterrupt+0x8f>
movzbl -0x1(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11ad <USBNInterrupt+0x4d>
mov    $0x0,%al
call   1040 <_USBNTransmitEvent@plt>
jmp    11ea <USBNInterrupt+0x8a>
movzbl -0x1(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11c9 <USBNInterrupt+0x69>
mov    $0x0,%al
call   1070 <_USBNAlternateEvent@plt>
jmp    11e5 <USBNInterrupt+0x85>
movzbl -0x1(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11e0 <USBNInterrupt+0x80>
mov    $0x0,%al
call   1080 <_USBNNackEvent@plt>
jmp    11e5 <USBNInterrupt+0x85>
jmp    11ea <USBNInterrupt+0x8a>
jmp    11ef <USBNInterrupt+0x8f>
mov    $0x7,%edi
call   1030 <USBNRead@plt>
mov    %al,-0x2(%rbp)
mov    $0x7,%edi
xor    %esi,%esi
call   1050 <USBNWrite@plt>
mov    $0x7,%edi
movzbl -0x2(%rbp),%esi
call   1050 <USBNWrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBNInterrupt>:
push   %rbx
mov    $0x6,%edi
call   1030 <USBNRead@plt>
test   $0x40,%al
jne    1184 <USBNInterrupt+0x24>
test   $0x4,%al
jne    118d <USBNInterrupt+0x2d>
test   $0x2,%al
jne    1196 <USBNInterrupt+0x36>
test   $0x10,%al
je     119d <USBNInterrupt+0x3d>
xor    %eax,%eax
call   1080 <_USBNNackEvent@plt>
jmp    119d <USBNInterrupt+0x3d>
xor    %eax,%eax
call   1060 <_USBNReceiveEvent@plt>
jmp    119d <USBNInterrupt+0x3d>
xor    %eax,%eax
call   1040 <_USBNTransmitEvent@plt>
jmp    119d <USBNInterrupt+0x3d>
xor    %eax,%eax
call   1070 <_USBNAlternateEvent@plt>
mov    $0x7,%edi
call   1030 <USBNRead@plt>
mov    %eax,%ebx
mov    $0x7,%edi
xor    %esi,%esi
call   1050 <USBNWrite@plt>
movzbl %bl,%esi
mov    $0x7,%edi
pop    %rbx
jmp    1050 <USBNWrite@plt>

LLVM IR (-O0):
define void @USBNInterrupt() {
%1 = alloca i8
%2 = alloca i8
%3 = call zeroext i8 @USBNRead(i32 6)
store i8 %3, i8* %1
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
%6 = and i32 %5, 64
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (...) @_USBNReceiveEvent()
br label %34
10: ; preds = %0
%11 = load i8, i8* %1
%12 = zext i8 %11 to i32
%13 = and i32 %12, 4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 (...) @_USBNTransmitEvent()
br label %33
17: ; preds = %10
%18 = load i8, i8* %1
%19 = zext i8 %18 to i32
%20 = and i32 %19, 2
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 (...) @_USBNAlternateEvent()
br label %32
24: ; preds = %17
%25 = load i8, i8* %1
%26 = zext i8 %25 to i32
%27 = and i32 %26, 16
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (...) @_USBNNackEvent()
br label %31
31: ; preds = %29, %24
br label %32
32: ; preds = %31, %22
br label %33
33: ; preds = %32, %15
br label %34
34: ; preds = %33, %8
%35 = call zeroext i8 @USBNRead(i32 7)
store i8 %35, i8* %2
%36 = call i32 @USBNWrite(i32 7, i8 zeroext 0)
%37 = load i8, i8* %2
%38 = call i32 @USBNWrite(i32 7, i8 zeroext %37)
ret void
}

LLVM IR (-O2):
define void @USBNInterrupt() {
%1 = tail call zeroext i8 @USBNRead(i32 6)
%2 = zext i8 %1 to i32
%3 = and i32 %2, 64
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (...) @_USBNReceiveEvent()
br label %22
7: ; preds = %0
%8 = and i32 %2, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (...) @_USBNTransmitEvent()
br label %22
12: ; preds = %7
%13 = and i32 %2, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (...) @_USBNAlternateEvent()
br label %22
17: ; preds = %12
%18 = and i32 %2, 16
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 (...) @_USBNNackEvent()
br label %22
22: ; preds = %10, %17, %20, %15, %5
%23 = tail call zeroext i8 @USBNRead(i32 7)
%24 = tail call i32 @USBNWrite(i32 7, i8 zeroext 0)
%25 = tail call i32 @USBNWrite(i32 7, i8 zeroext %23)
ret void
}