#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 /*<<< orphan*/,
                                 int /*<<< orphan*/, int, int, unsigned long *);
int /*<<< orphan*/ pci_conf_write(int /*<<< orphan*/, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ print_cpu_line(double, double, int);
void poll_fsb_us15w(void) {
  double dramclock, dramratio, fsb;
  unsigned long msr;
  pci_conf_write(0, 0, 0, 0xD0, 4, 0xD0050300);
  pci_conf_read(0, 0, 0, 0xD4, 4, &msr);
  fsb = (msr >> 3) & 1;
  dramratio = 0.5;
  if ((msr >> 3) & 1) {
    fsb = 533;
  } else {
    fsb = 400;
  }
  dramclock = fsb * dramratio;
  print_cpu_line(dramclock, fsb, 1);
}


x86 assembly (clang, -O0):
<poll_fsb_us15w>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %edx,%edx
mov    %edx,-0x28(%rbp)
mov    $0xd0,%ecx
mov    $0x4,%r8d
mov    %r8d,-0x24(%rbp)
mov    $0xd0050300,%r9d
mov    %edx,%edi
mov    %edx,%esi
call   1050 <pci_conf_write@plt>
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%r8d
mov    $0xd4,%ecx
lea    -0x20(%rbp),%r9
mov    %edx,%edi
mov    %edx,%esi
call   1030 <pci_conf_read@plt>
mov    -0x20(%rbp),%eax
shr    $0x3,%eax
and    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe72(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rax
shr    $0x3,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11bb <poll_fsb_us15w+0x8b>
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11c8 <poll_fsb_us15w+0x98>
movsd  0xe45(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    $0x1,%edi
call   1040 <print_cpu_line@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poll_fsb_us15w>:
push   %rax
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0xd0,%ecx
mov    $0x4,%r8d
mov    $0xd0050300,%r9d
call   1050 <pci_conf_write@plt>
mov    %rsp,%r9
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0xd4,%ecx
mov    $0x4,%r8d
call   1030 <pci_conf_read@plt>
xor    %eax,%eax
testb  $0x8,(%rsp)
sete   %al
lea    0xe8a(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm1
movsd  0xe8d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    $0x1,%edi
call   1040 <print_cpu_line@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @poll_fsb_us15w() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i64
%5 = call i32 @pci_conf_write(i32 0, i32 0, i32 0, i32 208, i32 4, i32 -804977920)
%6 = call i32 @pci_conf_read(i32 0, i32 0, i32 0, i32 212, i32 4, i64* %4)
%7 = load i64, i64* %4
%8 = lshr i64 %7, 3
%9 = and i64 %8, 1
%10 = uitofp i64 %9 to double
store double %10, double* %3
store double 5.000000e-01, double* %2
%11 = load i64, i64* %4
%12 = lshr i64 %11, 3
%13 = and i64 %12, 1
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %0
store double 5.330000e+02, double* %3
br label %17
16: ; preds = %0
store double 4.000000e+02, double* %3
br label %17
17: ; preds = %16, %15
%18 = load double, double* %3
%19 = load double, double* %2
%20 = fmul double %18, %19
store double %20, double* %1
%21 = load double, double* %1
%22 = load double, double* %3
%23 = call i32 @print_cpu_line(double %21, double %22, i32 1)
ret void
}

LLVM IR (-O2):
define void @poll_fsb_us15w() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @pci_conf_write(i32 0, i32 0, i32 0, i32 208, i32 4, i32 -804977920)
%4 = call i32 @pci_conf_read(i32 0, i32 0, i32 0, i32 212, i32 4, i64* %1)
%5 = load i64, i64* %1
%6 = and i64 %5, 8
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, double 4.000000e+02, double 5.330000e+02
%9 = fmul double %8, 5.000000e-01
%10 = call i32 @print_cpu_line(double %9, double %8, i32 1)
ret void
}