#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(unsigned long);
int /*<<< orphan*/ IntRegister(unsigned long, void (*)());
void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum,
                    void (*pfnHandler)(void)) {
  unsigned long ulInt;
  DEBUG_ASSERT((ulBase == 0x40038000) || (ulBase == 0x40039000));
  DEBUG_ASSERT(ulSequenceNum < 4);
  ulInt =
      ((ulBase == 0x40038000) ? (30 + ulSequenceNum) : (64 + ulSequenceNum));
  IntRegister(ulInt, pfnHandler);
  IntEnable(ulInt);
}


x86 assembly (clang, -O0):
<ADCIntRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%al
cmpq   $0x40038000,-0x8(%rbp)
40
mov    %al,-0x21(%rbp)
je     1165 <ADCIntRegister+0x35>
cmpq   $0x40039000,-0x8(%rbp)
40
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <DEBUG_ASSERT@plt>
cmpq   $0x4,-0x10(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <DEBUG_ASSERT@plt>
cmpq   $0x40038000,-0x8(%rbp)
40
jne    11a3 <ADCIntRegister+0x73>
mov    -0x10(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x30(%rbp)
jmp    11af <ADCIntRegister+0x7f>
mov    -0x10(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <IntRegister@plt>
mov    -0x20(%rbp),%rdi
call   1030 <IntEnable@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCIntRegister>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdi,%rax
and    $0xffffffffffffefff,%rax
xor    %edi,%edi
cmp    $0x40038000,%rax
sete   %dil
call   1050 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x4,%rbx
setb   %dil
call   1050 <DEBUG_ASSERT@plt>
lea    0x40(%rbx),%rax
add    $0x1e,%rbx
cmp    $0x40038000,%r15
cmovne %rax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <IntRegister@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <IntEnable@plt>

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

LLVM IR (-O2):
define void @ADCIntRegister(i64 %0, i64 %1, void ()* %2) {
%4 = icmp eq i64 %0, 1073971200
%5 = and i64 %0, -4097
%6 = icmp eq i64 %5, 1073971200
%7 = zext i1 %6 to i32
%8 = tail call i32 @DEBUG_ASSERT(i32 %7)
%9 = icmp ult i64 %1, 4
%10 = zext i1 %9 to i32
%11 = tail call i32 @DEBUG_ASSERT(i32 %10)
%12 = select i1 %4, i64 30, i64 64
%13 = add i64 %12, %1
%14 = bitcast void ()* %2 to void (...)*
%15 = tail call i32 @IntRegister(i64 %13, void (...)* %14)
%16 = tail call i32 @IntEnable(i64 %13)
ret void
}