#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 _USBIndexWrite(uint32_t ui32Base, uint32_t ui32Endpoint,
                    uint32_t ui32IndexedReg, uint32_t ui32Value,
                    uint32_t ui32Size) {
  uint32_t ui32Index;
  ASSERT(ui32Base == 0x40050000);
  ASSERT((ui32Endpoint == 0) || (ui32Endpoint == 1) || (ui32Endpoint == 2) ||
         (ui32Endpoint == 3));
  ASSERT((ui32Size == 1) || (ui32Size == 2));
  ui32Index = (*((volatile uint8_t *)(ui32Base + 0x0000000E)));
  (*((volatile uint8_t *)(ui32Base + 0x0000000E))) = ui32Endpoint;
  if (ui32Size == 1) {
    (*((volatile uint8_t *)(ui32Base + ui32IndexedReg))) = ui32Value;
  } else {
    (*((volatile uint16_t *)(ui32Base + ui32IndexedReg))) = ui32Value;
  }
  (*((volatile uint8_t *)(ui32Base + 0x0000000E))) = ui32Index;
}


x86 assembly (clang, -O0):
<_USBIndexWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%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,-0x19(%rbp)
je     1173 <_USBIndexWrite+0x63>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x19(%rbp)
je     1173 <_USBIndexWrite+0x63>
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x19(%rbp)
je     1173 <_USBIndexWrite+0x63>
cmpl   $0x3,-0x8(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x1a(%rbp)
je     1199 <_USBIndexWrite+0x89>
cmpl   $0x2,-0x14(%rbp)
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x4(%rbp),%eax
add    $0xe,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xe,%eax
cltq
mov    %ecx,(%rax)
cmpl   $0x1,-0x14(%rbp)
jne    11dc <_USBIndexWrite+0xcc>
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
cltq
mov    %ecx,(%rax)
jmp    11e9 <_USBIndexWrite+0xd9>
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
cltq
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xe,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_USBIndexWrite>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x40050000,%ebx
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x4,%r12d
setb   %dil
call   1030 <ASSERT@plt>
add    $0xffffffff,%ebp
xor    %edi,%edi
cmp    $0x2,%ebp
setb   %dil
call   1030 <ASSERT@plt>
movslq %ebx,%rax
mov    0xe(%rax),%ecx
mov    %r12d,0xe(%rax)
movslq %r15d,%rdx
mov    %r14d,(%rdx,%rax,1)
mov    %ecx,0xe(%rax)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @_USBIndexWrite(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %0, 1074069504
%7 = zext i1 %6 to i32
%8 = tail call i32 @ASSERT(i32 %7)
%9 = icmp ult i32 %1, 4
%10 = zext i1 %9 to i32
%11 = tail call i32 @ASSERT(i32 %10)
%12 = add i32 %4, -1
%13 = icmp ult i32 %12, 2
%14 = zext i1 %13 to i32
%15 = tail call i32 @ASSERT(i32 %14)
%16 = add nsw i32 %0, 14
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = load volatile i32, i32* %18
store volatile i32 %1, i32* %18
%20 = add nsw i32 %2, %0
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
store volatile i32 %3, i32* %22
store volatile i32 %19, i32* %18
ret void
}