#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 TimerMatchSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value) {
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00) ||
         (ui32Timer == 0x0000ffff));
  if (ui32Timer & 0x000000ff) {
    (*((volatile uint32_t *)(ui32Base + 0x00000030))) = ui32Value;
  }
  if (ui32Timer & 0x0000ff00) {
    (*((volatile uint32_t *)(ui32Base + 0x00000034))) = ui32Value;
  }
}


x86 assembly (clang, -O0):
<TimerMatchSet>:
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 <TimerMatchSet+0x51>
mov    $0x1,%al
cmpl   $0xff00,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1171 <TimerMatchSet+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    $0xff,%eax
cmp    $0x0,%eax
je     119c <TimerMatchSet+0x7c>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x30,%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff00,%eax
cmp    $0x0,%eax
je     11ba <TimerMatchSet+0x9a>
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x34,%eax
cltq
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerMatchSet>:
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 <TimerMatchSet+0x38>
cmp    $0xff00,%ebp
je     1158 <TimerMatchSet+0x38>
xor    %edi,%edi
cmp    $0xffff,%ebp
sete   %dil
call   1030 <ASSERT@plt>
movslq %ebx,%rax
test   %bpl,%bpl
je     1169 <TimerMatchSet+0x49>
mov    %r14d,0x30(%rax)
test   $0xff00,%ebp
je     1175 <TimerMatchSet+0x55>
mov    %r14d,0x34(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @TimerMatchSet(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, 255
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i32, i32* %6
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 48
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
store volatile i32 %26, i32* %30
br label %31
31: ; preds = %25, %18
%32 = load i32, i32* %5
%33 = and i32 %32, 65280
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 52
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
store volatile i32 %36, i32* %40
br label %41
41: ; preds = %35, %31
ret void
}

LLVM IR (-O2):
define void @TimerMatchSet(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, 255
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = add nsw i32 %0, 48
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store volatile i32 %2, i32* %17
br label %18
18: ; preds = %14, %9
%19 = and i32 %1, 65280
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = add nsw i32 %0, 52
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
store volatile i32 %2, i32* %24
br label %25
25: ; preds = %21, %18
ret void
}