#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;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void USBHostEndpointDataToggle(uint32_t ui32Base, uint32_t ui32Endpoint,
                               bool bDataToggle, uint32_t ui32Flags) {
  uint32_t ui32DataToggle;
  ASSERT(ui32Base == 0x40050000);
  ASSERT((ui32Endpoint == 0x00000000) || (ui32Endpoint == 0x00000010) ||
         (ui32Endpoint == 0x00000020) || (ui32Endpoint == 0x00000030) ||
         (ui32Endpoint == 0x00000040) || (ui32Endpoint == 0x00000050) ||
         (ui32Endpoint == 0x00000060) || (ui32Endpoint == 0x00000070));
  ui32DataToggle = 0;
  if (bDataToggle) {
    if (ui32Endpoint == 0x00000000) {
      ui32DataToggle = 0x00000002;
    } else if (ui32Flags == 0x00000000) {
      ui32DataToggle = 0x00000002;
    } else {
      ui32DataToggle = 0x00000001;
    }
  }
  if (ui32Endpoint == 0x00000000) {
    (*((volatile uint8_t *)(ui32Base + 0x00000103))) =
        (((*((volatile uint8_t *)(ui32Base + 0x00000103))) &
          ~(0x00000004 | 0x00000002)) |
         (ui32DataToggle | 0x00000004));
  } else if (ui32Flags == 0x00000000) {
    (*((volatile uint8_t *)(ui32Base + 0x00000117 + (ui32Endpoint - 0x10)))) =
        (((*((volatile uint8_t *)(ui32Base + 0x00000117 +
                                  (ui32Endpoint - 0x10)))) &
          ~(0x00000004 | 0x00000002)) |
         (ui32DataToggle | 0x00000004));
  } else {
    (*((volatile uint8_t *)(ui32Base + 0x00000113 + (ui32Endpoint - 0x10)))) =
        (((*((volatile uint8_t *)(ui32Base + 0x00000113 +
                                  (ui32Endpoint - 0x10)))) &
          ~(0x00000002 | 0x00000001)) |
         (ui32DataToggle | 0x00000002));
  }
}


x86 assembly (clang, -O0):
<USBHostEndpointDataToggle>:
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,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x10,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x20,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x30,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x40,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x50,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
mov    $0x1,%al
cmpl   $0x60,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11ab <USBHostEndpointDataToggle+0x9b>
cmpl   $0x70,-0x8(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1206 <USBHostEndpointDataToggle+0xf6>
cmpl   $0x0,-0x8(%rbp)
jne    11df <USBHostEndpointDataToggle+0xcf>
movl   $0x2,-0x14(%rbp)
jmp    1201 <USBHostEndpointDataToggle+0xf1>
cmpl   $0x0,-0x10(%rbp)
jne    11f5 <USBHostEndpointDataToggle+0xe5>
movl   $0x2,-0x14(%rbp)
jmp    11fc <USBHostEndpointDataToggle+0xec>
movl   $0x1,-0x14(%rbp)
jmp    1201 <USBHostEndpointDataToggle+0xf1>
jmp    1206 <USBHostEndpointDataToggle+0xf6>
cmpl   $0x0,-0x8(%rbp)
jne    1238 <USBHostEndpointDataToggle+0x128>
mov    -0x4(%rbp),%eax
add    $0x103,%eax
cltq
mov    (%rax),%ecx
and    $0xfffffff9,%ecx
mov    -0x14(%rbp),%eax
or     $0x4,%eax
or     %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x103,%eax
cltq
mov    %ecx,(%rax)
jmp    12b2 <USBHostEndpointDataToggle+0x1a2>
cmpl   $0x0,-0x10(%rbp)
jne    127a <USBHostEndpointDataToggle+0x16a>
mov    -0x4(%rbp),%eax
add    $0x117,%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
cltq
mov    (%rax),%ecx
and    $0xfffffff9,%ecx
mov    -0x14(%rbp),%eax
or     $0x4,%eax
or     %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x117,%eax
mov    -0x8(%rbp),%edx
sub    $0x10,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
jmp    12ad <USBHostEndpointDataToggle+0x19d>
mov    -0x4(%rbp),%eax
add    $0x113,%eax
mov    -0x8(%rbp),%ecx
sub    $0x10,%ecx
add    %ecx,%eax
cltq
mov    (%rax),%ecx
and    $0xfffffffc,%ecx
mov    -0x14(%rbp),%eax
or     $0x2,%eax
or     %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x113,%eax
mov    -0x8(%rbp),%edx
sub    $0x10,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
jmp    12b2 <USBHostEndpointDataToggle+0x1a2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostEndpointDataToggle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
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>
test   %ebx,%ebx
je     116d <USBHostEndpointDataToggle+0x5d>
test   %r15d,%r15d
je     1176 <USBHostEndpointDataToggle+0x66>
add    %ebx,%r14d
add    $0x103,%r14d
mov    $0x2,%eax
mov    $0xfffffffc,%ecx
jmp    118a <USBHostEndpointDataToggle+0x7a>
add    $0x103,%r14d
jmp    1180 <USBHostEndpointDataToggle+0x70>
add    %ebx,%r14d
add    $0x107,%r14d
mov    $0x4,%eax
mov    $0xfffffff9,%ecx
xor    %edx,%edx
test   %ebp,%ebp
setne  %dl
add    %edx,%edx
cmp    $0x1,%r15d
mov    $0x1,%esi
adc    $0x0,%esi
test   %ebp,%ebp
cmove  %edx,%esi
test   %ebx,%ebx
cmove  %edx,%esi
movslq %r14d,%rdx
and    (%rdx),%ecx
or     %esi,%ecx
or     %eax,%ecx
mov    %ecx,(%rdx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @USBHostEndpointDataToggle(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 = icmp eq i32 %2, 0
%16 = icmp eq i32 %3, 0
br i1 %8, label %17, label %19
17: ; preds = %4
%18 = add nsw i32 %0, 259
br label %26
19: ; preds = %4
br i1 %16, label %20, label %23
20: ; preds = %19
%21 = add i32 %1, %0
%22 = add i32 %21, 263
br label %26
23: ; preds = %19
%24 = add i32 %0, 259
%25 = add i32 %24, %1
br label %26
26: ; preds = %20, %23, %17
%27 = phi i32 [ %22, %20 ], [ %25, %23 ], [ %18, %17 ]
%28 = phi i32 [ -7, %20 ], [ -4, %23 ], [ -7, %17 ]
%29 = phi i32 [ 4, %20 ], [ 2, %23 ], [ 4, %17 ]
%30 = or i1 %8, %15
%31 = select i1 %15, i32 0, i32 2
%32 = select i1 %16, i32 2, i32 1
%33 = select i1 %30, i32 %31, i32 %32
%34 = sext i32 %27 to i64
%35 = inttoptr i64 %34 to i32*
%36 = load volatile i32, i32* %35
%37 = and i32 %36, %28
%38 = or i32 %33, %37
%39 = or i32 %38, %29
store volatile i32 %39, i32* %35
ret void
}