#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 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 uint32_t *)(0x400FE160))) & 0x000FFC00) >> 10);
  ui16PInt = (*((volatile uint32_t *)(0x400FE160))) & 0x000003FF;
  ui8Q = ((((*((volatile uint32_t *)(0x400FE164))) & 0x00001F00) >> 8) + 1);
  ui8N = ((((*((volatile uint32_t *)(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),%eax
and    $0xffc00,%eax
sar    $0xa,%eax
mov    %eax,-0x18(%rbp)
mov    $0x400fe160,%eax
mov    (%rax),%eax
and    $0x3ff,%eax
mov    %eax,-0x14(%rbp)
mov    $0x400fe164,%eax
mov    (%rax),%eax
and    $0x1f00,%eax
sar    $0x8,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x400fe164,%eax
mov    (%rax),%eax
and    $0x1f,%eax
sar    $0x0,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%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
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_SysCtlFrequencyGet>:
mov    %edi,%eax
mov    0x400fe160,%esi
shr    $0xa,%esi
mov    %esi,%r9d
and    $0x3ff,%r9d
mov    $0x3ff,%r8d
and    0x400fe160,%r8d
40
mov    0x400fe164,%ecx
shr    $0x8,%ecx
and    $0x1f,%ecx
add    $0x1,%ecx
mov    0x400fe164,%edi
and    $0x1f,%edi
add    $0x1,%edi
cltd
idiv   %edi
mov    %r9d,%edx
shr    $0x5,%edx
and    $0x3e0,%esi
sub    %esi,%r9d
imul   %eax,%r8d
imul   %eax,%edx
lea    0x1f(%rdx),%esi
test   %edx,%edx
cmovns %edx,%esi
sar    $0x5,%esi
add    %r8d,%esi
imul   %r9d,%eax
lea    0x3ff(%rax),%edx
test   %eax,%eax
cmovs  %edx,%eax
sar    $0xa,%eax
add    %esi,%eax
cltd
idiv   %ecx
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 i32
%9 = alloca i32
store i32 %0, i32* %2
%10 = load volatile i32, i32* inttoptr (i64 1074782560 to i32*)
%11 = and i32 %10, 1047552
%12 = ashr i32 %11, 10
store i32 %12, i32* %7
%13 = load volatile i32, i32* inttoptr (i64 1074782560 to i32*)
%14 = and i32 %13, 1023
store i32 %14, i32* %6
%15 = load volatile i32, i32* inttoptr (i64 1074782564 to i32*)
%16 = and i32 %15, 7936
%17 = ashr i32 %16, 8
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
%19 = load volatile i32, i32* inttoptr (i64 1074782564 to i32*)
%20 = and i32 %19, 31
%21 = ashr i32 %20, 0
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = load i32, i32* %2
%25 = sdiv i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %7
%27 = sdiv i32 %26, 32
store i32 %27, i32* %4
%28 = load i32, i32* %7
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, 32
%31 = sub nsw i32 %28, %30
store i32 %31, i32* %5
%32 = load i32, i32* %2
%33 = load i32, i32* %6
%34 = mul nsw i32 %32, %33
store i32 %34, i32* %3
%35 = load i32, i32* %2
%36 = load i32, i32* %4
%37 = mul nsw i32 %35, %36
%38 = sdiv i32 %37, 32
%39 = load i32, i32* %3
%40 = add nsw i32 %39, %38
store i32 %40, i32* %3
%41 = load i32, i32* %2
%42 = load i32, i32* %5
%43 = mul nsw i32 %41, %42
%44 = sdiv i32 %43, 1024
%45 = load i32, i32* %3
%46 = add nsw i32 %45, %44
store i32 %46, i32* %3
%47 = load i32, i32* %3
%48 = load i32, i32* %8
%49 = sdiv i32 %47, %48
store i32 %49, i32* %3
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
define i32 @_SysCtlFrequencyGet(i32 %0) {
%2 = load volatile i32, i32* inttoptr (i64 1074782560 to i32*)
%3 = lshr i32 %2, 10
%4 = and i32 %3, 1023
%5 = load volatile i32, i32* inttoptr (i64 1074782560 to i32*)
%6 = and i32 %5, 1023
%7 = load volatile i32, i32* inttoptr (i64 1074782564 to i32*)
%8 = lshr i32 %7, 8
%9 = and i32 %8, 31
%10 = add nuw nsw i32 %9, 1
%11 = load volatile i32, i32* inttoptr (i64 1074782564 to i32*)
%12 = and i32 %11, 31
%13 = add nuw nsw i32 %12, 1
%14 = sdiv i32 %0, %13
%15 = lshr i32 %4, 5
%16 = and i32 %3, 992
%17 = sub nsw i32 %4, %16
%18 = mul nsw i32 %14, %6
%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 = sdiv i32 %24, %10
ret i32 %25
}