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


x86 assembly (clang, -O0):
<TimerValueGet>:
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     1161 <TimerValueGet+0x41>
cmpq   $0xff00,-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    118d <TimerValueGet+0x6d>
mov    -0x8(%rbp),%rax
mov    0x48(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1199 <TimerValueGet+0x79>
mov    -0x8(%rbp),%rax
mov    0x4c(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerValueGet>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
xor    %ebx,%ebx
cmp    $0xff,%r15
setne  %bl
sete   %al
cmp    $0xff00,%r15
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    0x48(%r14,%rbx,4),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @TimerValueGet(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 %13, label %10
10: ; preds = %2
%11 = load i64, i64* %4
%12 = icmp eq i64 %11, 65280
br label %13
13: ; preds = %10, %2
%14 = phi i1 [ true, %2 ], [ %12, %10 ]
%15 = zext i1 %14 to i32
%16 = call i32 @DEBUG_ASSERT(i32 %15)
%17 = load i64, i64* %4
%18 = icmp eq i64 %17, 255
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i64, i64* %3
%21 = add i64 %20, 72
%22 = inttoptr i64 %21 to i64*
%23 = load volatile i64, i64* %22
br label %29
24: ; preds = %13
%25 = load i64, i64* %3
%26 = add i64 %25, 76
%27 = inttoptr i64 %26 to i64*
%28 = load volatile i64, i64* %27
br label %29
29: ; preds = %24, %19
%30 = phi i64 [ %23, %19 ], [ %28, %24 ]
ret i64 %30
}

LLVM IR (-O2):
define i64 @TimerValueGet(i64 %0, i64 %1) {
%3 = tail call i32 @TimerBaseValid(i64 %0)
%4 = tail call i32 @DEBUG_ASSERT(i32 %3)
%5 = icmp eq i64 %1, 255
%6 = icmp eq i64 %1, 65280
%7 = or i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = select i1 %5, i64 72, i64 76
%11 = add i64 %10, %0
%12 = inttoptr i64 %11 to i64*
%13 = load volatile i64, i64* %12
ret i64 %13
}