#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ i2cSendRegister(int, int);
int /*<<< orphan*/ setupMultisynth(int, int, int);
int /*<<< orphan*/ setupPLL(int, int, int, int);
void si5351aSetClk1Frequency(uint32_t frequency) {
  uint32_t pllFreq;
  uint32_t xtalFreq = 27000000;
  uint32_t l;
  float f;
  uint8_t mult;
  uint32_t num;
  uint32_t denom;
  uint32_t divider;
  divider = 900000000 / frequency;
  if (divider % 2)
    divider--;
  pllFreq = divider * frequency;
  mult = pllFreq / xtalFreq;
  l = pllFreq % xtalFreq;
  f = l;
  f *= 1048575;
  f /= xtalFreq;
  num = f;
  denom = 1048575;
  setupPLL(34, mult, num, denom);
  setupMultisynth(50, divider, 0b00000000);
  i2cSendRegister(177, 0xA0);
  i2cSendRegister(17, 0x4F | 0b00100000);
}


x86 assembly (clang, -O0):
<si5351aSetClk1Frequency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x19bfcc0,-0xc(%rbp)
mov    $0x35a4e900,%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     116b <si5351aSetClk1Frequency+0x3b>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe65(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0xfffff,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x22,%edi
call   1050 <setupPLL@plt>
mov    -0x24(%rbp),%esi
mov    $0x32,%edi
xor    %edx,%edx
call   1040 <setupMultisynth@plt>
mov    $0xb1,%edi
mov    $0xa0,%esi
call   1030 <i2cSendRegister@plt>
mov    $0x11,%edi
mov    $0x6f,%esi
call   1030 <i2cSendRegister@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<si5351aSetClk1Frequency>:
push   %rbx
mov    $0x35a4e900,%eax
xor    %edx,%edx
idiv   %edi
mov    %eax,%ebx
and    $0xfffffffe,%ebx
imul   %ebx,%edi
movslq %edi,%rax
imul   $0x27c4a9c9,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x36,%rsi
add    %ecx,%esi
imul   $0x19bfcc0,%esi,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
mulss  0xe93(%rip),%xmm0
divss  0xe8f(%rip),%xmm0
cvttss2si %xmm0,%edx
mov    $0x22,%edi
mov    $0xfffff,%ecx
call   1050 <setupPLL@plt>
mov    $0x32,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1040 <setupMultisynth@plt>
mov    $0xb1,%edi
mov    $0xa0,%esi
call   1030 <i2cSendRegister@plt>
mov    $0x11,%edi
mov    $0x6f,%esi
pop    %rbx
jmp    1030 <i2cSendRegister@plt>

LLVM IR (-O0):
define void @si5351aSetClk1Frequency(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %2
store i32 27000000, i32* %4
%11 = load i32, i32* %2
%12 = sdiv i32 900000000, %11
store i32 %12, i32* %10
%13 = load i32, i32* %10
%14 = srem i32 %13, 2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %10
%18 = add nsw i32 %17, -1
store i32 %18, i32* %10
br label %19
19: ; preds = %16, %1
%20 = load i32, i32* %10
%21 = load i32, i32* %2
%22 = mul nsw i32 %20, %21
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sdiv i32 %23, %24
store i32 %25, i32* %7
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = srem i32 %26, %27
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = sitofp i32 %29 to float
store float %30, float* %6
%31 = load float, float* %6
%32 = fmul float %31, 0x412FFFFE00000000
store float %32, float* %6
%33 = load i32, i32* %4
%34 = sitofp i32 %33 to float
%35 = load float, float* %6
%36 = fdiv float %35, %34
store float %36, float* %6
%37 = load float, float* %6
%38 = fptosi float %37 to i32
store i32 %38, i32* %8
store i32 1048575, i32* %9
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 @setupPLL(i32 34, i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %10
%44 = call i32 @setupMultisynth(i32 50, i32 %43, i32 0)
%45 = call i32 @i2cSendRegister(i32 177, i32 160)
%46 = call i32 @i2cSendRegister(i32 17, i32 111)
ret void
}

LLVM IR (-O2):
define void @si5351aSetClk1Frequency(i32 %0) {
%2 = sdiv i32 900000000, %0
%3 = and i32 %2, -2
%4 = mul nsw i32 %3, %0
%5 = sdiv i32 %4, 27000000
%6 = srem i32 %4, 27000000
%7 = sitofp i32 %6 to float
%8 = fmul float %7, 0x412FFFFE00000000
%9 = fdiv float %8, 2.700000e+07
%10 = fptosi float %9 to i32
%11 = tail call i32 @setupPLL(i32 34, i32 %5, i32 %10, i32 1048575)
%12 = tail call i32 @setupMultisynth(i32 50, i32 %3, i32 0)
%13 = tail call i32 @i2cSendRegister(i32 177, i32 160)
%14 = tail call i32 @i2cSendRegister(i32 17, i32 111)
ret void
}