#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);
int TimerBaseValid(unsigned long);
void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
                      unsigned long ulValue) {
  DEBUG_ASSERT(TimerBaseValid(ulBase));
  DEBUG_ASSERT((ulTimer == 0x000000ff) || (ulTimer == 0x0000ff00) ||
               (ulTimer == 0x0000ffff));
  DEBUG_ASSERT(ulValue < 256);
  if (ulTimer & 0x000000ff) {
    (*((volatile unsigned long *)(ulBase + 0x00000038))) = ulValue;
  }
  if (ulTimer & 0x0000ff00) {
    (*((volatile unsigned long *)(ulBase + 0x0000003C))) = ulValue;
  }
}


x86 assembly (clang, -O0):
<TimerPrescaleSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    $0x1,%al
cmpq   $0xff,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     1178 <TimerPrescaleSet+0x58>
mov    $0x1,%al
cmpq   $0xff00,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     1178 <TimerPrescaleSet+0x58>
cmpq   $0xffff,-0x10(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
cmpq   $0x100,-0x18(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
cmp    $0x0,%rax
je     11ba <TimerPrescaleSet+0x9a>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
cmp    $0x0,%rax
je     11da <TimerPrescaleSet+0xba>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x3c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleSet>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%rbx
je     115e <TimerPrescaleSet+0x3e>
cmp    $0xff00,%rbx
je     115e <TimerPrescaleSet+0x3e>
xor    %edi,%edi
cmp    $0xffff,%rbx
sete   %dil
call   1040 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x100,%r14
setb   %dil
call   1040 <DEBUG_ASSERT@plt>
test   %bl,%bl
je     117d <TimerPrescaleSet+0x5d>
mov    %r14,0x38(%r15)
test   $0xff00,%ebx
je     1189 <TimerPrescaleSet+0x69>
mov    %r14,0x3c(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @TimerPrescaleSet(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 = call i32 @TimerBaseValid(i64 %7)
%9 = call i32 @DEBUG_ASSERT(i32 %8)
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 255
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = load i64, i64* %5
%14 = icmp eq i64 %13, 65280
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i64, i64* %5
%17 = icmp eq i64 %16, 65535
br label %18
18: ; preds = %15, %12, %3
%19 = phi i1 [ true, %12 ], [ true, %3 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = call i32 @DEBUG_ASSERT(i32 %20)
%22 = load i64, i64* %6
%23 = icmp ult i64 %22, 256
%24 = zext i1 %23 to i32
%25 = call i32 @DEBUG_ASSERT(i32 %24)
%26 = load i64, i64* %5
%27 = and i64 %26, 255
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %18
%30 = load i64, i64* %6
%31 = load i64, i64* %4
%32 = add i64 %31, 56
%33 = inttoptr i64 %32 to i64*
store volatile i64 %30, i64* %33
br label %34
34: ; preds = %29, %18
%35 = load i64, i64* %5
%36 = and i64 %35, 65280
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i64, i64* %6
%40 = load i64, i64* %4
%41 = add i64 %40, 60
%42 = inttoptr i64 %41 to i64*
store volatile i64 %39, i64* %42
br label %43
43: ; preds = %38, %34
ret void
}

LLVM IR (-O2):
define void @TimerPrescaleSet(i64 %0, i64 %1, i64 %2) {
%4 = tail call i32 @TimerBaseValid(i64 %0)
%5 = tail call i32 @DEBUG_ASSERT(i32 %4)
switch i64 %1, label %6 [
i64 65280, label %9
i64 255, label %9
]
6: ; preds = %3
%7 = icmp eq i64 %1, 65535
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %3, %3, %6
%10 = phi i32 [ 1, %3 ], [ %8, %6 ], [ 1, %3 ]
%11 = tail call i32 @DEBUG_ASSERT(i32 %10)
%12 = icmp ult i64 %2, 256
%13 = zext i1 %12 to i32
%14 = tail call i32 @DEBUG_ASSERT(i32 %13)
%15 = and i64 %1, 255
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = add i64 %0, 56
%19 = inttoptr i64 %18 to i64*
store volatile i64 %2, i64* %19
br label %20
20: ; preds = %17, %9
%21 = and i64 %1, 65280
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = add i64 %0, 60
%25 = inttoptr i64 %24 to i64*
store volatile i64 %2, i64* %25
br label %26
26: ; preds = %23, %20
ret void
}