#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 TimerControlEvent(uint32_t ui32Base, uint32_t ui32Timer,
                       uint32_t ui32Event) {
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00) ||
         (ui32Timer == 0x0000ffff));
  ui32Timer &= 0x0000000C | 0x00000C00;
  (*((volatile uint32_t *)(ui32Base + 0x0000000C))) =
      (((*((volatile uint32_t *)(ui32Base + 0x0000000C))) & ~ui32Timer) |
       (ui32Event & ui32Timer));
}


x86 assembly (clang, -O0):
<TimerControlEvent>:
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 <TimerControlEvent+0x51>
mov    $0x1,%al
cmpl   $0xff00,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1171 <TimerControlEvent+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>
mov    -0x8(%rbp),%eax
and    $0xc0c,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%ecx
mov    -0x8(%rbp),%eax
xor    $0xffffffff,%eax
and    %eax,%ecx
mov    -0xc(%rbp),%eax
and    -0x8(%rbp),%eax
or     %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerControlEvent>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r14d
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%ebx
je     1158 <TimerControlEvent+0x38>
cmp    $0xff00,%ebx
je     1158 <TimerControlEvent+0x38>
xor    %edi,%edi
cmp    $0xffff,%ebx
sete   %dil
call   1030 <ASSERT@plt>
movslq %r14d,%rax
mov    0xc(%rax),%ecx
xor    %ecx,%ebp
and    %ebp,%ebx
and    $0xc0c,%ebx
xor    %ecx,%ebx
mov    %ebx,0xc(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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