#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 TimerControlEvent(unsigned long ulBase, unsigned long ulTimer,
                       unsigned long ulEvent) {
  DEBUG_ASSERT(TimerBaseValid(ulBase));
  DEBUG_ASSERT((ulTimer == 0x000000ff) || (ulTimer == 0x0000ff00) ||
               (ulTimer == 0x0000ffff));
  ulTimer &= 0x0000000C | 0x00000C00;
  (*((volatile unsigned long *)(ulBase + 0x0000000C))) =
      (((*((volatile unsigned long *)(ulBase + 0x0000000C))) & ~ulTimer) |
       (ulEvent & ulTimer));
}


x86 assembly (clang, -O0):
<TimerControlEvent>:
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 <TimerControlEvent+0x58>
mov    $0x1,%al
cmpq   $0xff00,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     1178 <TimerControlEvent+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    $0xc0c,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%rcx
mov    -0x10(%rbp),%rax
xor    $0xffffffffffffffff,%rax
and    %rax,%rcx
mov    -0x18(%rbp),%rax
and    -0x10(%rbp),%rax
or     %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerControlEvent>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%rbx
je     115e <TimerControlEvent+0x3e>
cmp    $0xff00,%rbx
je     115e <TimerControlEvent+0x3e>
xor    %edi,%edi
cmp    $0xffff,%rbx
sete   %dil
call   1040 <DEBUG_ASSERT@plt>
and    $0xc0c,%ebx
mov    %rbx,%rax
not    %rax
and    0xc(%r14),%rax
and    %r15d,%ebx
or     %rax,%rbx
mov    %rbx,0xc(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @TimerControlEvent(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, 3084
store i64 %23, i64* %5
%24 = load i64, i64* %4
%25 = add i64 %24, 12
%26 = inttoptr i64 %25 to i64*
%27 = load volatile i64, i64* %26
%28 = load i64, i64* %5
%29 = xor i64 %28, -1
%30 = and i64 %27, %29
%31 = load i64, i64* %6
%32 = load i64, i64* %5
%33 = and i64 %31, %32
%34 = or i64 %30, %33
%35 = load i64, i64* %4
%36 = add i64 %35, 12
%37 = inttoptr i64 %36 to i64*
store volatile i64 %34, i64* %37
ret void
}

LLVM IR (-O2):
define void @TimerControlEvent(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, 3084
%13 = add i64 %0, 12
%14 = inttoptr i64 %13 to i64*
%15 = load volatile i64, i64* %14
%16 = xor i64 %12, -1
%17 = and i64 %15, %16
%18 = and i64 %12, %2
%19 = or i64 %17, %18
store volatile i64 %19, i64* %14
ret void
}