#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);
unsigned long LPCStatusGet(unsigned long ulBase, unsigned long *pulCount,
                           unsigned long *pulPoolSize) {
  unsigned long ulStatus;
  DEBUG_ASSERT(ulBase == 0x40080000);
  ulStatus = (*((volatile unsigned long *)(ulBase + 0x00000004)));
  if (pulCount) {
    *pulCount = (((ulStatus & 0x00700000) >> 20) + 1);
  }
  if (pulPoolSize) {
    *pulPoolSize = (((ulStatus & 0x00070000) >> 16) * 256);
  }
  return (ulStatus);
}


x86 assembly (clang, -O0):
<LPCStatusGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x40080000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116a <LPCStatusGet+0x5a>
mov    -0x20(%rbp),%rcx
and    $0x700000,%rcx
shr    $0x14,%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     118f <LPCStatusGet+0x7f>
mov    -0x20(%rbp),%rcx
and    $0x70000,%rcx
shr    $0x10,%rcx
shl    $0x8,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCStatusGet>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x40080000,%rbx
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x4(%rbx),%rax
test   %r15,%r15
je     1148 <LPCStatusGet+0x38>
mov    %eax,%ecx
shr    $0x14,%ecx
and    $0x7,%ecx
add    $0x1,%rcx
mov    %rcx,(%r15)
test   %r14,%r14
je     115d <LPCStatusGet+0x4d>
mov    %rax,%rcx
shr    $0x8,%rcx
and    $0x700,%ecx
mov    %rcx,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @LPCStatusGet(i64 %0, i64* %1, i64* %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%8 = load i64, i64* %4
%9 = icmp eq i64 %8, 1074266112
%10 = zext i1 %9 to i32
%11 = call i32 @DEBUG_ASSERT(i32 %10)
%12 = load i64, i64* %4
%13 = add i64 %12, 4
%14 = inttoptr i64 %13 to i64*
%15 = load volatile i64, i64* %14
store i64 %15, i64* %7
%16 = load i64*, i64** %5
%17 = icmp ne i64* %16, null
br i1 %17, label %18, label %24
18: ; preds = %3
%19 = load i64, i64* %7
%20 = and i64 %19, 7340032
%21 = lshr i64 %20, 20
%22 = add i64 %21, 1
%23 = load i64*, i64** %5
store i64 %22, i64* %23
br label %24
24: ; preds = %18, %3
%25 = load i64*, i64** %6
%26 = icmp ne i64* %25, null
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i64, i64* %7
%29 = and i64 %28, 458752
%30 = lshr i64 %29, 16
%31 = mul i64 %30, 256
%32 = load i64*, i64** %6
store i64 %31, i64* %32
br label %33
33: ; preds = %27, %24
%34 = load i64, i64* %7
ret i64 %34
}

LLVM IR (-O2):
define i64 @LPCStatusGet(i64 %0, i64* writeonly %1, i64* writeonly %2) {
%4 = icmp eq i64 %0, 1074266112
%5 = zext i1 %4 to i32
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = add i64 %0, 4
%8 = inttoptr i64 %7 to i64*
%9 = load volatile i64, i64* %8
%10 = icmp eq i64* %1, null
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = lshr i64 %9, 20
%13 = and i64 %12, 7
%14 = add nuw nsw i64 %13, 1
store i64 %14, i64* %1
br label %15
15: ; preds = %11, %3
%16 = icmp eq i64* %2, null
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = lshr i64 %9, 8
%19 = and i64 %18, 1792
store i64 %19, i64* %2
br label %20
20: ; preds = %17, %15
ret i64 %9
}