#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 */

/* Variables and functions */
double floor(double);
double primefactor(double num, double den, double base) {
  double powe, div;
  powe = 0.0;
  div = num;
  while (div == floor(div)) {
    div = div / base;
    powe++;
  }
  div = den;
  while (div == floor(div)) {
    div = div / base;
    powe--;
  }
  return powe;
}


x86 assembly (clang, -O0):
<primefactor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    118b <primefactor+0x7b>
jp     118b <primefactor+0x7b>
movsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8c(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1139 <primefactor+0x29>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    11e7 <primefactor+0xd7>
jp     11e7 <primefactor+0xd7>
movsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe28(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1195 <primefactor+0x85>
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primefactor>:
sub    $0x28,%rsp
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
call   1030 <floor@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1191 <primefactor+0x81>
jp     1191 <primefactor+0x81>
movapd %xmm1,%xmm0
xorpd  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
divsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
addsd  0xe9c(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
jne    1195 <primefactor+0x85>
jnp    1150 <primefactor+0x40>
jmp    1195 <primefactor+0x85>
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1204 <primefactor+0xf4>
jp     1204 <primefactor+0xf4>
movsd  0x8(%rsp),%xmm0
nopw   0x0(%rax,%rax,1)
divsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
addsd  0xe34(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
jne    11ff <primefactor+0xef>
jnp    11c0 <primefactor+0xb0>
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @primefactor(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
%9 = load double, double* %4
store double %9, double* %8
br label %10
10: ; preds = %15, %3
%11 = load double, double* %8
%12 = load double, double* %8
%13 = call double @llvm.floor.f64(double %12)
%14 = fcmp oeq double %11, %13
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load double, double* %8
%17 = load double, double* %6
%18 = fdiv double %16, %17
store double %18, double* %8
%19 = load double, double* %7
%20 = fadd double %19, 1.000000e+00
store double %20, double* %7
br label %10
21: ; preds = %10
%22 = load double, double* %5
store double %22, double* %8
br label %23
23: ; preds = %28, %21
%24 = load double, double* %8
%25 = load double, double* %8
%26 = call double @llvm.floor.f64(double %25)
%27 = fcmp oeq double %24, %26
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load double, double* %8
%30 = load double, double* %6
%31 = fdiv double %29, %30
store double %31, double* %8
%32 = load double, double* %7
%33 = fadd double %32, -1.000000e+00
store double %33, double* %7
br label %23
34: ; preds = %23
%35 = load double, double* %7
ret double %35
}

LLVM IR (-O2):
define double @primefactor(double %0, double %1, double %2) {
%4 = tail call double @llvm.floor.f64(double %0)
%5 = fcmp oeq double %4, %0
br i1 %5, label %10, label %6
6: ; preds = %10, %3
%7 = phi double [ 0.000000e+00, %3 ], [ %14, %10 ]
%8 = tail call double @llvm.floor.f64(double %1)
%9 = fcmp oeq double %8, %1
br i1 %9, label %17, label %24
10: ; preds = %3, %10
%11 = phi double [ %13, %10 ], [ %0, %3 ]
%12 = phi double [ %14, %10 ], [ 0.000000e+00, %3 ]
%13 = fdiv double %11, %2
%14 = fadd double %12, 1.000000e+00
%15 = tail call double @llvm.floor.f64(double %13)
%16 = fcmp oeq double %13, %15
br i1 %16, label %10, label %6
17: ; preds = %6, %17
%18 = phi double [ %20, %17 ], [ %1, %6 ]
%19 = phi double [ %21, %17 ], [ %7, %6 ]
%20 = fdiv double %18, %2
%21 = fadd double %19, -1.000000e+00
%22 = tail call double @llvm.floor.f64(double %20)
%23 = fcmp oeq double %20, %22
br i1 %23, label %17, label %24
24: ; preds = %17, %6
%25 = phi double [ %7, %6 ], [ %21, %17 ]
ret double %25
}