#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, int);
void _USBNAlternateEvent(void) {
  unsigned char event;
  event = USBNRead(0x08);
  if (event & 0x40) {
    USBNWrite(0x05, 0x00);
    USBNWrite(0x04, 0x80 + 0);
    USBNWrite(0x20, 0x00);
    USBNWrite(0x23, 0x08);
    USBNWrite(0x27, 0x01);
    USBNWrite(0x05, 0x02);
  }
  if (event & 0x10) {
    USBNWrite(0x09, 0x80 + 0x40);
  }
  if (event & 0x80) {
    USBNWrite(0x09, 0x10 + 0x40 + 0x80);
  }
  if (event & 0x08) {
  }
}


x86 assembly (clang, -O0):
<_USBNAlternateEvent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x8,%edi
call   1030 <USBNRead@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1199 <_USBNAlternateEvent+0x79>
mov    $0x5,%edi
xor    %esi,%esi
call   1040 <USBNWrite@plt>
mov    $0x4,%edi
mov    $0x80,%esi
call   1040 <USBNWrite@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1040 <USBNWrite@plt>
mov    $0x23,%edi
mov    $0x8,%esi
call   1040 <USBNWrite@plt>
mov    $0x27,%edi
mov    $0x1,%esi
call   1040 <USBNWrite@plt>
mov    $0x5,%edi
mov    $0x2,%esi
call   1040 <USBNWrite@plt>
movzbl -0x1(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11b8 <_USBNAlternateEvent+0x98>
mov    $0x9,%edi
mov    $0xc0,%esi
call   1040 <USBNWrite@plt>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11d9 <_USBNAlternateEvent+0xb9>
mov    $0x9,%edi
mov    $0xd0,%esi
call   1040 <USBNWrite@plt>
movzbl -0x1(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ee <_USBNAlternateEvent+0xce>
jmp    11ee <_USBNAlternateEvent+0xce>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_USBNAlternateEvent>:
push   %rbx
mov    $0x8,%edi
call   1030 <USBNRead@plt>
mov    %eax,%ebx
test   $0x40,%al
jne    113d <_USBNAlternateEvent+0x1d>
test   $0x10,%bl
jne    1196 <_USBNAlternateEvent+0x76>
test   $0x80,%bl
jne    11aa <_USBNAlternateEvent+0x8a>
pop    %rbx
ret
mov    $0x5,%edi
xor    %esi,%esi
call   1040 <USBNWrite@plt>
mov    $0x4,%edi
mov    $0x80,%esi
call   1040 <USBNWrite@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1040 <USBNWrite@plt>
mov    $0x23,%edi
mov    $0x8,%esi
call   1040 <USBNWrite@plt>
mov    $0x27,%edi
mov    $0x1,%esi
call   1040 <USBNWrite@plt>
mov    $0x5,%edi
mov    $0x2,%esi
call   1040 <USBNWrite@plt>
test   $0x10,%bl
je     1136 <_USBNAlternateEvent+0x16>
mov    $0x9,%edi
mov    $0xc0,%esi
call   1040 <USBNWrite@plt>
test   $0x80,%bl
je     113b <_USBNAlternateEvent+0x1b>
mov    $0x9,%edi
mov    $0xd0,%esi
pop    %rbx
jmp    1040 <USBNWrite@plt>

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

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