#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 */
struct iw_freq {
  short e;
  long m;
};

/* Variables and functions */
scalar_t__ floor(double);
double log10(double);
double pow(int, int);
void iw_float2freq(double in, struct iw_freq *out) {
  out->e = (short)(floor(log10(in)));
  if (out->e > 8) {
    out->m = ((long)(floor(in / pow(10, out->e - 6)))) * 100;
    out->e -= 8;
  } else {
    out->m = in;
    out->e = 0;
  }
}


x86 assembly (clang, -O0):
<iw_float2freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log10@plt>
call   1050 <floor@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
movswl (%rax),%eax
cmp    $0x8,%eax
jle    11b7 <iw_float2freq+0x87>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movswl (%rax),%esi
sub    $0x6,%esi
mov    $0xa,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
imul   $0x64,%rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
movswl (%rax),%ecx
sub    $0x8,%ecx
mov    %cx,(%rax)
jmp    11ce <iw_float2freq+0x9e>
cvttsd2si -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
movw   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_float2freq>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
call   1040 <log10@plt>
call   1050 <floor@plt>
mov    %ax,(%rbx)
cmp    $0x9,%ax
jl     117f <iw_float2freq+0x4f>
movzwl %ax,%esi
add    $0xfffffffa,%esi
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <floor@plt>
imul   $0x64,%rax,%rax
mov    (%rbx),%ecx
add    $0xfffffff8,%ecx
jmp    1188 <iw_float2freq+0x58>
cvttsd2si 0x8(%rsp),%rax
xor    %ecx,%ecx
mov    %rax,0x8(%rbx)
mov    %cx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.iw_freq = type { i16, i64 }
define void @iw_float2freq(double %0, %struct.iw_freq* %1) {
%3 = alloca double
%4 = alloca %struct.iw_freq*
store double %0, double* %3
store %struct.iw_freq* %1, %struct.iw_freq** %4
%5 = load double, double* %3
%6 = call double @log10(double %5)
%7 = call i64 @floor(double %6)
%8 = trunc i64 %7 to i16
%9 = load %struct.iw_freq*, %struct.iw_freq** %4
%10 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %9, i32 0, i32 0
store i16 %8, i16* %10
%11 = load %struct.iw_freq*, %struct.iw_freq** %4
%12 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %11, i32 0, i32 0
%13 = load i16, i16* %12
%14 = sext i16 %13 to i32
%15 = icmp sgt i32 %14, 8
br i1 %15, label %16, label %35
16: ; preds = %2
%17 = load double, double* %3
%18 = load %struct.iw_freq*, %struct.iw_freq** %4
%19 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %18, i32 0, i32 0
%20 = load i16, i16* %19
%21 = sext i16 %20 to i32
%22 = sub nsw i32 %21, 6
%23 = call double @pow(i32 10, i32 %22)
%24 = fdiv double %17, %23
%25 = call i64 @floor(double %24)
%26 = mul nsw i64 %25, 100
%27 = load %struct.iw_freq*, %struct.iw_freq** %4
%28 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %27, i32 0, i32 1
store i64 %26, i64* %28
%29 = load %struct.iw_freq*, %struct.iw_freq** %4
%30 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %29, i32 0, i32 0
%31 = load i16, i16* %30
%32 = sext i16 %31 to i32
%33 = sub nsw i32 %32, 8
%34 = trunc i32 %33 to i16
store i16 %34, i16* %30
br label %42
35: ; preds = %2
%36 = load double, double* %3
%37 = fptosi double %36 to i64
%38 = load %struct.iw_freq*, %struct.iw_freq** %4
%39 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %38, i32 0, i32 1
store i64 %37, i64* %39
%40 = load %struct.iw_freq*, %struct.iw_freq** %4
%41 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %40, i32 0, i32 0
store i16 0, i16* %41
br label %42
42: ; preds = %35, %16
ret void
}

LLVM IR (-O2):
%struct.iw_freq = type { i16, i64 }
define void @iw_float2freq(double %0, %struct.iw_freq* nocapture %1) {
%3 = tail call double @log10(double %0)
%4 = tail call i64 @floor(double %3)
%5 = trunc i64 %4 to i16
%6 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %1, i64 0, i32 0
store i16 %5, i16* %6
%7 = icmp sgt i16 %5, 8
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = trunc i64 %4 to i32
%10 = and i32 %9, 65535
%11 = add nsw i32 %10, -6
%12 = tail call double @pow(i32 10, i32 %11)
%13 = fdiv double %0, %12
%14 = tail call i64 @floor(double %13)
%15 = mul nsw i64 %14, 100
%16 = load i16, i16* %6
%17 = add i16 %16, -8
br label %20
18: ; preds = %2
%19 = fptosi double %0 to i64
br label %20
20: ; preds = %18, %8
%21 = phi i64 [ %15, %8 ], [ %19, %18 ]
%22 = phi i16 [ %17, %8 ], [ 0, %18 ]
%23 = getelementptr inbounds %struct.iw_freq, %struct.iw_freq* %1, i64 0, i32 1
store i64 %21, i64* %23
store i16 %22, i16* %6
ret void
}