#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 /*<<< orphan*/);
int /*<<< orphan*/ _CANBaseValid(int);
bool CANErrCntrGet(uint32_t ui32Base, uint32_t *pui32RxCount,
                   uint32_t *pui32TxCount) {
  uint32_t ui32CANError;
  ASSERT(_CANBaseValid(ui32Base));
  ui32CANError = (*((volatile uint32_t *)(ui32Base + 0x00000008)));
  *pui32RxCount = (ui32CANError & 0x00007F00) >> 8;
  *pui32TxCount = (ui32CANError & 0x000000FF) >> 0;
  if (ui32CANError & 0x00008000) {
    return (true);
  }
  return (false);
}


x86 assembly (clang, -O0):
<CANErrCntrGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <_CANBaseValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
mov    -0x8(%rbp),%eax
add    $0x8,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
and    $0x7f00,%ecx
sar    $0x8,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xff,%ecx
sar    $0x0,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1190 <CANErrCntrGet+0x70>
movl   $0x1,-0x4(%rbp)
jmp    1197 <CANErrCntrGet+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANErrCntrGet>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <_CANBaseValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
movslq %ebp,%rax
mov    0x8(%rax),%eax
mov    %eax,%ecx
shr    $0x8,%ecx
and    $0x7f,%ecx
mov    %ecx,(%rbx)
movzbl %al,%ecx
mov    %ecx,(%r14)
shr    $0xf,%eax
and    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CANErrCntrGet(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%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
%9 = load i32, i32* %5
%10 = call i32 @_CANBaseValid(i32 %9)
%11 = call i32 @ASSERT(i32 %10)
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 8
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = and i32 %17, 32512
%19 = ashr i32 %18, 8
%20 = load i32*, i32** %6
store i32 %19, i32* %20
%21 = load i32, i32* %8
%22 = and i32 %21, 255
%23 = ashr i32 %22, 0
%24 = load i32*, i32** %7
store i32 %23, i32* %24
%25 = load i32, i32* %8
%26 = and i32 %25, 32768
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %3
store i32 1, i32* %4
br label %30
29: ; preds = %3
store i32 0, i32* %4
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @CANErrCntrGet(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @_CANBaseValid(i32 %0)
%5 = tail call i32 @ASSERT(i32 %4)
%6 = add nsw i32 %0, 8
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i32*
%9 = load volatile i32, i32* %8
%10 = lshr i32 %9, 8
%11 = and i32 %10, 127
store i32 %11, i32* %1
%12 = and i32 %9, 255
store i32 %12, i32* %2
%13 = lshr i32 %9, 15
%14 = and i32 %13, 1
ret i32 %14
}