#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;
typedef int uint16_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 uint16_t *)(ui32Base + ui32Register))) & 0x00000001) == 0) {
    return (0);
  }
  return ((*((volatile uint16_t *)(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),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1150 <USBEndpointDataAvail+0x50>
movl   $0x0,-0x4(%rbp)
jmp    1162 <USBEndpointDataAvail+0x62>
mov    -0x8(%rbp),%eax
add    $0x108,%eax
add    -0xc(%rbp),%eax
cltq
mov    (%rax),%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,%rdx
movslq %edi,%rcx
xor    %eax,%eax
testl  $0x1,(%rdx,%rcx,1)
je     112b <USBEndpointDataAvail+0x2b>
movslq %esi,%rax
mov    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 i32*
%20 = load volatile i32, i32* %19
%21 = and i32 %20, 1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %14
store i32 0, i32* %3
br label %32
24: ; preds = %14
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 264
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
%31 = load volatile i32, i32* %30
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %23
%33 = load i32, i32* %3
ret i32 %33
}

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 i32*
%9 = load volatile i32, i32* %8
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, 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 i32*
%17 = load volatile i32, i32* %16
br label %18
18: ; preds = %2, %12
%19 = phi i32 [ %17, %12 ], [ 0, %2 ]
ret i32 %19
}