#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);
uint32_t ADCIntStatus(uint32_t ui32Base, uint32_t ui32SequenceNum,
                      bool bMasked) {
  uint32_t ui32Temp;
  ASSERT((ui32Base == 0x40038000) || (ui32Base == 0x40039000));
  ASSERT(ui32SequenceNum < 4);
  if (bMasked) {
    ui32Temp = (*((volatile uint32_t *)(ui32Base + 0x0000000C))) &
               (0x10001 << ui32SequenceNum);
  } else {
    ui32Temp = ((*((volatile uint32_t *)(ui32Base + 0x00000004))) &
                (0x10000 | (1 << ui32SequenceNum)));
    if (ui32Temp & 0x10000) {
      ui32Temp |= 0xF0000;
      ui32Temp &= ~(0x10000 << ui32SequenceNum);
    }
  }
  return (ui32Temp);
}


x86 assembly (clang, -O0):
<ADCIntStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x40038000,-0x4(%rbp)
mov    %al,-0x11(%rbp)
je     1140 <ADCIntStatus+0x30>
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   $0x4,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x0,-0xc(%rbp)
je     1188 <ADCIntStatus+0x78>
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
mov    $0x10001,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11dd <ADCIntStatus+0xcd>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     $0x10000,%ecx
and    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     11d8 <ADCIntStatus+0xc8>
mov    -0x10(%rbp),%eax
or     $0xf0000,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x10000,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11dd <ADCIntStatus+0xcd>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADCIntStatus>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%eax
and    $0xffffefff,%eax
xor    %edi,%edi
cmp    $0x40038000,%eax
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x4,%ebx
setl   %dil
call   1030 <ASSERT@plt>
test   %r14d,%r14d
je     1156 <ADCIntStatus+0x46>
mov    $0x10001,%eax
mov    %ebx,%ecx
shl    %cl,%eax
movslq %ebp,%rcx
and    0xc(%rcx),%eax
jmp    1180 <ADCIntStatus+0x70>
movslq %ebp,%rax
mov    0x4(%rax),%ecx
mov    $0x10000,%edx
mov    $0x10000,%eax
bts    %ebx,%eax
and    %ecx,%eax
test   $0x10000,%ecx
je     1180 <ADCIntStatus+0x70>
mov    %ebx,%ecx
shl    %cl,%edx
or     $0xf0000,%eax
not    %edx
and    %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ADCIntStatus(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1073971200
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %4
%12 = icmp eq i32 %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 @ASSERT(i32 %15)
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 4
%19 = zext i1 %18 to i32
%20 = call i32 @ASSERT(i32 %19)
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %13
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 12
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = load volatile i32, i32* %27
%29 = load i32, i32* %5
%30 = shl i32 65537, %29
%31 = and i32 %28, %30
store i32 %31, i32* %7
br label %54
32: ; preds = %13
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 4
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i32*
%37 = load volatile i32, i32* %36
%38 = load i32, i32* %5
%39 = shl i32 1, %38
%40 = or i32 65536, %39
%41 = and i32 %37, %40
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = and i32 %42, 65536
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %32
%46 = load i32, i32* %7
%47 = or i32 %46, 983040
store i32 %47, i32* %7
%48 = load i32, i32* %5
%49 = shl i32 65536, %48
%50 = xor i32 %49, -1
%51 = load i32, i32* %7
%52 = and i32 %51, %50
store i32 %52, i32* %7
br label %53
53: ; preds = %45, %32
br label %54
54: ; preds = %53, %23
%55 = load i32, i32* %7
ret i32 %55
}

LLVM IR (-O2):
define i32 @ADCIntStatus(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %0, -4097
%5 = icmp eq i32 %4, 1073971200
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = icmp slt i32 %1, 4
%9 = zext i1 %8 to i32
%10 = tail call i32 @ASSERT(i32 %9)
%11 = icmp eq i32 %2, 0
br i1 %11, label %19, label %12
12: ; preds = %3
%13 = add nsw i32 %0, 12
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
%17 = shl i32 65537, %1
%18 = and i32 %16, %17
br label %34
19: ; preds = %3
%20 = add nsw i32 %0, 4
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = load volatile i32, i32* %22
%24 = shl nuw i32 1, %1
%25 = or i32 %24, 65536
%26 = and i32 %23, %25
%27 = and i32 %23, 65536
%28 = icmp eq i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %19
%30 = or i32 %26, 983040
%31 = shl i32 65536, %1
%32 = xor i32 %31, -1
%33 = and i32 %30, %32
br label %34
34: ; preds = %19, %29, %12
%35 = phi i32 [ %18, %12 ], [ %33, %29 ], [ %26, %19 ]
ret i32 %35
}