#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 USBHostEndpointSpeed(uint32_t ui32Base, uint32_t ui32Endpoint,
                          uint32_t ui32Flags) {
  uint32_t ui32Reg;
  uint32_t ui32Speed;
  ASSERT(ui32Base == 0x40050000);
  ASSERT((ui32Endpoint == 0x00000000) || (ui32Endpoint == 0x00000010) ||
         (ui32Endpoint == 0x00000020) || (ui32Endpoint == 0x00000030) ||
         (ui32Endpoint == 0x00000040) || (ui32Endpoint == 0x00000050) ||
         (ui32Endpoint == 0x00000060) || (ui32Endpoint == 0x00000070));
  if (ui32Flags & 0x00004000) {
    ui32Speed = 0x00000040;
  } else if (ui32Flags & 0x00001000) {
    ui32Speed = 0x00000080;
  } else {
    ui32Speed = 0x000000C0;
  }
  if (ui32Endpoint == 0x00000000) {
    (*((volatile uint8_t *)(ui32Base + 0x0000010A))) = ui32Speed;
  } else if (ui32Flags & 0x00002000) {
    ui32Reg = ((*((volatile uint16_t *)(ui32Base + (ui32Endpoint - 0x10) +
                                        0x0000011A))) &
               ~(0x000000C0));
    ui32Reg |= ui32Speed;
    (*((volatile uint16_t *)(ui32Base + (ui32Endpoint - 0x10) + 0x0000011A))) |=
        ui32Reg;
  } else {
    ui32Reg = ((*((volatile uint16_t *)(ui32Base + (ui32Endpoint - 0x10) +
                                        0x0000011C))) &
               ~(0x000000C0));
    ui32Reg |= ui32Speed;
    (*((volatile uint16_t *)(ui32Base + (ui32Endpoint - 0x10) + 0x0000011C))) |=
        ui32Reg;
  }
}


