#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);
unsigned long TimerPrescaleGet(unsigned long ulBase, unsigned long ulTimer) {
  DEBUG_ASSERT(TimerBaseValid(ulBase));
  DEBUG_ASSERT((ulTimer == 0x000000ff) || (ulTimer == 0x0000ff00) ||
               (ulTimer == 0x0000ffff));
  return ((ulTimer == 0x000000ff)
              ? (*((volatile unsigned long *)(ulBase + 0x00000038)))
              : (*((volatile unsigned long *)(ulBase + 0x0000003C))));
}


x86 assembly (clang, -O0):
<TimerPrescaleGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%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,-0x11(%rbp)
je     1174 <TimerPrescaleGet+0x54>
mov    $0x1,%al
cmpq   $0xff00,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1174 <TimerPrescaleGet+0x54>
cmpq   $0xffff,-0x10(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
cmpq   $0xff,-0x10(%rbp)
jne    11a0 <TimerPrescaleGet+0x80>
mov    -0x8(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11ac <TimerPrescaleGet+0x8c>
mov    -0x8(%rbp),%rax
mov    0x3c(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleGet>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%r15
je     115b <TimerPrescaleGet+0x3b>
cmp    $0xff00,%r15
je     115b <TimerPrescaleGet+0x3b>
xor    %edi,%edi
cmp    $0xffff,%r15
sete   %dil
xor    %ebx,%ebx
cmp    $0xff,%r15
setne  %bl
call   1040 <DEBUG_ASSERT@plt>
mov    0x38(%r14,%rbx,4),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @TimerPrescaleGet(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = call i32 @TimerBaseValid(i64 %5)
%7 = call i32 @DEBUG_ASSERT(i32 %6)
%8 = load i64, i64* %4
%9 = icmp eq i64 %8, 255
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i64, i64* %4
%12 = icmp eq i64 %11, 65280
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i64, i64* %4
%15 = icmp eq i64 %14, 65535
br label %16
16: ; preds = %13, %10, %2
%17 = phi i1 [ true, %10 ], [ true, %2 ], [ %15, %13 ]
%18 = zext i1 %17 to i32
%19 = call i32 @DEBUG_ASSERT(i32 %18)
%20 = load i64, i64* %4
%21 = icmp eq i64 %20, 255
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i64, i64* %3
%24 = add i64 %23, 56
%25 = inttoptr i64 %24 to i64*
%26 = load volatile i64, i64* %25
br label %32
27: ; preds = %16
%28 = load i64, i64* %3
%29 = add i64 %28, 60
%30 = inttoptr i64 %29 to i64*
%31 = load volatile i64, i64* %30
br label %32
32: ; preds = %27, %22
%33 = phi i64 [ %26, %22 ], [ %31, %27 ]
ret i64 %33
}

LLVM IR (-O2):
define i64 @TimerPrescaleGet(i64 %0, i64 %1) {
%3 = tail call i32 @TimerBaseValid(i64 %0)
%4 = tail call i32 @DEBUG_ASSERT(i32 %3)
switch i64 %1, label %5 [
i64 65280, label %8
i64 255, label %8
]
5: ; preds = %2
%6 = icmp eq i64 %1, 65535
%7 = zext i1 %6 to i32
br label %8
8: ; preds = %2, %2, %5
%9 = phi i32 [ 1, %2 ], [ %7, %5 ], [ 1, %2 ]
%10 = icmp eq i64 %1, 255
%11 = tail call i32 @DEBUG_ASSERT(i32 %9)
%12 = select i1 %10, i64 56, i64 60
%13 = add i64 %12, %0
%14 = inttoptr i64 %13 to i64*
%15 = load volatile i64, i64* %14
ret i64 %15
}