#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 ft_modf(double, double *);
int ft_gp(double n) {
  int power;
  double f;
  double i;
  power = 0;
  f = ft_modf(n, &i);
  f = (f < 0) ? -f : f;
  i = (i < 0) ? -i : i;
  if (i < 1.0)
    while ((f *= 10.0) < 1.0)
      power--;
  else
    while ((i /= 10.0) >= 1.0)
      power++;
  return (power);
}


x86 assembly (clang, -O0):
<ft_gp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
call   1030 <ft_modf@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    116b <ft_gp+0x5b>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1175 <ft_gp+0x65>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11b3 <ft_gp+0xa3>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11bd <ft_gp+0xad>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe31(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1216 <ft_gp+0x106>
jmp    11df <ft_gp+0xcf>
movsd  0xe21(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  %xmm1,-0x18(%rbp)
movsd  0xe07(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1211 <ft_gp+0x101>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11df <ft_gp+0xcf>
jmp    1256 <ft_gp+0x146>
jmp    121b <ft_gp+0x10b>
movsd  -0x20(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdc7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1251 <ft_gp+0x141>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    121b <ft_gp+0x10b>
jmp    1256 <ft_gp+0x146>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_gp>:
push   %rax
mov    %rsp,%rdi
call   1030 <ft_modf@plt>
movsd  (%rsp),%xmm1
movapd 0xeda(%rip),%xmm4
xorpd  %xmm1,%xmm4
xorpd  %xmm3,%xmm3
movapd %xmm1,%xmm2
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
movsd  0xec5(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    118f <ft_gp+0x7f>
movapd 0xea7(%rip),%xmm4
xorpd  %xmm0,%xmm4
movapd %xmm0,%xmm2
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm0,%xmm2
orpd   %xmm4,%xmm2
mov    $0x1,%eax
movsd  0xe99(%rip),%xmm0
nop
mulsd  %xmm0,%xmm2
add    $0xffffffff,%eax
ucomisd %xmm2,%xmm1
ja     1180 <ft_gp+0x70>
jmp    11ad <ft_gp+0x9d>
mov    $0xffffffff,%eax
movsd  0xe7c(%rip),%xmm0
nopl   0x0(%rax)
divsd  %xmm0,%xmm2
add    $0x1,%eax
ucomisd %xmm1,%xmm2
jae    11a0 <ft_gp+0x90>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @ft_gp(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store double %0, double* %2
store i32 0, i32* %3
%6 = load double, double* %2
%7 = call double @ft_modf(double %6, double* %5)
store double %7, double* %4
%8 = load double, double* %4
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load double, double* %4
%12 = fneg double %11
br label %15
13: ; preds = %1
%14 = load double, double* %4
br label %15
15: ; preds = %13, %10
%16 = phi double [ %12, %10 ], [ %14, %13 ]
store double %16, double* %4
%17 = load double, double* %5
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load double, double* %5
%21 = fneg double %20
br label %24
22: ; preds = %15
%23 = load double, double* %5
br label %24
24: ; preds = %22, %19
%25 = phi double [ %21, %19 ], [ %23, %22 ]
store double %25, double* %5
%26 = load double, double* %5
%27 = fcmp olt double %26, 1.000000e+00
br i1 %27, label %28, label %37
28: ; preds = %24
br label %29
29: ; preds = %33, %28
%30 = load double, double* %4
%31 = fmul double %30, 1.000000e+01
store double %31, double* %4
%32 = fcmp olt double %31, 1.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
store i32 %35, i32* %3
br label %29
36: ; preds = %29
br label %46
37: ; preds = %24
br label %38
38: ; preds = %42, %37
%39 = load double, double* %5
%40 = fdiv double %39, 1.000000e+01
store double %40, double* %5
%41 = fcmp oge double %40, 1.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %38
45: ; preds = %38
br label %46
46: ; preds = %45, %36
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @ft_gp(double %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = call double @ft_modf(double %0, double* %2)
%5 = load double, double* %2
%6 = fcmp olt double %5, 0.000000e+00
%7 = fneg double %5
%8 = select i1 %6, double %7, double %5
%9 = fcmp olt double %8, 1.000000e+00
br i1 %9, label %10, label %20
10: ; preds = %1
%11 = fcmp olt double %4, 0.000000e+00
%12 = fneg double %4
%13 = select i1 %11, double %12, double %4
br label %14
14: ; preds = %10, %14
%15 = phi i32 [ %19, %14 ], [ 0, %10 ]
%16 = phi double [ %17, %14 ], [ %13, %10 ]
%17 = fmul double %16, 1.000000e+01
%18 = fcmp olt double %17, 1.000000e+00
%19 = add nsw i32 %15, -1
br i1 %18, label %14, label %26
20: ; preds = %1, %20
%21 = phi double [ %23, %20 ], [ %8, %1 ]
%22 = phi i32 [ %25, %20 ], [ 0, %1 ]
%23 = fdiv double %21, 1.000000e+01
%24 = fcmp ult double %23, 1.000000e+00
%25 = add nuw nsw i32 %22, 1
br i1 %24, label %26, label %20
26: ; preds = %20, %14
%27 = phi i32 [ %15, %14 ], [ %22, %20 ]
ret i32 %27
}