#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void USBHostAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Addr,
                    uint32_t ui32Flags) {
  ASSERT(ui32Base == 0x40050000);
  ASSERT((ui32Endpoint == 0x00000000) || (ui32Endpoint == 0x00000010) ||
         (ui32Endpoint == 0x00000020) || (ui32Endpoint == 0x00000030) ||
         (ui32Endpoint == 0x00000040) || (ui32Endpoint == 0x00000050) ||
         (ui32Endpoint == 0x00000060) || (ui32Endpoint == 0x00000070));
  if (ui32Flags & 0x00002000) {
    (*((volatile uint8_t *)(ui32Base + 0x00000080 + (ui32Endpoint >> 1)))) =
        ui32Addr;
  } else {
    (*((volatile uint8_t *)(ui32Base + 0x00000080 + 4 + (ui32Endpoint >> 1)))) =
        ui32Addr;
  }
}


x86 assembly (clang, -O0):
<USBHostAddrSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x40050000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x10,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x20,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x30,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x40,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x50,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x60,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostAddrSet+0x9b>
cmpl   $0x70,-0x8(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x10(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     11e5 <USBHostAddrSet+0xd5>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x80,%eax
mov    -0x8(%rbp),%edx
sar    $0x1,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
jmp    11ff <USBHostAddrSet+0xef>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x80,%eax
add    $0x4,%eax
mov    -0x8(%rbp),%edx
sar    $0x1,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostAddrSet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x40050000,%ebx
sete   %dil
call   1030 <ASSERT@plt>
mov    %ebp,%eax
rol    $0x1c,%eax
cmp    $0x7,%eax
setb   %al
cmp    $0x70,%ebp
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1030 <ASSERT@plt>
xor    %eax,%eax
test   $0x2000,%r15d
sete   %al
lea    (%rbx,%rax,4),%eax
add    $0x80,%eax
sar    %ebp
cltq
movslq %ebp,%rcx
mov    %r14d,(%rax,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @USBHostAddrSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1074069504
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %36, label %15
15: ; preds = %4
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 16
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 32
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 48
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 64
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 80
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 96
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 112
br label %36
36: ; preds = %33, %30, %27, %24, %21, %18, %15, %4
%37 = phi i1 [ true, %30 ], [ true, %27 ], [ true, %24 ], [ true, %21 ], [ true, %18 ], [ true, %15 ], [ true, %4 ], [ %35, %33 ]
%38 = zext i1 %37 to i32
%39 = call i32 @ASSERT(i32 %38)
%40 = load i32, i32* %8
%41 = and i32 %40, 8192
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %36
%44 = load i32, i32* %7
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 128
%47 = load i32, i32* %6
%48 = ashr i32 %47, 1
%49 = add nsw i32 %46, %48
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i32*
store volatile i32 %44, i32* %51
br label %62
52: ; preds = %36
%53 = load i32, i32* %7
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 128
%56 = add nsw i32 %55, 4
%57 = load i32, i32* %6
%58 = ashr i32 %57, 1
%59 = add nsw i32 %56, %58
%60 = sext i32 %59 to i64
%61 = inttoptr i64 %60 to i32*
store volatile i32 %53, i32* %61
br label %62
62: ; preds = %52, %43
ret void
}

LLVM IR (-O2):
define void @USBHostAddrSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %0, 1074069504
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 28)
%9 = icmp ult i32 %8, 7
%10 = icmp eq i32 %1, 112
%11 = or i1 %10, %9
%12 = zext i1 %11 to i32
%13 = tail call i32 @ASSERT(i32 %12)
%14 = and i32 %3, 8192
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 132, i32 128
%17 = add nsw i32 %16, %0
%18 = ashr i32 %1, 1
%19 = add nsw i32 %17, %18
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
store volatile i32 %2, i32* %21
ret void
}