#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);
void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp,
                            unsigned long ulLowRef, unsigned long ulHighRef) {
  DEBUG_ASSERT((ulBase == 0x40038000) || (ulBase == 0x40039000));
  DEBUG_ASSERT(ulComp < 8);
  DEBUG_ASSERT((ulLowRef < 1024) && (ulLowRef <= ulHighRef));
  DEBUG_ASSERT(ulHighRef < 1024);
  (*((volatile unsigned long *)(ulBase + 0x00000E40 + (ulComp * 4)))) =
      (ulHighRef << 16) | ulLowRef;
}


x86 assembly (clang, -O0):
<ADCComparatorRegionSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x1,%al
cmpq   $0x40038000,-0x8(%rbp)
40
mov    %al,-0x21(%rbp)
je     1149 <ADCComparatorRegionSet+0x39>
cmpq   $0x40039000,-0x8(%rbp)
40
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x8,-0x10(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %eax,%eax
cmpq   $0x400,-0x18(%rbp)
mov    %al,-0x22(%rbp)
jae    1189 <ADCComparatorRegionSet+0x79>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
setbe  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x400,-0x20(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x20(%rbp),%rcx
shl    $0x10,%rcx
or     -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0xe40,%rax
mov    -0x10(%rbp),%rdx
shl    $0x2,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCComparatorRegionSet>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rdi,%rax
and    $0xffffffffffffefff,%rax
xor    %edi,%edi
cmp    $0x40038000,%rax
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x8,%r14
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
cmp    $0x400,%r15
setb   %al
cmp    %rbx,%r15
setbe  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x400,%rbx
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
shl    $0x10,%rbx
or     %r15,%rbx
mov    %rbx,0xe40(%r12,%r14,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ADCComparatorRegionSet(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%9 = load i64, i64* %5
%10 = icmp eq i64 %9, 1073971200
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load i64, i64* %5
%13 = icmp eq i64 %12, 1073975296
br label %14
14: ; preds = %11, %4
%15 = phi i1 [ true, %4 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = call i32 @DEBUG_ASSERT(i32 %16)
%18 = load i64, i64* %6
%19 = icmp ult i64 %18, 8
%20 = zext i1 %19 to i32
%21 = call i32 @DEBUG_ASSERT(i32 %20)
%22 = load i64, i64* %7
%23 = icmp ult i64 %22, 1024
br i1 %23, label %24, label %28
24: ; preds = %14
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = icmp ule i64 %25, %26
br label %28
28: ; preds = %24, %14
%29 = phi i1 [ false, %14 ], [ %27, %24 ]
%30 = zext i1 %29 to i32
%31 = call i32 @DEBUG_ASSERT(i32 %30)
%32 = load i64, i64* %8
%33 = icmp ult i64 %32, 1024
%34 = zext i1 %33 to i32
%35 = call i32 @DEBUG_ASSERT(i32 %34)
%36 = load i64, i64* %8
%37 = shl i64 %36, 16
%38 = load i64, i64* %7
%39 = or i64 %37, %38
%40 = load i64, i64* %5
%41 = add i64 %40, 3648
%42 = load i64, i64* %6
%43 = mul i64 %42, 4
%44 = add i64 %41, %43
%45 = inttoptr i64 %44 to i64*
store volatile i64 %39, i64* %45
ret void
}

LLVM IR (-O2):
define void @ADCComparatorRegionSet(i64 %0, i64 %1, i64 %2, i64 %3) {
%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, 8
%10 = zext i1 %9 to i32
%11 = tail call i32 @DEBUG_ASSERT(i32 %10)
%12 = icmp ult i64 %2, 1024
%13 = icmp ule i64 %2, %3
%14 = and i1 %12, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @DEBUG_ASSERT(i32 %15)
%17 = icmp ult i64 %3, 1024
%18 = zext i1 %17 to i32
%19 = tail call i32 @DEBUG_ASSERT(i32 %18)
%20 = shl i64 %3, 16
%21 = or i64 %20, %2
%22 = add i64 %0, 3648
%23 = shl i64 %1, 2
%24 = add i64 %22, %23
%25 = inttoptr i64 %24 to i64*
store volatile i64 %21, i64* %25
ret void
}