#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);
void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer,
                  unsigned long ulValue) {
  DEBUG_ASSERT(TimerBaseValid(ulBase));
  DEBUG_ASSERT((ulTimer == 0x000000ff) || (ulTimer == 0x0000ff00) ||
               (ulTimer == 0x0000ffff));
  if (ulTimer & 0x000000ff) {
    (*((volatile unsigned long *)(ulBase + 0x00000028))) = ulValue;
  }
  if (ulTimer & 0x0000ff00) {
    (*((volatile unsigned long *)(ulBase + 0x0000002C))) = ulValue;
  }
}


x86 assembly (clang, -O0):
<TimerLoadSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%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,-0x19(%rbp)
je     1178 <TimerLoadSet+0x58>
mov    $0x1,%al
cmpq   $0xff00,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     1178 <TimerLoadSet+0x58>
cmpq   $0xffff,-0x10(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0xff,%rax
cmp    $0x0,%rax
je     11a5 <TimerLoadSet+0x85>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
cmp    $0x0,%rax
je     11c5 <TimerLoadSet+0xa5>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x2c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerLoadSet>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%rbx
je     115e <TimerLoadSet+0x3e>
cmp    $0xff00,%rbx
je     115e <TimerLoadSet+0x3e>
xor    %edi,%edi
cmp    $0xffff,%rbx
sete   %dil
call   1040 <DEBUG_ASSERT@plt>
test   %bl,%bl
je     116b <TimerLoadSet+0x4b>
mov    %r14,0x28(%r15)
test   $0xff00,%ebx
je     1177 <TimerLoadSet+0x57>
mov    %r14,0x2c(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @TimerLoadSet(i64 %0, i64 %1, i64 %2) {
%4 = tail call i32 @TimerBaseValid(i64 %0)
%5 = tail call i32 @DEBUG_ASSERT(i32 %4)
switch i64 %1, label %6 [
i64 65280, label %9
i64 255, label %9
]
6: ; preds = %3
%7 = icmp eq i64 %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 @DEBUG_ASSERT(i32 %10)
%12 = and i64 %1, 255
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = add i64 %0, 40
%16 = inttoptr i64 %15 to i64*
store volatile i64 %2, i64* %16
br label %17
17: ; preds = %14, %9
%18 = and i64 %1, 65280
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = add i64 %0, 44
%22 = inttoptr i64 %21 to i64*
store volatile i64 %2, i64* %22
br label %23
23: ; preds = %20, %17
ret void
}