#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 TimerPrescaleMatchGet(uint32_t ui32Base, uint32_t ui32Timer) {
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00) ||
         (ui32Timer == 0x0000ffff));
  return ((ui32Timer == 0x000000ff)
              ? (*((volatile uint32_t *)(ui32Base + 0x00000040)))
              : (*((volatile uint32_t *)(ui32Base + 0x00000044))));
}


x86 assembly (clang, -O0):
<TimerPrescaleMatchGet>:
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     116e <TimerPrescaleMatchGet+0x4e>
mov    $0x1,%al
cmpl   $0xff00,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     116e <TimerPrescaleMatchGet+0x4e>
cmpl   $0xffff,-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    119a <TimerPrescaleMatchGet+0x7a>
mov    -0x4(%rbp),%eax
add    $0x40,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    11a7 <TimerPrescaleMatchGet+0x87>
mov    -0x4(%rbp),%eax
add    $0x44,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleMatchGet>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%ebp
je     1156 <TimerPrescaleMatchGet+0x36>
cmp    $0xff00,%ebp
je     1156 <TimerPrescaleMatchGet+0x36>
xor    %edi,%edi
cmp    $0xffff,%ebp
sete   %dil
xor    %ebx,%ebx
cmp    $0xff,%ebp
setne  %bl
call   1030 <ASSERT@plt>
lea    0x40(,%rbx,4),%eax
movslq %r14d,%rcx
mov    (%rax,%rcx,1),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @TimerPrescaleMatchGet(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 %16, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 65280
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp eq i32 %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 @ASSERT(i32 %18)
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 255
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 64
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = load volatile i32, i32* %26
br label %34
28: ; preds = %16
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 68
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = load volatile i32, i32* %32
br label %34
34: ; preds = %28, %22
%35 = phi i32 [ %27, %22 ], [ %33, %28 ]
ret i32 %35
}

LLVM IR (-O2):
define i32 @TimerPrescaleMatchGet(i32 %0, i32 %1) {
%3 = tail call i32 @_TimerBaseValid(i32 %0)
%4 = tail call i32 @ASSERT(i32 %3)
switch i32 %1, label %5 [
i32 65280, label %8
i32 255, label %8
]
5: ; preds = %2
%6 = icmp eq i32 %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 i32 %1, 255
%11 = tail call i32 @ASSERT(i32 %9)
%12 = select i1 %10, i32 64, i32 68
%13 = add nsw i32 %12, %0
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
ret i32 %16
}