#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 /*<<< orphan*/ IntEnable(int);
int /*<<< orphan*/ IntRegister(int, void (*)());
int _TimerBaseValid(int);
int _TimerIntNumberGet(int, int);
void TimerIntRegister(uint32_t ui32Base, uint32_t ui32Timer,
                      void (*pfnHandler)(void)) {
  uint32_t ui32Int;
  ASSERT(_TimerBaseValid(ui32Base));
  ASSERT((ui32Timer == 0x000000ff) || (ui32Timer == 0x0000ff00) ||
         (ui32Timer == 0x0000ffff));
  ui32Int = _TimerIntNumberGet(ui32Base, ui32Timer);
  ASSERT(ui32Int != 0);
  IntRegister(ui32Int, pfnHandler);
  IntEnable(ui32Int);
}


x86 assembly (clang, -O0):
<TimerIntRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1060 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0xff,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a2 <TimerIntRegister+0x52>
mov    $0x1,%al
cmpl   $0xff00,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     11a2 <TimerIntRegister+0x52>
cmpl   $0xffff,-0x8(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <ASSERT@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_TimerIntNumberGet@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <ASSERT@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <IntRegister@plt>
mov    -0x14(%rbp),%edi
call   1040 <IntEnable@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerIntRegister>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
call   1070 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1060 <ASSERT@plt>
mov    $0x1,%edi
cmp    $0xff,%ebp
je     1188 <TimerIntRegister+0x38>
cmp    $0xff00,%ebp
je     1188 <TimerIntRegister+0x38>
xor    %edi,%edi
cmp    $0xffff,%ebp
sete   %dil
call   1060 <ASSERT@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <_TimerIntNumberGet@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1060 <ASSERT@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <IntRegister@plt>
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <IntEnable@plt>

LLVM IR (-O0):
define void @TimerIntRegister(i32 %0, i32 %1, void ()* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca void ()*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store void ()* %2, void ()** %6
%8 = load i32, i32* %4
%9 = call i32 @_TimerBaseValid(i32 %8)
%10 = call i32 @ASSERT(i32 %9)
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 255
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 65280
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 65535
br label %19
19: ; preds = %16, %13, %3
%20 = phi i1 [ true, %13 ], [ true, %3 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
%22 = call i32 @ASSERT(i32 %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 @_TimerIntNumberGet(i32 %23, i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @ASSERT(i32 %28)
%30 = load i32, i32* %7
%31 = load void ()*, void ()** %6
%32 = bitcast void ()* %31 to void (...)*
%33 = call i32 @IntRegister(i32 %30, void (...)* %32)
%34 = load i32, i32* %7
%35 = call i32 @IntEnable(i32 %34)
ret void
}

LLVM IR (-O2):
define void @TimerIntRegister(i32 %0, i32 %1, void ()* %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 = tail call i32 @_TimerIntNumberGet(i32 %0, i32 %1)
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @ASSERT(i32 %14)
%16 = bitcast void ()* %2 to void (...)*
%17 = tail call i32 @IntRegister(i32 %12, void (...)* %16)
%18 = tail call i32 @IntEnable(i32 %12)
ret void
}