#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 /*<<< orphan*/ IntEnable(int);
int /*<<< orphan*/ IntRegister(int, void (*)());
void ComparatorIntRegister(unsigned long ulBase, unsigned long ulComp,
                           void (*pfnHandler)(void)) {
  DEBUG_ASSERT(ulBase == 0x4003C000);
  DEBUG_ASSERT(ulComp < 3);
  IntRegister(41 + ulComp, pfnHandler);
  IntEnable(41 + ulComp);
  (*((volatile unsigned long *)(ulBase + 0x00000008))) |= 1 << ulComp;
}


x86 assembly (clang, -O0):
<ComparatorIntRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x4003c000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <DEBUG_ASSERT@plt>
cmpq   $0x3,-0x10(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
add    $0x29,%rax
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1040 <IntRegister@plt>
mov    -0x10(%rbp),%rax
add    $0x29,%rax
mov    %eax,%edi
call   1030 <IntEnable@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
movslq %eax,%rdx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
or     %rdx,%rcx
mov    %rcx,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComparatorIntRegister>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
cmp    $0x4003c000,%r14
sete   %dil
call   1050 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x3,%rbx
setb   %dil
call   1050 <DEBUG_ASSERT@plt>
lea    0x29(%rbx),%ebp
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <IntRegister@plt>
mov    %ebp,%edi
call   1030 <IntEnable@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
cltq
or     %rax,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ComparatorIntRegister(i64 %0, i64 %1, void ()* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca void ()*
store i64 %0, i64* %4
store i64 %1, i64* %5
store void ()* %2, void ()** %6
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 1073987584
%9 = zext i1 %8 to i32
%10 = call i32 @DEBUG_ASSERT(i32 %9)
%11 = load i64, i64* %5
%12 = icmp ult i64 %11, 3
%13 = zext i1 %12 to i32
%14 = call i32 @DEBUG_ASSERT(i32 %13)
%15 = load i64, i64* %5
%16 = add i64 41, %15
%17 = trunc i64 %16 to i32
%18 = load void ()*, void ()** %6
%19 = bitcast void ()* %18 to void (...)*
%20 = call i32 @IntRegister(i32 %17, void (...)* %19)
%21 = load i64, i64* %5
%22 = add i64 41, %21
%23 = trunc i64 %22 to i32
%24 = call i32 @IntEnable(i32 %23)
%25 = load i64, i64* %5
%26 = trunc i64 %25 to i32
%27 = shl i32 1, %26
%28 = sext i32 %27 to i64
%29 = load i64, i64* %4
%30 = add i64 %29, 8
%31 = inttoptr i64 %30 to i64*
%32 = load volatile i64, i64* %31
%33 = or i64 %32, %28
store volatile i64 %33, i64* %31
ret void
}

LLVM IR (-O2):
define void @ComparatorIntRegister(i64 %0, i64 %1, void ()* %2) {
%4 = icmp eq i64 %0, 1073987584
%5 = zext i1 %4 to i32
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = icmp ult i64 %1, 3
%8 = zext i1 %7 to i32
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = trunc i64 %1 to i32
%11 = add i32 %10, 41
%12 = bitcast void ()* %2 to void (...)*
%13 = tail call i32 @IntRegister(i32 %11, void (...)* %12)
%14 = tail call i32 @IntEnable(i32 %11)
%15 = shl nuw i32 1, %10
%16 = sext i32 %15 to i64
%17 = add i64 %0, 8
%18 = inttoptr i64 %17 to i64*
%19 = load volatile i64, i64* %18
%20 = or i64 %19, %16
store volatile i64 %20, i64* %18
ret void
}