#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 (*)());
void ComparatorIntRegister(uint32_t ui32Base, uint32_t ui32Comp,
                           void (*pfnHandler)(void)) {
  ASSERT(ui32Base == 0x4003C000);
  ASSERT(ui32Comp < 3);
  IntRegister(41 + ui32Comp, pfnHandler);
  IntEnable(41 + ui32Comp);
  (*((volatile uint32_t *)(ui32Base + 0x00000008))) |= 1 << ui32Comp;
}


x86 assembly (clang, -O0):
<ComparatorIntRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x4003c000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <ASSERT@plt>
cmpl   $0x3,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <ASSERT@plt>
mov    -0x8(%rbp),%edi
add    $0x29,%edi
mov    -0x10(%rbp),%rsi
call   1040 <IntRegister@plt>
mov    -0x8(%rbp),%edi
add    $0x29,%edi
call   1030 <IntEnable@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
mov    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

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

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

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