#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(long long);
int /*<<< orphan*/ ft_putulnbr(long long);
long double ft_round(long double, int);
void ft_putlldbl(long double n, int prec) {
  long long ival;
  ival = n;
  ft_putulnbr(ival);
  n = ft_round(n - ival, prec);
  if (prec > 0)
    ft_putchar('.');
  while (prec-- > 0) {
    n = n * 10.0;
    ft_putchar((long long)n % 10 + '0');
  }
}


x86 assembly (clang, -O0):
<ft_putlldbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %edi,-0x14(%rbp)
fldt   -0x10(%rbp)
fnstcw -0x3a(%rbp)
movzwl -0x3a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x3c(%rbp)
fldcw  -0x3c(%rbp)
fistpll -0x30(%rbp)
fldcw  -0x3a(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <ft_putulnbr@plt>
fldt   -0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
fildll -0x28(%rbp)
fsubrp %st,%st(1)
mov    -0x14(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <ft_round@plt>
fstpt  -0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a2 <ft_putlldbl+0x72>
mov    $0x2e,%edi
call   1050 <ft_putchar@plt>
jmp    11a7 <ft_putlldbl+0x77>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    1204 <ft_putlldbl+0xd4>
fldt   -0x10(%rbp)
flds   0xe3c(%rip)
fmulp  %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
fnstcw -0x3e(%rbp)
movzwl -0x3e(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x40(%rbp)
fldcw  -0x40(%rbp)
fistpll -0x38(%rbp)
fldcw  -0x3e(%rbp)
mov    -0x38(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
add    $0x30,%rdi
call   1050 <ft_putchar@plt>
jmp    11a7 <ft_putlldbl+0x77>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putlldbl>:
push   %r14
push   %rbx
sub    $0x48,%rsp
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
fnstcw 0x1e(%rsp)
movzwl 0x1e(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x22(%rsp)
fldcw  0x22(%rsp)
fistpll 0x38(%rsp)
fldcw  0x1e(%rsp)
mov    %edi,%ebx
mov    0x38(%rsp),%r14
mov    %r14,%rdi
call   1030 <ft_putulnbr@plt>
mov    %r14,0x40(%rsp)
fildll 0x40(%rsp)
fldt   0x24(%rsp)
fsubp  %st,%st(1)
fstpt  (%rsp)
mov    %ebx,%edi
call   1040 <ft_round@plt>
fstpt  0x24(%rsp)
test   %ebx,%ebx
jle    1217 <ft_putlldbl+0xe7>
mov    $0x2e,%edi
call   1050 <ft_putchar@plt>
add    $0x1,%ebx
movabs $0x6666666666666667,%r14
66 66 66
nopl   0x0(%rax,%rax,1)
fldt   0x24(%rsp)
fmuls  0xe46(%rip)
fnstcw 0x1c(%rsp)
movzwl 0x1c(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x20(%rsp)
fldcw  0x20(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
fistpll 0x30(%rsp)
fldcw  0x1c(%rsp)
mov    0x30(%rsp),%rcx
mov    %rcx,%rax
imul   %r14
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
neg    %rax
lea    (%rcx,%rax,1),%rdi
add    $0x30,%rdi
call   1050 <ft_putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11b0 <ft_putlldbl+0x80>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ft_putlldbl(x86_fp80 %0, i32 %1) {
%3 = alloca x86_fp80
%4 = alloca i32
%5 = alloca i64
store x86_fp80 %0, x86_fp80* %3
store i32 %1, i32* %4
%6 = load x86_fp80, x86_fp80* %3
%7 = fptosi x86_fp80 %6 to i64
store i64 %7, i64* %5
%8 = load i64, i64* %5
%9 = call i32 @ft_putulnbr(i64 %8)
%10 = load x86_fp80, x86_fp80* %3
%11 = load i64, i64* %5
%12 = sitofp i64 %11 to x86_fp80
%13 = fsub x86_fp80 %10, %12
%14 = load i32, i32* %4
%15 = call x86_fp80 @ft_round(x86_fp80 %13, i32 %14)
store x86_fp80 %15, x86_fp80* %3
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @ft_putchar(i64 46)
br label %20
20: ; preds = %18, %2
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, -1
store i32 %23, i32* %4
%24 = icmp sgt i32 %22, 0
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load x86_fp80, x86_fp80* %3
%27 = fmul x86_fp80 %26, 0xK4002A000000000000000
store x86_fp80 %27, x86_fp80* %3
%28 = load x86_fp80, x86_fp80* %3
%29 = fptosi x86_fp80 %28 to i64
%30 = srem i64 %29, 10
%31 = add nsw i64 %30, 48
%32 = call i32 @ft_putchar(i64 %31)
br label %21
33: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @ft_putlldbl(x86_fp80 %0, i32 %1) {
%3 = fptosi x86_fp80 %0 to i64
%4 = tail call i32 @ft_putulnbr(i64 %3)
%5 = sitofp i64 %3 to x86_fp80
%6 = fsub x86_fp80 %0, %5
%7 = tail call x86_fp80 @ft_round(x86_fp80 %6, i32 %1)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = tail call i32 @ft_putchar(i64 46)
br label %11
11: ; preds = %9, %11
%12 = phi x86_fp80 [ %15, %11 ], [ %7, %9 ]
%13 = phi i32 [ %14, %11 ], [ %1, %9 ]
%14 = add nsw i32 %13, -1
%15 = fmul x86_fp80 %12, 0xK4002A000000000000000
%16 = fptosi x86_fp80 %15 to i64
%17 = srem i64 %16, 10
%18 = add nsw i64 %17, 48
%19 = tail call i32 @ft_putchar(i64 %18)
%20 = icmp ugt i32 %13, 1
br i1 %20, label %11, label %21
21: ; preds = %11, %2
ret void
}