#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 */
int /*<<< orphan*/ ft_putchar_fd(char, int);
int /*<<< orphan*/ ft_putnbr_fd(double, int);
void ft_putdouble_fd(double d, int fd) {
  int i;
  i = 0;
  ft_putnbr_fd((int)d, fd);
  ft_putchar_fd('.', fd);
  d -= (int)d;
  while (i++ < 6)
    d *= 10;
  ft_putnbr_fd(d, fd);
}


x86 assembly (clang, -O0):
<ft_putdouble_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cvttsd2si -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0xc(%rbp),%edi
call   1030 <ft_putnbr_fd@plt>
mov    -0xc(%rbp),%esi
mov    $0x2e,%edi
call   1040 <ft_putchar_fd@plt>
cvttsd2si -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x6,%eax
jge    1197 <ft_putdouble_fd+0x77>
movsd  0xe78(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    116c <ft_putdouble_fd+0x4c>
movsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1030 <ft_putnbr_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putdouble_fd>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movapd %xmm0,0x10(%rsp)
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movaps %xmm0,(%rsp)
call   1030 <ft_putnbr_fd@plt>
mov    $0x2e,%edi
mov    %ebx,%esi
call   1040 <ft_putchar_fd@plt>
movapd 0x10(%rsp),%xmm0
subsd  (%rsp),%xmm0
movsd  0xea3(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mov    %ebx,%edi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <ft_putnbr_fd@plt>

LLVM IR (-O0):
define void @ft_putdouble_fd(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load double, double* %3
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = load i32, i32* %4
%10 = call i32 @ft_putnbr_fd(double %8, i32 %9)
%11 = load i32, i32* %4
%12 = call i32 @ft_putchar_fd(i8 signext 46, i32 %11)
%13 = load double, double* %3
%14 = fptosi double %13 to i32
%15 = sitofp i32 %14 to double
%16 = load double, double* %3
%17 = fsub double %16, %15
store double %17, double* %3
br label %18
18: ; preds = %22, %2
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = icmp slt i32 %19, 6
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load double, double* %3
%24 = fmul double %23, 1.000000e+01
store double %24, double* %3
br label %18
25: ; preds = %18
%26 = load double, double* %3
%27 = load i32, i32* %4
%28 = call i32 @ft_putnbr_fd(double %26, i32 %27)
ret void
}

LLVM IR (-O2):
define void @ft_putdouble_fd(double %0, i32 %1) {
%3 = fptosi double %0 to i32
%4 = sitofp i32 %3 to double
%5 = tail call i32 @ft_putnbr_fd(double %4, i32 %1)
%6 = tail call i32 @ft_putchar_fd(i8 signext 46, i32 %1)
%7 = fsub double %0, %4
%8 = fmul double %7, 1.000000e+01
%9 = fmul double %8, 1.000000e+01
%10 = fmul double %9, 1.000000e+01
%11 = fmul double %10, 1.000000e+01
%12 = fmul double %11, 1.000000e+01
%13 = fmul double %12, 1.000000e+01
%14 = tail call i32 @ft_putnbr_fd(double %13, i32 %1)
ret void
}