#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);
void TimerPrescaleMatchSet(uint32_t ui32Base, uint32_t ui32Timer,
                           uint32_t ui32Value) {
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00) ||
         (ui32Timer == 0x0000ffff));
  ASSERT(ui32Value < 256);
  if (ui32Timer & 0x000000ff) {
    (*((volatile uint32_t *)(ui32Base + 0x00000040))) = ui32Value;
  }
  if (ui32Timer & 0x0000ff00) {
    (*((volatile uint32_t *)(ui32Base + 0x00000044))) = ui32Value;
  }
}


x86 assembly (clang, -O0):
<TimerPrescaleMatchSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%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,-0xd(%rbp)
je     1171 <TimerPrescaleMatchSet+0x51>
mov    $0x1,%al
cmpl   $0xff00,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1171 <TimerPrescaleMatchSet+0x51>
cmpl   $0xffff,-0x8(%rbp)
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x100,-0xc(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
cmp    $0x0,%eax
je     11b0 <TimerPrescaleMatchSet+0x90>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x40,%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff00,%eax
cmp    $0x0,%eax
je     11ce <TimerPrescaleMatchSet+0xae>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x44,%eax
cltq
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerPrescaleMatchSet>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%ebp
je     1158 <TimerPrescaleMatchSet+0x38>
cmp    $0xff00,%ebp
je     1158 <TimerPrescaleMatchSet+0x38>
xor    %edi,%edi
cmp    $0xffff,%ebp
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x100,%r14d
setl   %dil
call   1030 <ASSERT@plt>
movslq %ebx,%rax
test   %bpl,%bpl
je     117b <TimerPrescaleMatchSet+0x5b>
mov    %r14d,0x40(%rax)
test   $0xff00,%ebp
je     1187 <TimerPrescaleMatchSet+0x67>
mov    %r14d,0x44(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @TimerPrescaleMatchSet(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = call i32 @_TimerBaseValid(i32 %7)
%9 = call i32 @ASSERT(i32 %8)
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 255
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 65280
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp eq i32 %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 @ASSERT(i32 %20)
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 256
%24 = zext i1 %23 to i32
%25 = call i32 @ASSERT(i32 %24)
%26 = load i32, i32* %5
%27 = and i32 %26, 255
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %18
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 64
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
store volatile i32 %30, i32* %34
br label %35
35: ; preds = %29, %18
%36 = load i32, i32* %5
%37 = and i32 %36, 65280
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = load i32, i32* %6
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 68
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i32*
store volatile i32 %40, i32* %44
br label %45
45: ; preds = %39, %35
ret void
}

LLVM IR (-O2):
define void @TimerPrescaleMatchSet(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @_TimerBaseValid(i32 %0)
%5 = tail call i32 @ASSERT(i32 %4)
switch i32 %1, label %6 [
i32 65280, label %9
i32 255, label %9
]
6: ; preds = %3
%7 = icmp eq i32 %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 @ASSERT(i32 %10)
%12 = icmp slt i32 %2, 256
%13 = zext i1 %12 to i32
%14 = tail call i32 @ASSERT(i32 %13)
%15 = and i32 %1, 255
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %9
%18 = add nsw i32 %0, 64
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
store volatile i32 %2, i32* %20
br label %21
21: ; preds = %17, %9
%22 = and i32 %1, 65280
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = add nsw i32 %0, 68
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
store volatile i32 %2, i32* %27
br label %28
28: ; preds = %24, %21
ret void
}