#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*/ pci_conf_read(int /*<<< orphan*/, int, int, int, int,
                                 unsigned long *);
int /*<<< orphan*/ pci_conf_write(int /*<<< orphan*/, int, int, int, int,
                                  unsigned long);
int /*<<< orphan*/ print_ecc_err(unsigned long, unsigned long, int,
                                 unsigned long, int /*<<< orphan*/);
void poll_amd64(void) {
  unsigned long mcanb;
  unsigned long page, offset;
  unsigned long celog_syndrome;
  unsigned long mcanb_add;
  pci_conf_read(0, 24, 3, 0x4C, 4, &mcanb);
  if (((mcanb >> 31) & 1) && ((mcanb >> 14) & 1)) {
    pci_conf_read(0, 24, 3, 0x50, 4, &mcanb_add);
    celog_syndrome = (mcanb >> 15) & 0xFF;
    page = (mcanb_add >> 12);
    offset = (mcanb_add >> 3) & 0xFFF;
    print_ecc_err(page, offset, 1, celog_syndrome, 0);
    pci_conf_write(0, 24, 3, 0x4C, 4, mcanb & 0x7FFFFFFF);
  }
  if (((mcanb >> 31) & 1) && ((mcanb >> 13) & 1)) {
    pci_conf_read(0, 24, 3, 0x50, 4, &mcanb_add);
    page = (mcanb_add >> 12);
    offset = (mcanb_add >> 3) & 0xFFF;
    print_ecc_err(page, offset, 0, 0, 0);
    pci_conf_write(0, 24, 3, 0x4C, 4, mcanb & 0x7FFFFFF);
  }
}


x86 assembly (clang, -O0):
<poll_amd64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
lea    -0x8(%rbp),%r9
call   1040 <pci_conf_read@plt>
mov    -0x8(%rbp),%rax
shr    $0x1f,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1214 <poll_amd64+0xe4>
mov    -0x8(%rbp),%rax
shr    $0xe,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1214 <poll_amd64+0xe4>
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x50,%ecx
mov    $0x4,%r8d
lea    -0x28(%rbp),%r9
call   1040 <pci_conf_read@plt>
mov    -0x8(%rbp),%rax
shr    $0xf,%rax
and    $0xff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
shr    $0xc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x3,%rax
and    $0xfff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
xor    %r8d,%r8d
call   1030 <print_ecc_err@plt>
mov    -0x8(%rbp),%r9
and    $0x7fffffff,%r9
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
call   1050 <pci_conf_write@plt>
mov    -0x8(%rbp),%rax
shr    $0x1f,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     12bc <poll_amd64+0x18c>
mov    -0x8(%rbp),%rax
shr    $0xd,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     12bc <poll_amd64+0x18c>
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x50,%ecx
mov    $0x4,%r8d
lea    -0x28(%rbp),%r9
call   1040 <pci_conf_read@plt>
mov    -0x28(%rbp),%rax
shr    $0xc,%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x3,%rax
and    $0xfff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1030 <print_ecc_err@plt>
mov    -0x8(%rbp),%r9
and    $0x7ffffff,%r9
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
call   1050 <pci_conf_write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poll_amd64>:
push   %rbx
sub    $0x10,%rsp
mov    $0x80002000,%ebx
mov    %rsp,%r9
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
call   1040 <pci_conf_read@plt>
mov    (%rsp),%rax
mov    %eax,%ecx
and    $0x80004000,%ecx
lea    0x2000(%rbx),%rdx
cmp    %rdx,%rcx
jne    11e8 <poll_amd64+0xb8>
lea    0x8(%rsp),%r9
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x50,%ecx
mov    $0x4,%r8d
call   1040 <pci_conf_read@plt>
mov    (%rsp),%eax
shr    $0xf,%eax
movzbl %al,%ecx
mov    0x8(%rsp),%rsi
mov    %rsi,%rdi
shr    $0xc,%rdi
shr    $0x3,%esi
and    $0xfff,%esi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1030 <print_ecc_err@plt>
mov    (%rsp),%r9
and    $0x7fffffff,%r9d
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
call   1050 <pci_conf_write@plt>
mov    (%rsp),%rax
and    $0x80002000,%eax
cmp    %rbx,%rax
jne    125b <poll_amd64+0x12b>
lea    0x8(%rsp),%r9
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x50,%ecx
mov    $0x4,%r8d
call   1040 <pci_conf_read@plt>
mov    0x8(%rsp),%rsi
mov    %rsi,%rdi
shr    $0xc,%rdi
shr    $0x3,%esi
and    $0xfff,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <print_ecc_err@plt>
mov    (%rsp),%r9
and    $0x7ffffff,%r9d
xor    %edi,%edi
mov    $0x18,%esi
mov    $0x3,%edx
mov    $0x4c,%ecx
mov    $0x4,%r8d
call   1050 <pci_conf_write@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @poll_amd64() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 76, i32 4, i64* %1)
%7 = load i64, i64* %1
%8 = lshr i64 %7, 31
%9 = and i64 %8, 1
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %0
%12 = load i64, i64* %1
%13 = lshr i64 %12, 14
%14 = and i64 %13, 1
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %11
%17 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 80, i32 4, i64* %5)
%18 = load i64, i64* %1
%19 = lshr i64 %18, 15
%20 = and i64 %19, 255
store i64 %20, i64* %4
%21 = load i64, i64* %5
%22 = lshr i64 %21, 12
store i64 %22, i64* %2
%23 = load i64, i64* %5
%24 = lshr i64 %23, 3
%25 = and i64 %24, 4095
store i64 %25, i64* %3
%26 = load i64, i64* %2
%27 = load i64, i64* %3
%28 = load i64, i64* %4
%29 = call i32 @print_ecc_err(i64 %26, i64 %27, i32 1, i64 %28, i32 0)
%30 = load i64, i64* %1
%31 = and i64 %30, 2147483647
%32 = call i32 @pci_conf_write(i32 0, i32 24, i32 3, i32 76, i32 4, i64 %31)
br label %33
33: ; preds = %16, %11, %0
%34 = load i64, i64* %1
%35 = lshr i64 %34, 31
%36 = and i64 %35, 1
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %33
%39 = load i64, i64* %1
%40 = lshr i64 %39, 13
%41 = and i64 %40, 1
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %38
%44 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 80, i32 4, i64* %5)
%45 = load i64, i64* %5
%46 = lshr i64 %45, 12
store i64 %46, i64* %2
%47 = load i64, i64* %5
%48 = lshr i64 %47, 3
%49 = and i64 %48, 4095
store i64 %49, i64* %3
%50 = load i64, i64* %2
%51 = load i64, i64* %3
%52 = call i32 @print_ecc_err(i64 %50, i64 %51, i32 0, i64 0, i32 0)
%53 = load i64, i64* %1
%54 = and i64 %53, 134217727
%55 = call i32 @pci_conf_write(i32 0, i32 24, i32 3, i32 76, i32 4, i64 %54)
br label %56
56: ; preds = %43, %38, %33
ret void
}

