// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_misc/lv_printf.c
// Function: etoa
static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags)
{
  // check for NaN and special values
  if ((value != value) || (value > DBL_MAX) || (value < -DBL_MAX)) {
    return _ftoa(out, buffer, idx, maxlen, value, prec, width, flags);
  }

  // determine the sign
  const bool negative = value < 0;
  if (negative) {
    value = -value;
  }

  // default precision
  if (!(flags & FLAGS_PRECISION)) {
    prec = PRINTF_DEFAULT_FLOAT_PRECISION;
  }

  // determine the decimal exponent
  // based on the algorithm by David Gay (https://www.ampl.com/netlib/fp/dtoa.c)
  union {
    uint64_t U;
    double   F;
  } conv;

  conv.F = value;
  int exp2 = (int)((conv.U >> 52U) & 0x07FFU) - 1023;           // effectively log2
  conv.U = (conv.U & ((1ULL << 52U) - 1U)) | (1023ULL << 52U);  // drop the exponent so conv.F is now in [1,2)
  // now approximate log10 from the log2 integer part and an expansion of ln around 1.5
  int expval = (int)(0.1760912590558 + exp2 * 0.301029995663981 + (conv.F - 1.5) * 0.289529654602168);
  // now we want to compute 10^expval but we want to be sure it won't overflow
  exp2 = (int)(expval * 3.321928094887362 + 0.5);
  const double z  = expval * 2.302585092994046 - exp2 * 0.6931471805599453;
  const double z2 = z * z;
  conv.U = (uint64_t)(exp2 + 1023) << 52U;
  // compute exp(z) using continued fractions, see https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex
  conv.F *= 1 + 2 * z / (2 - z + (z2 / (6 + (z2 / (10 + z2 / 14)))));
  // correct for rounding errors
  if (value < conv.F) {
    expval--;
    conv.F /= 10;
  }

  // the exponent format is "%+03d" and largest value is "307", so set aside 4-5 characters
  unsigned int minwidth = ((expval < 100) && (expval > -100)) ? 4U : 5U;

  // in "%g" mode, "prec" is the number of *significant figures* not decimals
  if (flags & FLAGS_ADAPT_EXP) {
    // do we want to fall-back to "%f" mode?
    if ((value >= 1e-4) && (value < 1e6)) {
      if ((int)prec > expval) {
        prec = (unsigned)((int)prec - expval - 1);
      }
      else {
        prec = 0;
      }
      flags |= FLAGS_PRECISION;   // make sure _ftoa respects precision
      // no characters in exponent
      minwidth = 0U;
      expval   = 0;
    }
    else {
      // we use one sigfig for the whole part
      if ((prec > 0) && (flags & FLAGS_PRECISION)) {
        --prec;
      }
    }
  }

  // will everything fit?
  unsigned int fwidth = width;
  if (width > minwidth) {
    // we didn't fall-back so subtract the characters required for the exponent
    fwidth -= minwidth;
  } else {
    // not enough characters, so go back to default sizing
    fwidth = 0U;
  }
  if ((flags & FLAGS_LEFT) && minwidth) {
    // if we're padding on the right, DON'T pad the floating part
    fwidth = 0U;
  }

  // rescale the float value
  if (expval) {
    value /= conv.F;
  }

  // output the floating part
  const size_t start_idx = idx;
  idx = _ftoa(out, buffer, idx, maxlen, negative ? -value : value, prec, fwidth, flags & ~FLAGS_ADAPT_EXP);

  // output the exponent part
  if (minwidth) {
    // output the exponential symbol
    out((flags & FLAGS_UPPERCASE) ? 'E' : 'e', buffer, idx++, maxlen);
    // output the exponent value
    idx = _ntoa_long(out, buffer, idx, maxlen, (expval < 0) ? -expval : expval, expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS);
    // might need to right-pad spaces
    if (flags & FLAGS_LEFT) {
      while (idx - start_idx < width) out(' ', buffer, idx++, maxlen);
    }
  }
  return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movl %r8d, -0x34(%rbp)
movl %r9d, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x4985b
jp 0x4985b
movsd -0x30(%rbp), %xmm0
movsd 0x22682(%rip), %xmm1    # 0x6bec8
ucomisd %xmm1, %xmm0
ja 0x4985b
movsd 0x2266c(%rip), %xmm0    # 0x6bec0
ucomisd -0x30(%rbp), %xmm0
jbe 0x4988c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movsd -0x30(%rbp), %xmm0
movl -0x34(%rbp), %r8d
movl -0x38(%rbp), %r9d
movl 0x10(%rbp), %eax
movl %eax, (%rsp)
callq 0x491f0
movq %rax, -0x8(%rbp)
jmp 0x49d6c
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
seta %al
andb $0x1, %al
movb %al, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
je 0x498c3
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x30(%rbp)
movl 0x10(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x498d7
movl $0x6, -0x34(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x48(%rbp), %rax
shrq $0x34, %rax
andq $0x7ff, %rax            # imm = 0x7FF
subl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x4c(%rbp)
movabsq $0xfffffffffffff, %rax  # imm = 0xFFFFFFFFFFFFF
andq -0x48(%rbp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
orq %rcx, %rax
movq %rax, -0x48(%rbp)
cvtsi2sdl -0x4c(%rbp), %xmm1
movsd 0x2261d(%rip), %xmm0    # 0x6bf40
mulsd %xmm0, %xmm1
movsd 0x22619(%rip), %xmm0    # 0x6bf48
addsd %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
movsd 0x225f8(%rip), %xmm2    # 0x6bf38
subsd %xmm2, %xmm0
movsd 0x225e4(%rip), %xmm2    # 0x6bf30
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x50(%rbp)
cvtsi2sdl -0x50(%rbp), %xmm0
movsd 0x225c0(%rip), %xmm1    # 0x6bf28
mulsd %xmm1, %xmm0
movsd 0x2256c(%rip), %xmm1    # 0x6bee0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x4c(%rbp)
cvtsi2sdl -0x50(%rbp), %xmm0
cvtsi2sdl -0x4c(%rbp), %xmm1
movsd 0x2258f(%rip), %xmm2    # 0x6bf20
mulsd %xmm2, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x22564(%rip), %xmm2    # 0x6bf18
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x4c(%rbp), %eax
addl $0x3ff, %eax            # imm = 0x3FF
cltq
shlq $0x34, %rax
movq %rax, -0x48(%rbp)
movsd 0x22526(%rip), %xmm1    # 0x6bf10
mulsd -0x58(%rbp), %xmm1
movsd 0x22519(%rip), %xmm0    # 0x6bf10
subsd -0x58(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
movsd -0x60(%rbp), %xmm4
movsd -0x60(%rbp), %xmm5
movsd 0x224f5(%rip), %xmm3    # 0x6bf08
divsd %xmm3, %xmm5
movsd 0x224e1(%rip), %xmm3    # 0x6bf00
addsd %xmm5, %xmm3
divsd %xmm3, %xmm4
movsd 0x224c9(%rip), %xmm3    # 0x6bef8
addsd %xmm4, %xmm3
divsd %xmm3, %xmm2
addsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd 0x224a9(%rip), %xmm0    # 0x6bef0
addsd %xmm1, %xmm0
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x49a84
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
movsd 0x22485(%rip), %xmm1    # 0x6bf00
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
xorl %eax, %eax
cmpl $0x64, -0x50(%rbp)
movb %al, -0x71(%rbp)
jge 0x49a99
cmpl $-0x64, -0x50(%rbp)
setg %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %dl
movl $0x5, %eax
movl $0x4, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x64(%rbp)
movl 0x10(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x49b36
movsd -0x30(%rbp), %xmm0
movsd 0x22487(%rip), %xmm1    # 0x6bf50
ucomisd %xmm1, %xmm0
jb 0x49b16
movsd 0x22481(%rip), %xmm0    # 0x6bf58
ucomisd -0x30(%rbp), %xmm0
jbe 0x49b16
movl -0x34(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x49af4
movl -0x34(%rbp), %eax
subl -0x50(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x49afb
movl $0x0, -0x34(%rbp)
movl 0x10(%rbp), %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x10(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x49b34
cmpl $0x0, -0x34(%rbp)
jbe 0x49b32
movl 0x10(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x49b32
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x49b34
jmp 0x49b36
movl -0x38(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x64(%rbp), %eax
jbe 0x49b51
movl -0x64(%rbp), %ecx
movl -0x68(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x68(%rbp)
jmp 0x49b58
movl $0x0, -0x68(%rbp)
movl 0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x49b70
cmpl $0x0, -0x64(%rbp)
je 0x49b70
movl $0x0, -0x68(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x49b89
movsd -0x48(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
testb $0x1, -0x39(%rbp)
je 0x49be6
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0x49bf3
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x80(%rbp), %rcx
movq -0x88(%rbp), %rdx
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
movl -0x34(%rbp), %r8d
movl -0x68(%rbp), %r9d
movl 0x10(%rbp), %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %eax, (%rsp)
callq 0x491f0
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x49d64
movq -0x10(%rbp), %rax
movl 0x10(%rbp), %esi
andl $0x20, %esi
movl $0x65, %ecx
movl $0x45, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
movb %cl, %dil
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq %rdx, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movq -0x28(%rbp), %rcx
movsbl %dil, %edi
callq *%rax
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpl $0x0, -0x50(%rbp)
jge 0x49cb3
xorl %eax, %eax
subl -0x50(%rbp), %eax
movl %eax, -0xc4(%rbp)
jmp 0x49cbc
movl -0x50(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xb0(%rbp), %rdx
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
movl -0xc4(%rbp), %eax
movslq %eax, %r8
cmpl $0x0, -0x50(%rbp)
setl %al
movl -0x64(%rbp), %r10d
subl $0x1, %r10d
movq %rsp, %r9
movl %r10d, 0x10(%r9)
movl $0x5, 0x18(%r9)
movl $0x0, 0x8(%r9)
movq $0xa, (%r9)
movzbl %al, %r9d
andl $0x1, %r9d
callq 0x49090
movq %rax, -0x20(%rbp)
movl 0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x49d62
jmp 0x49d2c
movq -0x20(%rbp), %rax
subq -0x70(%rbp), %rax
movl -0x38(%rbp), %ecx
cmpq %rcx, %rax
jae 0x49d60
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq %rdx, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movq -0x28(%rbp), %rcx
movl $0x20, %edi
callq *%rax
jmp 0x49d2c
jmp 0x49d62
jmp 0x49d64
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)