#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int _TimerBaseValid(int);
uint32_t TimerLoadGet(uint32_t ui32Base, uint32_t ui32Timer) {
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00));
  return ((ui32Timer == 0x000000ff)
              ? (*((volatile uint32_t *)(ui32Base + 0x00000028)))
              : (*((volatile uint32_t *)(ui32Base + 0x0000002C))));
}


x86 assembly (clang, -O0):
<TimerLoadGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0xff,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     115c <TimerLoadGet+0x3c>
cmpl   $0xff00,-0x8(%rbp)
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0xff,-0x8(%rbp)
jne    1188 <TimerLoadGet+0x68>
mov    -0x4(%rbp),%eax
add    $0x28,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1195 <TimerLoadGet+0x75>
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerLoadGet>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
xor    %ebp,%ebp
cmp    $0xff,%ebx
setne  %bpl
sete   %al
cmp    $0xff00,%ebx
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1030 <ASSERT@plt>
lea    0x28(,%rbp,4),%eax
movslq %r14d,%rcx
mov    (%rax,%rcx,1),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @TimerLoadGet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i32 @_TimerBaseValid(i32 %5)
%7 = call i32 @ASSERT(i32 %6)
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 255
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %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 @ASSERT(i32 %15)
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 255
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 40
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
%24 = load volatile i32, i32* %23
br label %31
25: ; preds = %13
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 44
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
%30 = load volatile i32, i32* %29
br label %31
31: ; preds = %25, %19
%32 = phi i32 [ %24, %19 ], [ %30, %25 ]
ret i32 %32
}

LLVM IR (-O2):
define i32 @TimerLoadGet(i32 %0, i32 %1) {
%3 = tail call i32 @_TimerBaseValid(i32 %0)
%4 = tail call i32 @ASSERT(i32 %3)
%5 = icmp eq i32 %1, 255
%6 = icmp eq i32 %1, 65280
%7 = or i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @ASSERT(i32 %8)
%10 = select i1 %5, i32 40, i32 44
%11 = add nsw i32 %10, %0
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = load volatile i32, i32* %13
ret i32 %14
}