int __ecvt_r(value, ndigit, decpt, sign, buf, len)
double value;
int ndigit, *decpt, *sign;
char *buf;
{
  if ((sizeof(value) == sizeof(float) ? __finitef(value) : __finite(value)) &&
      value != 0.0) {
    double d;
    double f = 1.0;
    d = -value;
    if (d < 1.0e-307) {
      do {
        f *= 10.0;
      } while (d * f < 1.0);
    }
  }
  if (ndigit <= 0 && len > 0) {
    buf[0] = '\0';
    *sign =
        (sizeof(value) == sizeof(float) ? __finitef(value) : __finite(value))
            ? (sizeof(value) == sizeof(float) ? __signbitf(value)
                                              : __signbit(value)) != 0
            : 0;
  }
}


x86 assembly (clang, -O0):
<__ecvt_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    113f <__ecvt_r+0x2f>
jmp    1169 <__ecvt_r+0x59>
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movaps 0xee1(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xee5(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    118b <__ecvt_r+0x7b>
jmp    1226 <__ecvt_r+0x116>
movsd  -0x10(%rbp),%xmm0
movaps 0xeab(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
je     1226 <__ecvt_r+0x116>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a8 <__ecvt_r+0x98>
jp     11a8 <__ecvt_r+0x98>
jmp    1226 <__ecvt_r+0x116>
movsd  0xe60(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe2a(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1221 <__ecvt_r+0x111>
jmp    11ee <__ecvt_r+0xde>
movsd  0xe22(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xdfe(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11ee <__ecvt_r+0xde>
jmp    1221 <__ecvt_r+0x111>
jmp    1226 <__ecvt_r+0x116>
cmpl   $0x0,-0x14(%rbp)
jg     12ce <__ecvt_r+0x1be>
cmpl   $0x0,-0x34(%rbp)
jle    12ce <__ecvt_r+0x1be>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
test   $0x1,%al
jne    1250 <__ecvt_r+0x140>
jmp    127a <__ecvt_r+0x16a>
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movaps 0xdd0(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xdd4(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    129c <__ecvt_r+0x18c>
jmp    12bb <__ecvt_r+0x1ab>
movsd  -0x10(%rbp),%xmm0
movaps 0xd9a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
je     12bb <__ecvt_r+0x1ab>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1030 <__signbit@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4c(%rbp)
jmp    12c5 <__ecvt_r+0x1b5>
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
jmp    12c5 <__ecvt_r+0x1b5>
mov    -0x4c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ecvt_r>:
test   %edi,%edi
jg     114b <__ecvt_r+0x3b>
test   %r8d,%r8d
jle    114b <__ecvt_r+0x3b>
push   %rbx
mov    %rdx,%rbx
movapd 0xedb(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xedf(%rip),%xmm1
movb   $0x0,(%rcx)
je     1146 <__ecvt_r+0x36>
mov    $0x1,%al
call   1030 <__signbit@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
jmp    1148 <__ecvt_r+0x38>
xor    %ecx,%ecx
mov    %ecx,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define i32 @__ecvt_r(double %0, i32 %1, i32* %2, i32* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store double %0, double* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
br i1 false, label %16, label %21
16: ; preds = %6
%17 = load double, double* %8
%18 = fptrunc double %17 to float
%19 = call float @llvm.fabs.f32(float %18)
%20 = fcmp one float %19, 0x7FF0000000000000
br i1 %20, label %25, label %44
21: ; preds = %6
%22 = load double, double* %8
%23 = call double @llvm.fabs.f64(double %22)
%24 = fcmp one double %23, 0x7FF0000000000000
br i1 %24, label %25, label %44
25: ; preds = %21, %16
%26 = load double, double* %8
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %44
28: ; preds = %25
store double 1.000000e+00, double* %15
%29 = load double, double* %8
%30 = fneg double %29
store double %30, double* %14
%31 = load double, double* %14
%32 = fcmp olt double %31, 0x31FA182C40C60D
br i1 %32, label %33, label %43
33: ; preds = %28
br label %34
34: ; preds = %37, %33
%35 = load double, double* %15
%36 = fmul double %35, 1.000000e+01
store double %36, double* %15
br label %37
37: ; preds = %34
%38 = load double, double* %14
%39 = load double, double* %15
%40 = fmul double %38, %39
%41 = fcmp olt double %40, 1.000000e+00
br i1 %41, label %34, label %42
42: ; preds = %37
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43, %25, %21, %16
%45 = load i32, i32* %9
%46 = icmp sle i32 %45, 0
br i1 %46, label %47, label %71
47: ; preds = %44
%48 = load i32, i32* %13
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %71
50: ; preds = %47
%51 = load i8*, i8** %12
%52 = getelementptr inbounds i8, i8* %51, i64 0
store i8 0, i8* %52
br i1 false, label %53, label %58
53: ; preds = %50
%54 = load double, double* %8
%55 = fptrunc double %54 to float
%56 = call float @llvm.fabs.f32(float %55)
%57 = fcmp one float %56, 0x7FF0000000000000
br i1 %57, label %62, label %67
58: ; preds = %50
%59 = load double, double* %8
%60 = call double @llvm.fabs.f64(double %59)
%61 = fcmp one double %60, 0x7FF0000000000000
br i1 %61, label %62, label %67
62: ; preds = %58, %53
%63 = load double, double* %8
%64 = call i32 (double, ...) bitcast (i32 (...)* @__signbit to i32 (double, ...)*)(double %63)
%65 = icmp ne i32 %64, 0
%66 = zext i1 %65 to i32
br label %68
67: ; preds = %58, %53
br label %68
68: ; preds = %67, %62
%69 = phi i32 [ %66, %62 ], [ 0, %67 ]
%70 = load i32*, i32** %11
store i32 %69, i32* %70
br label %71
71: ; preds = %68, %47, %44
%72 = load i32, i32* %7
ret i32 %72
}

LLVM IR (-O2):
define i32 @__ecvt_r(double %0, i32 %1, i32* nocapture readnone %2, i32* nocapture writeonly %3, i8* nocapture writeonly %4, i32 %5) {
%7 = icmp slt i32 %1, 1
%8 = icmp sgt i32 %5, 0
%9 = and i1 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = tail call double @llvm.fabs.f64(double %0)
%12 = fcmp ueq double %11, 0x7FF0000000000000
store i8 0, i8* %4
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 (double, ...) bitcast (i32 (...)* @__signbit to i32 (double, ...)*)(double %0)
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %10, %13
%18 = phi i32 [ %16, %13 ], [ 0, %10 ]
store i32 %18, i32* %3
br label %19
19: ; preds = %17, %6
ret i32 undef
}