x86 assembly (clang, -O0):
<USBHostEndpointSpeed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%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,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x10,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x20,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x30,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x40,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x50,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
mov    $0x1,%al
cmpl   $0x60,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a8 <USBHostEndpointSpeed+0x98>
cmpl   $0x70,-0x8(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0xc(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     11d2 <USBHostEndpointSpeed+0xc2>
movl   $0x40,-0x14(%rbp)
jmp    11fb <USBHostEndpointSpeed+0xeb>
mov    -0xc(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     11ef <USBHostEndpointSpeed+0xdf>
movl   $0x80,-0x14(%rbp)
jmp    11f6 <USBHostEndpointSpeed+0xe6>
movl   $0xc0,-0x14(%rbp)
jmp    11fb <USBHostEndpointSpeed+0xeb>
cmpl   $0x0,-0x8(%rbp)
jne    1219 <USBHostEndpointSpeed+0x109>
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
mov    %ecx,(%rax)
jmp    12b4 <USBHostEndpointSpeed+0x1a4>
mov    -0xc(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     126f <USBHostEndpointSpeed+0x15f>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
add    $0x11a,%eax
cltq
mov    (%rax),%eax
and    $0xffffff3f,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
add    $0x11a,%eax
cltq
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
jmp    12af <USBHostEndpointSpeed+0x19f>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
add    $0x11c,%eax
cltq
mov    (%rax),%eax
and    $0xffffff3f,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
add    $0x11c,%eax
cltq
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
jmp    12b4 <USBHostEndpointSpeed+0x1a4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostEndpointSpeed>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r14d
xor    %edi,%edi
cmp    $0x40050000,%r14d
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>
xor    %ecx,%ecx
test   $0x1000,%ebp
sete   %cl
or     $0x2,%ecx
shl    $0x6,%ecx
test   $0x4000,%ebp
mov    $0x40,%eax
cmove  %ecx,%eax
test   %ebx,%ebx
je     117e <USBHostEndpointSpeed+0x6e>
add    %r14d,%ebx
test   $0x2000,%ebp
jne    1189 <USBHostEndpointSpeed+0x79>
add    $0x10c,%ebx
jmp    118f <USBHostEndpointSpeed+0x7f>
movslq %r14d,%rcx
mov    %eax,0x10a(%rcx)
jmp    119d <USBHostEndpointSpeed+0x8d>
add    $0x10a,%ebx
movslq %ebx,%rcx
mov    $0xffffff3f,%edx
and    (%rcx),%edx
or     %eax,%edx
or     %edx,(%rcx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @USBHostEndpointSpeed(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1074069504
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %36, label %15
15: ; preds = %3
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 16
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 32
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 48
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 64
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 80
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 96
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 112
br label %36
36: ; preds = %33, %30, %27, %24, %21, %18, %15, %3
%37 = phi i1 [ true, %30 ], [ true, %27 ], [ true, %24 ], [ true, %21 ], [ true, %18 ], [ true, %15 ], [ true, %3 ], [ %35, %33 ]
%38 = zext i1 %37 to i32
%39 = call i32 @ASSERT(i32 %38)
%40 = load i32, i32* %6
%41 = and i32 %40, 16384
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %36
store i32 64, i32* %8
br label %51
44: ; preds = %36
%45 = load i32, i32* %6
%46 = and i32 %45, 4096
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 128, i32* %8
br label %50
49: ; preds = %44
store i32 192, i32* %8
br label %50
50: ; preds = %49, %48
br label %51
51: ; preds = %50, %43
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i32, i32* %8
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 266
%58 = sext i32 %57 to i64
%59 = inttoptr i64 %58 to i32*
store volatile i32 %55, i32* %59
br label %111
60: ; preds = %51
%61 = load i32, i32* %6
%62 = and i32 %61, 8192
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %87
64: ; preds = %60
%65 = load i32, i32* %4
%66 = load i32, i32* %5
%67 = sub nsw i32 %66, 16
%68 = add nsw i32 %65, %67
%69 = add nsw i32 %68, 282
%70 = sext i32 %69 to i64
%71 = inttoptr i64 %70 to i32*
%72 = load volatile i32, i32* %71
%73 = and i32 %72, -193
store i32 %73, i32* %7
%74 = load i32, i32* %8
%75 = load i32, i32* %7
%76 = or i32 %75, %74
store i32 %76, i32* %7
%77 = load i32, i32* %7
%78 = load i32, i32* %4
%79 = load i32, i32* %5
%80 = sub nsw i32 %79, 16
%81 = add nsw i32 %78, %80
%82 = add nsw i32 %81, 282
%83 = sext i32 %82 to i64
%84 = inttoptr i64 %83 to i32*
%85 = load volatile i32, i32* %84
%86 = or i32 %85, %77
store volatile i32 %86, i32* %84
br label %110
87: ; preds = %60
%88 = load i32, i32* %4
%89 = load i32, i32* %5
%90 = sub nsw i32 %89, 16
%91 = add nsw i32 %88, %90
%92 = add nsw i32 %91, 284
%93 = sext i32 %92 to i64
%94 = inttoptr i64 %93 to i32*
%95 = load volatile i32, i32* %94
%96 = and i32 %95, -193
store i32 %96, i32* %7
%97 = load i32, i32* %8
%98 = load i32, i32* %7
%99 = or i32 %98, %97
store i32 %99, i32* %7
%100 = load i32, i32* %7
%101 = load i32, i32* %4
%102 = load i32, i32* %5
%103 = sub nsw i32 %102, 16
%104 = add nsw i32 %101, %103
%105 = add nsw i32 %104, 284
%106 = sext i32 %105 to i64
%107 = inttoptr i64 %106 to i32*
%108 = load volatile i32, i32* %107
%109 = or i32 %108, %100
store volatile i32 %109, i32* %107
br label %110
110: ; preds = %87, %64
br label %111
111: ; preds = %110, %54
ret void
}

LLVM IR (-O2):
define void @USBHostEndpointSpeed(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %0, 1074069504
%5 = zext i1 %4 to i32
%6 = tail call i32 @ASSERT(i32 %5)
%7 = icmp eq i32 %1, 0
%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 %2, 16384
%15 = icmp eq i32 %14, 0
%16 = and i32 %2, 4096
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 192, i32 128
%19 = select i1 %15, i32 %18, i32 64
br i1 %7, label %20, label %24
20: ; preds = %3
%21 = add nsw i32 %0, 266
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
store volatile i32 %19, i32* %23
br label %46
24: ; preds = %3
%25 = and i32 %2, 8192
%26 = icmp eq i32 %25, 0
%27 = add i32 %1, %0
br i1 %26, label %37, label %28
28: ; preds = %24
%29 = add i32 %27, 266
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
%32 = load volatile i32, i32* %31
%33 = and i32 %32, -193
%34 = or i32 %33, %19
%35 = load volatile i32, i32* %31
%36 = or i32 %34, %35
store volatile i32 %36, i32* %31
br label %46
37: ; preds = %24
%38 = add i32 %27, 268
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
%41 = load volatile i32, i32* %40
%42 = and i32 %41, -193
%43 = or i32 %42, %19
%44 = load volatile i32, i32* %40
%45 = or i32 %43, %44
store volatile i32 %45, i32* %40
br label %46
46: ; preds = %28, %37, %20
ret void
}