#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 uint16_t;

/* Variables and functions */
int st103_get_istr();
int /*<<< orphan*/ st103_set_istr(int);
int /*<<< orphan*/ usb_cb_device_reset();
int /*<<< orphan*/ usb_handle_transfer(int);
void usb_interrupt_handler(void) {
  uint16_t istr_value = st103_get_istr();
  if ((istr_value & (0x0400))) {
    st103_set_istr((~(0x0400)));
    usb_cb_device_reset();
  } else {
    if ((istr_value & (0x4000)))
      st103_set_istr((~(0x4000)));
    if ((istr_value & (0x2000)))
      st103_set_istr((~(0x2000)));
    if ((istr_value & (0x8000)))
      usb_handle_transfer(istr_value);
  }
}


x86 assembly (clang, -O0):
<usb_interrupt_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <st103_get_istr@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     1179 <usb_interrupt_handler+0x39>
mov    $0xfffffbff,%edi
call   1030 <st103_set_istr@plt>
mov    $0x0,%al
call   1040 <usb_cb_device_reset@plt>
jmp    11cd <usb_interrupt_handler+0x8d>
mov    -0x4(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1194 <usb_interrupt_handler+0x54>
mov    $0xffffbfff,%edi
call   1030 <st103_set_istr@plt>
mov    -0x4(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     11af <usb_interrupt_handler+0x6f>
mov    $0xffffdfff,%edi
call   1030 <st103_set_istr@plt>
mov    -0x4(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     11c8 <usb_interrupt_handler+0x88>
mov    -0x4(%rbp),%edi
call   1060 <usb_handle_transfer@plt>
jmp    11cd <usb_interrupt_handler+0x8d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_interrupt_handler>:
push   %rbx
xor    %eax,%eax
call   1050 <st103_get_istr@plt>
test   $0x400,%eax
jne    116a <usb_interrupt_handler+0x2a>
mov    %eax,%ebx
test   $0x4000,%eax
jne    117c <usb_interrupt_handler+0x3c>
test   $0x2000,%ebx
jne    118e <usb_interrupt_handler+0x4e>
test   $0x8000,%ebx
jne    11a0 <usb_interrupt_handler+0x60>
pop    %rbx
ret
mov    $0xfffffbff,%edi
call   1030 <st103_set_istr@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <usb_cb_device_reset@plt>
mov    $0xffffbfff,%edi
call   1030 <st103_set_istr@plt>
test   $0x2000,%ebx
je     1160 <usb_interrupt_handler+0x20>
mov    $0xffffdfff,%edi
call   1030 <st103_set_istr@plt>
test   $0x8000,%ebx
je     1168 <usb_interrupt_handler+0x28>
mov    %ebx,%edi
pop    %rbx
jmp    1060 <usb_handle_transfer@plt>

LLVM IR (-O0):
define void @usb_interrupt_handler() {
%1 = alloca i32
%2 = call i32 (...) @st103_get_istr()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = and i32 %3, 1024
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @st103_set_istr(i32 -1025)
%8 = call i32 (...) @usb_cb_device_reset()
br label %29
9: ; preds = %0
%10 = load i32, i32* %1
%11 = and i32 %10, 16384
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @st103_set_istr(i32 -16385)
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %1
%17 = and i32 %16, 8192
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @st103_set_istr(i32 -8193)
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %1
%23 = and i32 %22, 32768
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %1
%27 = call i32 @usb_handle_transfer(i32 %26)
br label %28
28: ; preds = %25, %21
br label %29
29: ; preds = %28, %6
ret void
}

LLVM IR (-O2):
define void @usb_interrupt_handler() {
%1 = tail call i32 (...) @st103_get_istr()
%2 = and i32 %1, 1024
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i32 @st103_set_istr(i32 -1025)
%6 = tail call i32 (...) @usb_cb_device_reset()
br label %22
7: ; preds = %0
%8 = and i32 %1, 16384
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @st103_set_istr(i32 -16385)
br label %12
12: ; preds = %10, %7
%13 = and i32 %1, 8192
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @st103_set_istr(i32 -8193)
br label %17
17: ; preds = %15, %12
%18 = and i32 %1, 32768
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @usb_handle_transfer(i32 %1)
br label %22
22: ; preds = %17, %20, %4
ret void
}