#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 ADCComparatorReset(uint32_t ui32Base, uint32_t ui32Comp, bool bTrigger,
                        bool bInterrupt) {
  uint32_t ui32Temp;
  ASSERT((ui32Base == 0x40038000) || (ui32Base == 0x40039000));
  ASSERT(ui32Comp < 8);
  ui32Temp = 0;
  if (bTrigger) {
    ui32Temp |= (1 << (16 + ui32Comp));
  }
  if (bInterrupt) {
    ui32Temp |= (1 << ui32Comp);
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000D00))) = ui32Temp;
}


x86 assembly (clang, -O0):
<ADCComparatorReset>:
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,-0x15(%rbp)
je     1143 <ADCComparatorReset+0x33>
cmpl   $0x40039000,-0x4(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%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>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1185 <ADCComparatorReset+0x75>
mov    -0x8(%rbp),%ecx
add    $0x10,%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     119f <ADCComparatorReset+0x8f>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xd00,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCComparatorReset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
mov    %edi,%eax
and    $0xffffefff,%eax
xor    %edi,%edi
cmp    $0x40038000,%eax
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x8,%ebp
setl   %dil
call   1030 <ASSERT@plt>
lea    0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
test   %ebx,%ebx
cmove  %ebx,%eax
mov    $0x1,%edx
mov    %ebp,%ecx
shl    %cl,%edx
test   %r15d,%r15d
cmove  %r15d,%edx
or     %eax,%edx
movslq %r14d,%rax
mov    %edx,0xd00(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @ADCComparatorReset(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 eq i32 %2, 0
%13 = add nsw i32 %1, 16
%14 = shl nuw i32 1, %13
%15 = select i1 %12, i32 0, i32 %14
%16 = icmp eq i32 %3, 0
%17 = shl nuw i32 1, %1
%18 = select i1 %16, i32 0, i32 %17
%19 = or i32 %18, %15
%20 = add nsw i32 %0, 3328
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
store volatile i32 %19, i32* %22
ret void
}