#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 factor(double x, double y) {
  double powe, div;
  powe = 0.0;
  div = x;
  while (div == floor(div)) {
    div = div / 3.0;
    powe++;
  }
  div = y;
  while (div == floor(div)) {
    div = div / 3.0;
    powe--;
  }
  return powe;
}


x86 assembly (clang, -O0):
<factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    118d <factor+0x7d>
jp     118d <factor+0x7d>
movsd  -0x20(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe92(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1134 <factor+0x24>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    11f0 <factor+0xe0>
jp     11f0 <factor+0xe0>
movsd  -0x20(%rbp),%xmm0
movsd  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe1f(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1197 <factor+0x87>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factor>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1181 <factor+0x71>
jp     1181 <factor+0x71>
movapd %xmm1,%xmm0
xorpd  %xmm1,%xmm1
nopl   0x0(%rax,%rax,1)
divsd  0xeb8(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0xeb2(%rip),%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  (%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
jne    1185 <factor+0x75>
jnp    1140 <factor+0x30>
jmp    1185 <factor+0x75>
xorpd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    11f4 <factor+0xe4>
jp     11f4 <factor+0xe4>
movsd  (%rsp),%xmm0
nopl   0x0(%rax,%rax,1)
divsd  0xe48(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  0xe4a(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
jne    11ef <factor+0xdf>
jnp    11b0 <factor+0xa0>
add    $0x18,%rsp
ret
movsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

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

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