#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 USBHostHubAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint,
                       uint32_t ui32Addr, uint32_t ui32Flags) {
  ;

  ;
  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
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     113d <USBHostHubAddrSet+0x3d>
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    1157 <USBHostHubAddrSet+0x57>
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    11c7 <USBHostHubAddrSet+0xc7>
mov    -0x10(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1187 <USBHostHubAddrSet+0x87>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0x80,(%rax)
jmp    11c2 <USBHostHubAddrSet+0xc2>
mov    -0x10(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     11ad <USBHostHubAddrSet+0xad>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0x40,(%rax)
jmp    11bd <USBHostHubAddrSet+0xbd>
mov    -0x4(%rbp),%eax
add    $0x10a,%eax
cltq
movl   $0xc0,(%rax)
jmp    11c2 <USBHostHubAddrSet+0xc2>
jmp    11c7 <USBHostHubAddrSet+0xc7>
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostHubAddrSet>:
xor    %eax,%eax
test   $0x2000,%ecx
sete   %al
lea    (%rdi,%rax,4),%r8d
add    $0x82,%r8d
mov    %esi,%eax
sar    %eax
movslq %r8d,%r8
cltq
mov    %edx,(%r8,%rax,1)
test   %esi,%esi
je     1128 <USBHostHubAddrSet+0x28>
ret
movslq %edi,%rax
test   $0x1000,%ecx
jne    1146 <USBHostHubAddrSet+0x46>
test   $0x4000,%ecx
jne    1151 <USBHostHubAddrSet+0x51>
movl   $0xc0,0x10a(%rax)
ret
movl   $0x80,0x10a(%rax)
ret
movl   $0x40,0x10a(%rax)
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* %8
%10 = and i32 %9, 8192
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %4
%13 = load i32, i32* %7
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 130
%16 = load i32, i32* %6
%17 = ashr i32 %16, 1
%18 = add nsw i32 %15, %17
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
store volatile i32 %13, i32* %20
br label %31
21: ; preds = %4
%22 = load i32, i32* %7
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 130
%25 = add nsw i32 %24, 4
%26 = load i32, i32* %6
%27 = ashr i32 %26, 1
%28 = add nsw i32 %25, %27
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
store volatile i32 %22, i32* %30
br label %31
31: ; preds = %21, %12
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %59
34: ; preds = %31
%35 = load i32, i32* %8
%36 = and i32 %35, 4096
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 266
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i32*
store volatile i32 128, i32* %42
br label %58
43: ; preds = %34
%44 = load i32, i32* %8
%45 = and i32 %44, 16384
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 266
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i32*
store volatile i32 64, i32* %51
br label %57
52: ; preds = %43
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 266
%55 = sext i32 %54 to i64
%56 = inttoptr i64 %55 to i32*
store volatile i32 192, i32* %56
br label %57
57: ; preds = %52, %47
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %31
ret void
}

LLVM IR (-O2):
define void @USBHostHubAddrSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = and i32 %3, 8192
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 134, i32 130
%8 = add nsw i32 %7, %0
%9 = ashr i32 %1, 1
%10 = add nsw i32 %8, %9
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
store volatile i32 %2, i32* %12
%13 = icmp eq i32 %1, 0
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = and i32 %3, 4096
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = add nsw i32 %0, 266
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
store volatile i32 128, i32* %20
br label %29
21: ; preds = %14
%22 = and i32 %3, 16384
%23 = icmp eq i32 %22, 0
%24 = add nsw i32 %0, 266
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
br i1 %23, label %28, label %27
27: ; preds = %21
store volatile i32 64, i32* %26
br label %29
28: ; preds = %21
store volatile i32 192, i32* %26
br label %29
29: ; preds = %17, %28, %27, %4
ret void
}