#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);
void ADCComparatorRegionSet(uint32_t ui32Base, uint32_t ui32Comp,
                            uint32_t ui32LowRef, uint32_t ui32HighRef) {
  ASSERT((ui32Base == 0x40038000) || (ui32Base == 0x40039000));
  ASSERT(ui32Comp < 8);
  ASSERT((ui32LowRef < 4096) && (ui32LowRef <= ui32HighRef));
  ASSERT(ui32HighRef < 4096);
  (*((volatile uint32_t *)(ui32Base + 0x00000E40 + (ui32Comp * 4)))) =
      ((ui32HighRef << 16) | ui32LowRef);
}


x86 assembly (clang, -O0):
<ADCComparatorRegionSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x40038000,-0x4(%rbp)
mov    %al,-0x11(%rbp)
je     1143 <ADCComparatorRegionSet+0x33>
cmpl   $0x40039000,-0x4(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x8,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
xor    %eax,%eax
cmpl   $0x1000,-0xc(%rbp)
mov    %al,-0x12(%rbp)
jge    117f <ADCComparatorRegionSet+0x6f>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setle  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x1000,-0x10(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x10(%rbp),%ecx
shl    $0x10,%ecx
or     -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xe40,%eax
mov    -0x8(%rbp),%edx
shl    $0x2,%edx
add    %edx,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCComparatorRegionSet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
mov    %edi,%eax
and    $0xffffefff,%eax
xor    %edi,%edi
cmp    $0x40038000,%eax
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x8,%r14d
setl   %dil
call   1030 <ASSERT@plt>
cmp    $0x1000,%ebp
setl   %al
cmp    %ebx,%ebp
setle  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x1000,%ebx
setl   %dil
call   1030 <ASSERT@plt>
shl    $0x10,%ebx
or     %ebp,%ebx
movslq %r15d,%rax
movslq %r14d,%rcx
mov    %ebx,0xe40(%rax,%rcx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ADCComparatorRegionSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1073971200
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load i32, i32* %5
%13 = icmp eq i32 %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 @ASSERT(i32 %16)
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 8
%20 = zext i1 %19 to i32
%21 = call i32 @ASSERT(i32 %20)
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 4096
br i1 %23, label %24, label %28
24: ; preds = %14
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = icmp sle i32 %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 @ASSERT(i32 %30)
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 4096
%34 = zext i1 %33 to i32
%35 = call i32 @ASSERT(i32 %34)
%36 = load i32, i32* %8
%37 = shl i32 %36, 16
%38 = load i32, i32* %7
%39 = or i32 %37, %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 3648
%42 = load i32, i32* %6
%43 = mul nsw i32 %42, 4
%44 = add nsw i32 %41, %43
%45 = sext i32 %44 to i64
%46 = inttoptr i64 %45 to i32*
store volatile i32 %39, i32* %46
ret void
}

LLVM IR (-O2):
define void @ADCComparatorRegionSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = and i32 %0, -4097
%6 = icmp eq i32 %5, 1073971200
%7 = zext i1 %6 to i32
%8 = tail call i32 @ASSERT(i32 %7)
%9 = icmp slt i32 %1, 8
%10 = zext i1 %9 to i32
%11 = tail call i32 @ASSERT(i32 %10)
%12 = icmp slt i32 %2, 4096
%13 = icmp sle i32 %2, %3
%14 = and i1 %12, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @ASSERT(i32 %15)
%17 = icmp slt i32 %3, 4096
%18 = zext i1 %17 to i32
%19 = tail call i32 @ASSERT(i32 %18)
%20 = shl i32 %3, 16
%21 = or i32 %20, %2
%22 = add nsw i32 %0, 3648
%23 = shl nsw i32 %1, 2
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
store volatile i32 %21, i32* %26
ret void
}