#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 */
uint32_t get_sclk_mpll() {
  uint32_t mdiv, pdiv, sdiv;
  mdiv = ((*((volatile uint32_t *)0xE0100108)) & 0x3ff0000) >> 16;
  pdiv = ((*((volatile uint32_t *)0xE0100108)) & 0x3f00) >> 8;
  sdiv = (*((volatile uint32_t *)0xE0100108)) & 0x03;
  if ((*((volatile uint32_t *)0xE0100200)) & 0x10)
    return mdiv * ((24000000) / (pdiv << sdiv));
  else
    return (24000000);
}


x86 assembly (clang, -O0):
<get_sclk_mpll>:
push   %rbp
mov    %rsp,%rbp
mov    $0xe0100108,%eax
mov    (%rax),%eax
and    $0x3ff0000,%eax
sar    $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    $0xe0100108,%eax
mov    (%rax),%eax
and    $0x3f00,%eax
sar    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    $0xe0100108,%eax
mov    (%rax),%eax
and    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    $0xe0100200,%eax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1170 <get_sclk_mpll+0x70>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    $0x16e3600,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <get_sclk_mpll+0x77>
movl   $0x16e3600,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sclk_mpll>:
mov    $0xe0100108,%edx
mov    (%rdx),%esi
mov    (%rdx),%edi
mov    (%rdx),%ecx
mov    $0x16e3600,%eax
testl  $0x10,0xf8(%rdx)
je     113c <get_sclk_mpll+0x3c>
shr    $0x8,%edi
and    $0x3f,%edi
shr    $0x10,%esi
and    $0x3ff,%esi
and    $0x3,%cl
shl    %cl,%edi
mov    $0x16e3600,%eax
xor    %edx,%edx
div    %edi
imul   %esi,%eax
ret

LLVM IR (-O0):
define i32 @get_sclk_mpll() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%6 = and i32 %5, 67043328
%7 = ashr i32 %6, 16
store i32 %7, i32* %2
%8 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%9 = and i32 %8, 16128
%10 = ashr i32 %9, 8
store i32 %10, i32* %3
%11 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%12 = and i32 %11, 3
store i32 %12, i32* %4
%13 = load volatile i32, i32* inttoptr (i64 3759145472 to i32*)
%14 = and i32 %13, 16
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = shl i32 %18, %19
%21 = sdiv i32 24000000, %20
%22 = mul nsw i32 %17, %21
store i32 %22, i32* %1
br label %24
23: ; preds = %0
store i32 24000000, i32* %1
br label %24
24: ; preds = %23, %16
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
define i32 @get_sclk_mpll() {
%1 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%2 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%3 = load volatile i32, i32* inttoptr (i64 3759145224 to i32*)
%4 = load volatile i32, i32* inttoptr (i64 3759145472 to i32*)
%5 = and i32 %4, 16
%6 = icmp eq i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %0
%8 = and i32 %3, 3
%9 = lshr i32 %2, 8
%10 = and i32 %9, 63
%11 = lshr i32 %1, 16
%12 = and i32 %11, 1023
%13 = shl nuw nsw i32 %10, %8
%14 = udiv i32 24000000, %13
%15 = mul nsw i32 %14, %12
br label %16
16: ; preds = %0, %7
%17 = phi i32 [ %15, %7 ], [ 24000000, %0 ]
ret i32 %17
}