#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 unsigned long uint_fast8_t;
typedef int uint_fast16_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t _SysCtlFrequencyGet(uint32_t ui32Xtal) {
  uint32_t ui32Result;
  uint_fast16_t ui16F1, ui16F2;
  uint_fast16_t ui16PInt, ui16PFract;
  uint_fast8_t ui8Q, ui8N;
  ui16PFract =
      (((*((volatile unsigned long *)(0x400FE160))) & 0x000FFC00) >> 10);
  ui16PInt = (*((volatile unsigned long *)(0x400FE160))) & 0x000003FF;
  ui8Q =
      ((((*((volatile unsigned long *)(0x400FE164))) & 0x00001F00) >> 8) + 1);
  ui8N =
      ((((*((volatile unsigned long *)(0x400FE164))) & 0x0000001F) >> 0) + 1);
  ui32Xtal /= (uint32_t)ui8N;
  ui16F1 = ui16PFract / 32;
  ui16F2 = ui16PFract - (ui16F1 * 32);
  ui32Result = ui32Xtal * (uint32_t)ui16PInt;
  ui32Result += (ui32Xtal * (uint32_t)ui16F1) / 32;
  ui32Result += (ui32Xtal * (uint32_t)ui16F2) / 1024;
  ui32Result = ui32Result / (uint32_t)ui8Q;
  return (ui32Result);
}


x86 assembly (clang, -O0):
<_SysCtlFrequencyGet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0x400fe160,%eax
mov    (%rax),%rax
and    $0xffc00,%rax
shr    $0xa,%rax
mov    %eax,-0x18(%rbp)
mov    $0x400fe160,%eax
mov    (%rax),%rax
and    $0x3ff,%rax
mov    %eax,-0x14(%rbp)
mov    $0x400fe164,%eax
mov    (%rax),%rax
and    $0x1f00,%rax
shr    $0x8,%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    $0x400fe164,%eax
mov    (%rax),%rax
and    $0x1f,%rax
shr    $0x0,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x5,%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x20(%rbp),%rcx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_SysCtlFrequencyGet>:
mov    %edi,%eax
mov    0x400fe160,%rdi
40
shr    $0xa,%edi
mov    %edi,%esi
and    $0x3ff,%esi
mov    0x400fe160,%r8
40
and    $0x3ff,%r8d
mov    0x400fe164,%r9
40
mov    0x400fe164,%rcx
40
and    $0x1f,%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %esi,%ecx
shr    $0x5,%ecx
and    $0x3e0,%edi
sub    %edi,%esi
imul   %eax,%r8d
imul   %eax,%ecx
lea    0x1f(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0x5,%edx
add    %r8d,%edx
imul   %esi,%eax
lea    0x3ff(%rax),%ecx
test   %eax,%eax
cmovs  %ecx,%eax
sar    $0xa,%eax
add    %edx,%eax
shr    $0x8,%r9d
and    $0x1f,%r9d
add    $0x1,%r9d
cltd
idiv   %r9d
ret

LLVM IR (-O0):
define i32 @_SysCtlFrequencyGet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32 %0, i32* %2
%10 = load volatile i64, i64* inttoptr (i64 1074782560 to i64*)
%11 = and i64 %10, 1047552
%12 = lshr i64 %11, 10
%13 = trunc i64 %12 to i32
store i32 %13, i32* %7
%14 = load volatile i64, i64* inttoptr (i64 1074782560 to i64*)
%15 = and i64 %14, 1023
%16 = trunc i64 %15 to i32
store i32 %16, i32* %6
%17 = load volatile i64, i64* inttoptr (i64 1074782564 to i64*)
%18 = and i64 %17, 7936
%19 = lshr i64 %18, 8
%20 = add i64 %19, 1
store i64 %20, i64* %8
%21 = load volatile i64, i64* inttoptr (i64 1074782564 to i64*)
%22 = and i64 %21, 31
%23 = lshr i64 %22, 0
%24 = add i64 %23, 1
store i64 %24, i64* %9
%25 = load i64, i64* %9
%26 = trunc i64 %25 to i32
%27 = load i32, i32* %2
%28 = sdiv i32 %27, %26
store i32 %28, i32* %2
%29 = load i32, i32* %7
%30 = sdiv i32 %29, 32
store i32 %30, i32* %4
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = mul nsw i32 %32, 32
%34 = sub nsw i32 %31, %33
store i32 %34, i32* %5
%35 = load i32, i32* %2
%36 = load i32, i32* %6
%37 = mul nsw i32 %35, %36
store i32 %37, i32* %3
%38 = load i32, i32* %2
%39 = load i32, i32* %4
%40 = mul nsw i32 %38, %39
%41 = sdiv i32 %40, 32
%42 = load i32, i32* %3
%43 = add nsw i32 %42, %41
store i32 %43, i32* %3
%44 = load i32, i32* %2
%45 = load i32, i32* %5
%46 = mul nsw i32 %44, %45
%47 = sdiv i32 %46, 1024
%48 = load i32, i32* %3
%49 = add nsw i32 %48, %47
store i32 %49, i32* %3
%50 = load i32, i32* %3
%51 = load i64, i64* %8
%52 = trunc i64 %51 to i32
%53 = sdiv i32 %50, %52
store i32 %53, i32* %3
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
define i32 @_SysCtlFrequencyGet(i32 %0) {
%2 = load volatile i64, i64* inttoptr (i64 1074782560 to i64*)
%3 = trunc i64 %2 to i32
%4 = lshr i32 %3, 10
%5 = and i32 %4, 1023
%6 = load volatile i64, i64* inttoptr (i64 1074782560 to i64*)
%7 = trunc i64 %6 to i32
%8 = and i32 %7, 1023
%9 = load volatile i64, i64* inttoptr (i64 1074782564 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 1074782564 to i64*)
%11 = trunc i64 %10 to i32
%12 = and i32 %11, 31
%13 = add nuw nsw i32 %12, 1
%14 = sdiv i32 %0, %13
%15 = lshr i32 %5, 5
%16 = and i32 %4, 992
%17 = sub nsw i32 %5, %16
%18 = mul nsw i32 %14, %8
%19 = mul nsw i32 %14, %15
%20 = sdiv i32 %19, 32
%21 = add nsw i32 %20, %18
%22 = mul nsw i32 %14, %17
%23 = sdiv i32 %22, 1024
%24 = add nsw i32 %21, %23
%25 = trunc i64 %9 to i32
%26 = lshr i32 %25, 8
%27 = and i32 %26, 31
%28 = add nuw nsw i32 %27, 1
%29 = sdiv i32 %24, %28
ret i32 %29
}