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

/* Variables and functions */
uint32_t USBEndpointDataAvail(uint32_t ui32Base, uint32_t ui32Endpoint) {
  uint32_t ui32Register;
  ;

  ;
  if (ui32Endpoint == 0x00000000) {
    ui32Register = 0x00000102;
  } else {
    ui32Register = 0x00000116 + (ui32Endpoint - 0x10);
  }
  if (((*((volatile unsigned short *)(ui32Base + ui32Register))) &
       0x00000001) == 0) {
    return (0);
  }
  return (
      (*((volatile unsigned short *)(ui32Base + 0x00000108 + ui32Endpoint))));
}


x86 assembly (clang, -O0):
<USBEndpointDataAvail>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1120 <USBEndpointDataAvail+0x20>
movl   $0x102,-0x10(%rbp)
jmp    112e <USBEndpointDataAvail+0x2e>
mov    -0xc(%rbp),%eax
sub    $0x10,%eax
add    $0x116,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
cltq
mov    (%rax),%ax
movzwl %ax,%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1154 <USBEndpointDataAvail+0x54>
movl   $0x0,-0x4(%rbp)
jmp    116a <USBEndpointDataAvail+0x6a>
mov    -0x8(%rbp),%eax
add    $0x108,%eax
add    -0xc(%rbp),%eax
cltq
mov    (%rax),%ax
movzwl %ax,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBEndpointDataAvail>:
lea    0x106(%rsi),%eax
test   %esi,%esi
mov    $0x102,%ecx
cmovne %eax,%ecx
movslq %ecx,%rax
movslq %edi,%rcx
movzwl (%rax,%rcx,1),%edx
xor    %eax,%eax
test   $0x1,%dl
je     112c <USBEndpointDataAvail+0x2c>
movslq %esi,%rax
movzwl 0x108(%rcx,%rax,1),%eax
ret

LLVM IR (-O0):
define i32 @USBEndpointDataAvail(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 258, i32* %6
br label %14
10: ; preds = %2
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 16
%13 = add nsw i32 278, %12
store i32 %13, i32* %6
br label %14
14: ; preds = %10, %9
%15 = load i32, i32* %4
%16 = load i32, i32* %6
%17 = add nsw i32 %15, %16
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i16*
%20 = load volatile i16, i16* %19
%21 = zext i16 %20 to i32
%22 = and i32 %21, 1
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %14
store i32 0, i32* %3
br label %34
25: ; preds = %14
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 264
%28 = load i32, i32* %5
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i16*
%32 = load volatile i16, i16* %31
%33 = zext i16 %32 to i32
store i32 %33, i32* %3
br label %34
34: ; preds = %25, %24
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @USBEndpointDataAvail(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = add nsw i32 %1, 262
%5 = select i1 %3, i32 258, i32 %4
%6 = add nsw i32 %5, %0
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i16*
%9 = load volatile i16, i16* %8
%10 = and i16 %9, 1
%11 = icmp eq i16 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = add nsw i32 %0, 264
%14 = add nsw i32 %13, %1
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i16*
%17 = load volatile i16, i16* %16
%18 = zext i16 %17 to i32
br label %19
19: ; preds = %2, %12
%20 = phi i32 [ %18, %12 ], [ 0, %2 ]
ret i32 %20
}