#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 */
void USBHostEndpointSpeed(uint32_t ui32Base, uint32_t ui32Endpoint,
                          uint32_t ui32Flags) {
  uint32_t ui32Reg;
  uint32_t ui32Speed;
  ;

  ;
  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
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     112a <USBHostEndpointSpeed+0x2a>
movl   $0x40,-0x14(%rbp)
jmp    1153 <USBHostEndpointSpeed+0x53>
mov    -0xc(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1147 <USBHostEndpointSpeed+0x47>
movl   $0x80,-0x14(%rbp)
jmp    114e <USBHostEndpointSpeed+0x4e>
movl   $0xc0,-0x14(%rbp)
jmp    1153 <USBHostEndpointSpeed+0x53>
cmpl   $0x0,-0x8(%rbp)
jne    1171 <USBHostEndpointSpeed+0x71>
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
mov    %ecx,(%rax)
jmp    120c <USBHostEndpointSpeed+0x10c>
mov    -0xc(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     11c7 <USBHostEndpointSpeed+0xc7>
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    1207 <USBHostEndpointSpeed+0x107>
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    120c <USBHostEndpointSpeed+0x10c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostEndpointSpeed>:
xor    %ecx,%ecx
test   $0x1000,%edx
sete   %cl
or     $0x2,%ecx
shl    $0x6,%ecx
test   $0x4000,%edx
mov    $0x40,%eax
cmove  %ecx,%eax
test   %esi,%esi
je     1135 <USBHostEndpointSpeed+0x35>
add    %edi,%esi
test   $0x2000,%edx
jne    113f <USBHostEndpointSpeed+0x3f>
add    $0x10c,%esi
jmp    1145 <USBHostEndpointSpeed+0x45>
movslq %edi,%rcx
mov    %eax,0x10a(%rcx)
ret
add    $0x10a,%esi
movslq %esi,%rcx
mov    $0xffffff3f,%edx
and    (%rcx),%edx
or     %eax,%edx
or     %edx,(%rcx)
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* %6
%10 = and i32 %9, 16384
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 64, i32* %8
br label %20
13: ; preds = %3
%14 = load i32, i32* %6
%15 = and i32 %14, 4096
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 128, i32* %8
br label %19
18: ; preds = %13
store i32 192, i32* %8
br label %19
19: ; preds = %18, %17
br label %20
20: ; preds = %19, %12
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 266
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i32*
store volatile i32 %24, i32* %28
br label %80
29: ; preds = %20
%30 = load i32, i32* %6
%31 = and i32 %30, 8192
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %56
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 16
%37 = add nsw i32 %34, %36
%38 = add nsw i32 %37, 282
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
%41 = load volatile i32, i32* %40
%42 = and i32 %41, -193
store i32 %42, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %7
%45 = or i32 %44, %43
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = load i32, i32* %4
%48 = load i32, i32* %5
%49 = sub nsw i32 %48, 16
%50 = add nsw i32 %47, %49
%51 = add nsw i32 %50, 282
%52 = sext i32 %51 to i64
%53 = inttoptr i64 %52 to i32*
%54 = load volatile i32, i32* %53
%55 = or i32 %54, %46
store volatile i32 %55, i32* %53
br label %79
56: ; preds = %29
%57 = load i32, i32* %4
%58 = load i32, i32* %5
%59 = sub nsw i32 %58, 16
%60 = add nsw i32 %57, %59
%61 = add nsw i32 %60, 284
%62 = sext i32 %61 to i64
%63 = inttoptr i64 %62 to i32*
%64 = load volatile i32, i32* %63
%65 = and i32 %64, -193
store i32 %65, i32* %7
%66 = load i32, i32* %8
%67 = load i32, i32* %7
%68 = or i32 %67, %66
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = sub nsw i32 %71, 16
%73 = add nsw i32 %70, %72
%74 = add nsw i32 %73, 284
%75 = sext i32 %74 to i64
%76 = inttoptr i64 %75 to i32*
%77 = load volatile i32, i32* %76
%78 = or i32 %77, %69
store volatile i32 %78, i32* %76
br label %79
79: ; preds = %56, %33
br label %80
80: ; preds = %79, %23
ret void
}

LLVM IR (-O2):
define void @USBHostEndpointSpeed(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %2, 16384
%5 = icmp eq i32 %4, 0
%6 = and i32 %2, 4096
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 192, i32 128
%9 = select i1 %5, i32 %8, i32 64
%10 = icmp eq i32 %1, 0
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = add nsw i32 %0, 266
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
store volatile i32 %9, i32* %14
br label %37
15: ; preds = %3
%16 = and i32 %2, 8192
%17 = icmp eq i32 %16, 0
%18 = add i32 %1, %0
br i1 %17, label %28, label %19
19: ; preds = %15
%20 = add i32 %18, 266
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = load volatile i32, i32* %22
%24 = and i32 %23, -193
%25 = or i32 %24, %9
%26 = load volatile i32, i32* %22
%27 = or i32 %25, %26
store volatile i32 %27, i32* %22
br label %37
28: ; preds = %15
%29 = add i32 %18, 268
%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, %9
%35 = load volatile i32, i32* %31
%36 = or i32 %34, %35
store volatile i32 %36, i32* %31
br label %37
37: ; preds = %19, %28, %11
ret void
}