#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 */
void USBHostEndpointDataToggle(uint32_t ui32Base, uint32_t ui32Endpoint,
                               bool bDataToggle, uint32_t ui32Flags) {
  uint32_t ui32DataToggle;
  ;

  ;
  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
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     115e <USBHostEndpointDataToggle+0x5e>
cmpl   $0x0,-0x8(%rbp)
jne    1137 <USBHostEndpointDataToggle+0x37>
movl   $0x2,-0x14(%rbp)
jmp    1159 <USBHostEndpointDataToggle+0x59>
cmpl   $0x0,-0x10(%rbp)
jne    114d <USBHostEndpointDataToggle+0x4d>
movl   $0x2,-0x14(%rbp)
jmp    1154 <USBHostEndpointDataToggle+0x54>
movl   $0x1,-0x14(%rbp)
jmp    1159 <USBHostEndpointDataToggle+0x59>
jmp    115e <USBHostEndpointDataToggle+0x5e>
cmpl   $0x0,-0x8(%rbp)
jne    1190 <USBHostEndpointDataToggle+0x90>
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    120a <USBHostEndpointDataToggle+0x10a>
cmpl   $0x0,-0x10(%rbp)
jne    11d2 <USBHostEndpointDataToggle+0xd2>
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    1205 <USBHostEndpointDataToggle+0x105>
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    120a <USBHostEndpointDataToggle+0x10a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBHostEndpointDataToggle>:
test   %edx,%edx
je     1115 <USBHostEndpointDataToggle+0x15>
test   %esi,%esi
je     1138 <USBHostEndpointDataToggle+0x38>
cmp    $0x1,%ecx
mov    $0x1,%eax
adc    $0x0,%eax
jmp    111b <USBHostEndpointDataToggle+0x1b>
xor    %eax,%eax
test   %esi,%esi
je     1158 <USBHostEndpointDataToggle+0x58>
test   %ecx,%ecx
je     113f <USBHostEndpointDataToggle+0x3f>
lea    (%rdi,%rsi,1),%ecx
add    $0x103,%ecx
movslq %ecx,%rcx
mov    (%rcx),%edx
and    $0xfffffffc,%edx
or     %edx,%eax
or     $0x2,%eax
mov    %eax,(%rcx)
ret
mov    $0x6,%eax
jmp    115d <USBHostEndpointDataToggle+0x5d>
lea    (%rsi,%rdi,1),%ecx
add    $0x107,%ecx
movslq %ecx,%rcx
mov    (%rcx),%edx
and    $0xfffffff9,%edx
or     %edx,%eax
or     $0x4,%eax
mov    %eax,(%rcx)
ret
mov    $0x4,%eax
movslq %edi,%rcx
mov    0x103(%rcx),%edx
and    $0xfffffff9,%edx
or     %eax,%edx
mov    %edx,0x103(%rcx)
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
store i32 0, i32* %9
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %4
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 2, i32* %9
br label %22
16: ; preds = %12
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 2, i32* %9
br label %21
20: ; preds = %16
store i32 1, i32* %9
br label %21
21: ; preds = %20, %19
br label %22
22: ; preds = %21, %15
br label %23
23: ; preds = %22, %4
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 259
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
%31 = load volatile i32, i32* %30
%32 = and i32 %31, -7
%33 = load i32, i32* %9
%34 = or i32 %33, 4
%35 = or i32 %32, %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 259
%38 = sext i32 %37 to i64
%39 = inttoptr i64 %38 to i32*
store volatile i32 %35, i32* %39
br label %84
40: ; preds = %23
%41 = load i32, i32* %8
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %63
43: ; preds = %40
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 279
%46 = load i32, i32* %6
%47 = sub nsw i32 %46, 16
%48 = add nsw i32 %45, %47
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
%51 = load volatile i32, i32* %50
%52 = and i32 %51, -7
%53 = load i32, i32* %9
%54 = or i32 %53, 4
%55 = or i32 %52, %54
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 279
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 16
%60 = add nsw i32 %57, %59
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i32*
store volatile i32 %55, i32* %62
br label %83
63: ; preds = %40
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 275
%66 = load i32, i32* %6
%67 = sub nsw i32 %66, 16
%68 = add nsw i32 %65, %67
%69 = sext i32 %68 to i64
%70 = inttoptr i64 %69 to i32*
%71 = load volatile i32, i32* %70
%72 = and i32 %71, -4
%73 = load i32, i32* %9
%74 = or i32 %73, 2
%75 = or i32 %72, %74
%76 = load i32, i32* %5
%77 = add nsw i32 %76, 275
%78 = load i32, i32* %6
%79 = sub nsw i32 %78, 16
%80 = add nsw i32 %77, %79
%81 = sext i32 %80 to i64
%82 = inttoptr i64 %81 to i32*
store volatile i32 %75, i32* %82
br label %83
83: ; preds = %63, %43
br label %84
84: ; preds = %83, %26
ret void
}

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