#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 ADCReferenceSet(unsigned long ulBase, unsigned long ulRef) {
  DEBUG_ASSERT((ulBase == 0x40038000) || (ulBase == 0x40039000));
  DEBUG_ASSERT((ulRef == 0x00000000) || (ulRef == 0x00000001) ||
               (ulRef == 0x00000003));
  (*((volatile unsigned long *)(ulBase + 0x00000038))) =
      ((*((volatile unsigned long *)(ulBase + 0x00000038))) & ~0x00000003) |
      ulRef;
}


x86 assembly (clang, -O0):
<ADCReferenceSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%al
cmpq   $0x40038000,-0x8(%rbp)
40
mov    %al,-0x11(%rbp)
je     1141 <ADCReferenceSet+0x31>
cmpq   $0x40039000,-0x8(%rbp)
40
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x1,%al
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
je     1179 <ADCReferenceSet+0x69>
mov    $0x1,%al
cmpq   $0x1,-0x10(%rbp)
mov    %al,-0x12(%rbp)
je     1179 <ADCReferenceSet+0x69>
cmpq   $0x3,-0x10(%rbp)
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
mov    0x38(%rax),%rcx
and    $0xfffffffffffffffc,%rcx
or     -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x38(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCReferenceSet>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%rax
and    $0xffffffffffffefff,%rax
xor    %edi,%edi
cmp    $0x40038000,%rax
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
cmp    $0x2,%rbx
setb   %al
cmp    $0x3,%rbx
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    0x38(%r14),%rax
and    $0xfffffffffffffffc,%rax
or     %rbx,%rax
mov    %rax,0x38(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @ADCReferenceSet(i64 %0, i64 %1) {
%3 = and i64 %0, -4097
%4 = icmp eq i64 %3, 1073971200
%5 = zext i1 %4 to i32
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = icmp ult i64 %1, 2
%8 = icmp eq i64 %1, 3
%9 = or i1 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @DEBUG_ASSERT(i32 %10)
%12 = add i64 %0, 56
%13 = inttoptr i64 %12 to i64*
%14 = load volatile i64, i64* %13
%15 = and i64 %14, -4
%16 = or i64 %15, %1
store volatile i64 %16, i64* %13
ret void
}