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


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

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

LLVM IR (-O0):
define void @ft_putdouble_fd(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
store i32 %0, i32* %3
store double %1, double* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = load double, double* %4
%8 = fptosi double %7 to i32
%9 = sitofp i32 %8 to double
%10 = call i32 @ft_putint_fd(i32 %6, double %9)
%11 = load i32, i32* %3
%12 = call i32 @ft_putchar_fd(i32 %11, i8 signext 46)
%13 = load double, double* %4
%14 = fptosi double %13 to i32
%15 = sitofp i32 %14 to double
%16 = load double, double* %4
%17 = fsub double %16, %15
store double %17, double* %4
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* %4
%24 = fmul double %23, 1.000000e+01
store double %24, double* %4
br label %18
25: ; preds = %18
%26 = load i32, i32* %3
%27 = load double, double* %4
%28 = call i32 @ft_putint_fd(i32 %26, double %27)
ret void
}

LLVM IR (-O2):
define void @ft_putdouble_fd(i32 %0, double %1) {
%3 = fptosi double %1 to i32
%4 = sitofp i32 %3 to double
%5 = tail call i32 @ft_putint_fd(i32 %0, double %4)
%6 = tail call i32 @ft_putchar_fd(i32 %0, i8 signext 46)
%7 = fsub double %1, %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_putint_fd(i32 %0, double %13)
ret void
}