#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 */

/* Variables and functions */
int /*<<< orphan*/ DEBUG_ASSERT(int);
void QEIVelocityConfigure(unsigned long ulBase, unsigned long ulPreDiv,
                          unsigned long ulPeriod) {
  DEBUG_ASSERT((ulBase == 0x4002C000) || (ulBase == 0x4002D000));
  DEBUG_ASSERT(!(ulPreDiv & ~(0x000001C0)));
  DEBUG_ASSERT(ulPeriod != 0);
  (*((volatile unsigned long *)(ulBase + 0x00000000))) =
      (((*((volatile unsigned long *)(ulBase + 0x00000000))) & ~(0x000001C0)) |
       ulPreDiv);
  (*((volatile unsigned long *)(ulBase + 0x00000010))) = ulPeriod - 1;
}


x86 assembly (clang, -O0):
<QEIVelocityConfigure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%al
cmpq   $0x4002c000,-0x8(%rbp)
40
mov    %al,-0x19(%rbp)
je     1145 <QEIVelocityConfigure+0x35>
cmpq   $0x4002d000,-0x8(%rbp)
40
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0xfffffffffffffe3f,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
and    $0xfffffffffffffe3f,%rcx
or     -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QEIVelocityConfigure>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rdi,%rax
and    $0xffffffffffffefff,%rax
xor    %edi,%edi
cmp    $0x4002c000,%rax
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   $0xfffffffffffffe3f,%r15
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
add    $0xffffffffffffffff,%r14
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    $0xfffffffffffffe3f,%rax
and    (%rbx),%rax
or     %r15,%rax
mov    %rax,(%rbx)
mov    %r14,0x10(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @QEIVelocityConfigure(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 1073922048
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i64, i64* %4
%11 = icmp eq i64 %10, 1073926144
br label %12
12: ; preds = %9, %3
%13 = phi i1 [ true, %3 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @DEBUG_ASSERT(i32 %14)
%16 = load i64, i64* %5
%17 = and i64 %16, -449
%18 = icmp ne i64 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
%21 = call i32 @DEBUG_ASSERT(i32 %20)
%22 = load i64, i64* %6
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @DEBUG_ASSERT(i32 %24)
%26 = load i64, i64* %4
%27 = add i64 %26, 0
%28 = inttoptr i64 %27 to i64*
%29 = load volatile i64, i64* %28
%30 = and i64 %29, -449
%31 = load i64, i64* %5
%32 = or i64 %30, %31
%33 = load i64, i64* %4
%34 = add i64 %33, 0
%35 = inttoptr i64 %34 to i64*
store volatile i64 %32, i64* %35
%36 = load i64, i64* %6
%37 = sub i64 %36, 1
%38 = load i64, i64* %4
%39 = add i64 %38, 16
%40 = inttoptr i64 %39 to i64*
store volatile i64 %37, i64* %40
ret void
}

LLVM IR (-O2):
define void @QEIVelocityConfigure(i64 %0, i64 %1, i64 %2) {
%4 = and i64 %0, -4097
%5 = icmp eq i64 %4, 1073922048
%6 = zext i1 %5 to i32
%7 = tail call i32 @DEBUG_ASSERT(i32 %6)
%8 = and i64 %1, -449
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @DEBUG_ASSERT(i32 %10)
%12 = icmp ne i64 %2, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @DEBUG_ASSERT(i32 %13)
%15 = inttoptr i64 %0 to i64*
%16 = load volatile i64, i64* %15
%17 = and i64 %16, -449
%18 = or i64 %17, %1
store volatile i64 %18, i64* %15
%19 = add i64 %2, -1
%20 = add i64 %0, 16
%21 = inttoptr i64 %20 to i64*
store volatile i64 %19, i64* %21
ret void
}