#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 */
int /*<<< orphan*/ ASSERT(int);
uint32_t USBEndpointDataAvail(uint32_t ui32Base, uint32_t ui32Endpoint) {
  uint32_t ui32Register;
  ASSERT(ui32Base == 0x40050000);
  ASSERT((ui32Endpoint == 0x00000000) || (ui32Endpoint == 0x00000010) ||
         (ui32Endpoint == 0x00000020) || (ui32Endpoint == 0x00000030) ||
         (ui32Endpoint == 0x00000040) || (ui32Endpoint == 0x00000050) ||
         (ui32Endpoint == 0x00000060) || (ui32Endpoint == 0x00000070));
  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
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x40050000,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x10,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x20,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x30,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x40,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x50,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
mov    $0x1,%al
cmpl   $0x60,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11a5 <USBEndpointDataAvail+0x95>
cmpl   $0x70,-0xc(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c8 <USBEndpointDataAvail+0xb8>
movl   $0x102,-0x10(%rbp)
jmp    11d6 <USBEndpointDataAvail+0xc6>
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    11f8 <USBEndpointDataAvail+0xe8>
movl   $0x0,-0x4(%rbp)
jmp    120a <USBEndpointDataAvail+0xfa>
mov    -0x8(%rbp),%eax
add    $0x108,%eax
add    -0xc(%rbp),%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBEndpointDataAvail>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x40050000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
mov    %ebx,%eax
rol    $0x1c,%eax
cmp    $0x7,%eax
setb   %al
cmp    $0x70,%ebx
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1030 <ASSERT@plt>
lea    0x106(%rbx),%eax
test   %ebx,%ebx
mov    $0x102,%ecx
cmovne %eax,%ecx
movslq %ecx,%rdx
movslq %ebp,%rcx
xor    %eax,%eax
testl  $0x1,(%rdx,%rcx,1)
je     116e <USBEndpointDataAvail+0x5e>
movslq %ebx,%rax
mov    0x108(%rcx,%rax,1),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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* %4
%8 = icmp eq i32 %7, 1074069504
%9 = zext i1 %8 to i32
%10 = call i32 @ASSERT(i32 %9)
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 16
br i1 %15, label %34, label %16
16: ; preds = %13
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 32
br i1 %18, label %34, label %19
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 48
br i1 %21, label %34, label %22
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 64
br i1 %24, label %34, label %25
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 80
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 96
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 112
br label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %2
%35 = phi i1 [ true, %28 ], [ true, %25 ], [ true, %22 ], [ true, %19 ], [ true, %16 ], [ true, %13 ], [ true, %2 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
%37 = call i32 @ASSERT(i32 %36)
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 258, i32* %6
br label %45
41: ; preds = %34
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 16
%44 = add nsw i32 278, %43
store i32 %44, i32* %6
br label %45
45: ; preds = %41, %40
%46 = load i32, i32* %4
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
%51 = load volatile i32, i32* %50
%52 = and i32 %51, 1
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %45
store i32 0, i32* %3
br label %63
55: ; preds = %45
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 264
%58 = load i32, i32* %5
%59 = add nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = inttoptr i64 %60 to i32*
%62 = load volatile i32, i32* %61
store i32 %62, i32* %3
br label %63
63: ; preds = %55, %54
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
define i32 @USBEndpointDataAvail(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 1074069504
%4 = zext i1 %3 to i32
%5 = tail call i32 @ASSERT(i32 %4)
%6 = icmp eq i32 %1, 0
%7 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 28)
%8 = icmp ult i32 %7, 7
%9 = icmp eq i32 %1, 112
%10 = or i1 %9, %8
%11 = zext i1 %10 to i32
%12 = tail call i32 @ASSERT(i32 %11)
%13 = add nsw i32 %1, 262
%14 = select i1 %6, i32 258, i32 %13
%15 = add nsw i32 %14, %0
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
%18 = load volatile i32, i32* %17
%19 = and i32 %18, 1
%20 = icmp eq i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %2
%22 = add nsw i32 %0, 264
%23 = add nsw i32 %22, %1
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
%26 = load volatile i32, i32* %25
br label %27
27: ; preds = %2, %21
%28 = phi i32 [ %26, %21 ], [ 0, %2 ]
ret i32 %28
}