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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void USBHostHubAddrSet(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 uint16_t *)(ui32Base + 0x00000082 + (ui32Endpoint >> 1)))) =
        ui32Addr;
  } else {
    (*((volatile uint16_t *)(ui32Base + 0x00000082 + 4 +
                             (ui32Endpoint >> 1)))) = ui32Addr;
  }
  if (ui32Endpoint == 0x00000000) {
    if (ui32Flags & 0x00001000) {
      (*((volatile uint8_t *)(ui32Base + 0x0000010A))) = 0x00000080;
    } else if (ui32Flags & 0x00004000) {
      (*((volatile uint8_t *)(ui32Base + 0x0000010A))) = 0x00000040;
    } else {
      (*((volatile uint8_t *)(ui32Base + 0x0000010A))) = 0x000000C0;
    }
  }
}


x86 assembly (clang, -O0):
<USBHostHubAddrSet>:
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 <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x10,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x20,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x30,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x40,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x50,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+0x9b>
mov    $0x1,%al
cmpl   $0x60,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     11ab <USBHostHubAddrSet+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 <USBHostHubAddrSet+0xd5>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x82,%eax
mov    -0x8(%rbp),%edx
sar    $0x1,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
jmp    11ff <USBHostHubAddrSet+0xef>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x82,%eax
add    $0x4,%eax
mov    -0x8(%rbp),%edx
sar    $0x1,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
cmpl   $0x0,-0x8(%rbp)
jne    126f <USBHostHubAddrSet+0x15f>
mov    -0x10(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     122f <USBHostHubAddrSet+0x11f>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0x80,(%rax)
jmp    126a <USBHostHubAddrSet+0x15a>
mov    -0x10(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1255 <USBHostHubAddrSet+0x145>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0x40,(%rax)
jmp    1265 <USBHostHubAddrSet+0x155>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0xc0,(%rax)
jmp    126a <USBHostHubAddrSet+0x15a>
jmp    126f <USBHostHubAddrSet+0x15f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostHubAddrSet>:
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
mov    %ebp,%ecx
sar    %ecx
lea    (%rbx,%rax,4),%eax
add    $0x82,%eax
cltq
movslq %ecx,%rcx
mov    %r14d,(%rax,%rcx,1)
test   %ebp,%ebp
jne    11a9 <USBHostHubAddrSet+0x99>
movslq %ebx,%rax
test   $0x1000,%r15d
jne    1193 <USBHostHubAddrSet+0x83>
test   $0x4000,%r15d
jne    119f <USBHostHubAddrSet+0x8f>
movl   $0xc0,0x10a(%rax)
jmp    11a9 <USBHostHubAddrSet+0x99>
movl   $0x80,0x10a(%rax)
jmp    11a9 <USBHostHubAddrSet+0x99>
movl   $0x40,0x10a(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @USBHostHubAddrSet(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, 130
%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, 130
%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
%63 = load i32, i32* %6
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %90
65: ; preds = %62
%66 = load i32, i32* %8
%67 = and i32 %66, 4096
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %65
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 266
%72 = sext i32 %71 to i64
%73 = inttoptr i64 %72 to i32*
store volatile i32 128, i32* %73
br label %89
74: ; preds = %65
%75 = load i32, i32* %8
%76 = and i32 %75, 16384
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 266
%81 = sext i32 %80 to i64
%82 = inttoptr i64 %81 to i32*
store volatile i32 64, i32* %82
br label %88
83: ; preds = %74
%84 = load i32, i32* %5
%85 = add nsw i32 %84, 266
%86 = sext i32 %85 to i64
%87 = inttoptr i64 %86 to i32*
store volatile i32 192, i32* %87
br label %88
88: ; preds = %83, %78
br label %89
89: ; preds = %88, %69
br label %90
90: ; preds = %89, %62
ret void
}

LLVM IR (-O2):
define void @USBHostHubAddrSet(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 = icmp eq i32 %1, 0
%9 = tail call i32 @llvm.fshl.i32(i32 %1, i32 %1, i32 28)
%10 = icmp ult i32 %9, 7
%11 = icmp eq i32 %1, 112
%12 = or i1 %11, %10
%13 = zext i1 %12 to i32
%14 = tail call i32 @ASSERT(i32 %13)
%15 = and i32 %3, 8192
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 134, i32 130
%18 = add nsw i32 %17, %0
%19 = ashr i32 %1, 1
%20 = add nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
store volatile i32 %2, i32* %22
br i1 %8, label %23, label %38
23: ; preds = %4
%24 = and i32 %3, 4096
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = add nsw i32 %0, 266
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store volatile i32 128, i32* %29
br label %38
30: ; preds = %23
%31 = and i32 %3, 16384
%32 = icmp eq i32 %31, 0
%33 = add nsw i32 %0, 266
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i32*
br i1 %32, label %37, label %36
36: ; preds = %30
store volatile i32 64, i32* %35
br label %38
37: ; preds = %30
store volatile i32 192, i32* %35
br label %38
38: ; preds = %26, %37, %36, %4
ret void
}