LLVM IR (-O2):
define void @poll_amd64() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 76, i32 4, i64* %1)
%6 = load i64, i64* %1
%7 = and i64 %6, 2147500032
%8 = icmp eq i64 %7, 2147500032
br i1 %8, label %9, label %23
9: ; preds = %0
%10 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 80, i32 4, i64* %2)
%11 = load i64, i64* %1
%12 = lshr i64 %11, 15
%13 = and i64 %12, 255
%14 = load i64, i64* %2
%15 = lshr i64 %14, 12
%16 = lshr i64 %14, 3
%17 = and i64 %16, 4095
%18 = call i32 @print_ecc_err(i64 %15, i64 %17, i32 1, i64 %13, i32 0)
%19 = load i64, i64* %1
%20 = and i64 %19, 2147483647
%21 = call i32 @pci_conf_write(i32 0, i32 24, i32 3, i32 76, i32 4, i64 %20)
%22 = load i64, i64* %1
br label %23
23: ; preds = %9, %0
%24 = phi i64 [ %22, %9 ], [ %6, %0 ]
%25 = and i64 %24, 2147491840
%26 = icmp eq i64 %25, 2147491840
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = call i32 @pci_conf_read(i32 0, i32 24, i32 3, i32 80, i32 4, i64* %2)
%29 = load i64, i64* %2
%30 = lshr i64 %29, 12
%31 = lshr i64 %29, 3
%32 = and i64 %31, 4095
%33 = call i32 @print_ecc_err(i64 %30, i64 %32, i32 0, i64 0, i32 0)
%34 = load i64, i64* %1
%35 = and i64 %34, 134217727
%36 = call i32 @pci_conf_write(i32 0, i32 24, i32 3, i32 76, i32 4, i64 %35)
br label %37
37: ; preds = %27, %23
ret void
}