// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: number_to_string_base_10
static char *number_to_string_base_10(s7_scheme *sc, s7_pointer obj, s7_int width, s7_int precision, char float_choice, s7_int *nlen, use_write_t choice) /* don't free result */
    {
        /* called by number_to_string_with_radix g_number_to_string, number_to_string_p_p number_to_port format_number */
        /* the rest of s7 assumes nlen is set to the correct length
         *   a tricky case: (format #f "~f" 1e308) -- tries to print 308 digits! so 256 as default len is too small.
         *   but then even worse: (format #f "~F" 1e308+1e308i)!
         */
        s7_int len;

        if ((width + precision) > 512)
            len = 512 + 2 * (width + precision);
        else len = 1024;

        if (len > sc->num_to_str_size)
        {
            if (!sc->num_to_str)
                sc->num_to_str = (char *)malloc(len);
            else sc->num_to_str = (char *)realloc(sc->num_to_str, len);
            sc->num_to_str_size = len;
        }

        /* bignums can't happen here */
        switch (type(obj))
        {
            case T_INTEGER:
                if (width == 0)
                {
                    if (has_print_name(obj))
                    {
                        (*nlen) = print_name_length(obj);
                        return((char *)print_name(obj));
                    }
                    return(integer_to_string(sc, integer(obj), nlen));
                }
                {
                    char *p;
                    p = integer_to_string(sc, integer(obj), &len);
                    if (width > len)
                    {
                        insert_spaces(sc, p, width, len);
                        (*nlen) = width;
                        return(sc->num_to_str);
                    }
                    (*nlen) = len;
                    return(p);
                }

            case T_RATIO:
                len = catstrs_direct(sc->num_to_str, integer_to_string_no_length(sc, numerator(obj)), "/", pos_int_to_str_direct(sc, denominator(obj)), NULL);
                if (width > len)
                {
                    insert_spaces(sc, sc->num_to_str, width, len);
                    (*nlen) = width;
                }
                else (*nlen) = len;
                return(sc->num_to_str);

            case T_REAL:
                if (width == 0)
                {
#if WITH_DTOA
                    if ((float_choice == 'g') &&
                            (precision == WRITE_REAL_PRECISION))
                    {
                        /* (number->string 0.0000001) is sensitive to (*s7* 'float-format-precision) and inconsistent: either 1e-7 or 0.0000001
                         *    because fpconv_dtoa has some complicated decision about 'g' vs 'f' -- not sure if this is a bug.
                         */
                        len = fpconv_dtoa(real(obj), sc->num_to_str);
                        sc->num_to_str[len] = '\0';
                        (*nlen) = len;
                        return(sc->num_to_str);
                    }
#endif
                    len = snprintf(sc->num_to_str, sc->num_to_str_size - 4,
                            (float_choice == 'g') ? "%.*g" : ((float_choice == 'f') ? "%.*f" : "%.*e"),
                            (int32_t)precision, real(obj)); /* -4 for floatify */
                }
                else len = snprintf(sc->num_to_str, sc->num_to_str_size - 4,
                        (float_choice == 'g') ? "%*.*g" : ((float_choice == 'f') ? "%*.*f" : "%*.*e"),
                        (int32_t)width, (int32_t)precision, real(obj)); /* -4 for floatify */
                (*nlen) = len;
                floatify(sc->num_to_str, nlen);
                return(sc->num_to_str);

            default:
                {
                    char *imag;

                    sc->num_to_str[0] = '\0';
                    real(sc->real_wrapper4) = imag_part(obj);
                    imag = copy_string(number_to_string_base_10(sc, sc->real_wrapper4, 0, precision, float_choice, &len, choice));

                    sc->num_to_str[0] = '\0';
                    real(sc->real_wrapper3) = real_part(obj);
                    number_to_string_base_10(sc, sc->real_wrapper3, 0, precision, float_choice, &len, choice);

                    sc->num_to_str[len] = '\0';
                    len = catstrs(sc->num_to_str, sc->num_to_str_size, ((imag[0] == '+') || (imag[0] == '-')) ? "" : "+", imag, "i", NULL);
                    free(imag);

                    if (width > len)  /* (format #f "~20g" 1+i) */
                    {
                        insert_spaces(sc, sc->num_to_str, width, len); /* this checks sc->num_to_str_size */
                        (*nlen) = width;
                    }
                    else (*nlen) = len;
                }
                break;
        }
        return(sc->num_to_str);
    }

// Assembly:
subq $0xb8, %rsp
movb %r8b, %al
movl 0xc0(%rsp), %r8d
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rcx, 0x90(%rsp)
movb %al, 0x8f(%rsp)
movq %r9, 0x80(%rsp)
movq 0x98(%rsp), %rax
addq 0x90(%rsp), %rax
cmpq $0x200, %rax            # imm = 0x200
jle 0xc6759
movq 0x98(%rsp), %rax
addq 0x90(%rsp), %rax
shlq %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, 0x78(%rsp)
jmp 0xc6762
movq $0x400, 0x78(%rsp)      # imm = 0x400
movq 0x78(%rsp), %rax
movq 0xa8(%rsp), %rcx
movslq 0x7e0(%rcx), %rcx
cmpq %rcx, %rax
jle 0xc67eb
movq 0xa8(%rsp), %rax
cmpq $0x0, 0x830(%rax)
jne 0xc67ab
movq 0x78(%rsp), %rdi
callq 0x9480
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x830(%rax)
jmp 0xc67d6
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rdi
movq 0x78(%rsp), %rsi
callq 0x9510
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x830(%rax)
movq 0x78(%rsp), %rax
movl %eax, %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x7e0(%rax)
movq 0xa0(%rsp), %rax
movzbl (%rax), %eax
movl %eax, 0x64(%rsp)
subl $0xb, %eax
je 0xc6822
jmp 0xc6801
movl 0x64(%rsp), %eax
subl $0xc, %eax
je 0xc694e
jmp 0xc6810
movl 0x64(%rsp), %eax
subl $0xd, %eax
je 0xc6a37
jmp 0xc6c5c
cmpq $0x0, 0x98(%rsp)
jne 0xc68ac
movq 0xa0(%rsp), %rax
movq (%rax), %rax
andq $0x8000000, %rax        # imm = 0x8000000
cmpq $0x0, %rax
je 0xc687e
movq 0xa0(%rsp), %rax
movzbl 0x18(%rax), %eax
movl %eax, %ecx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0xa0(%rsp), %rax
addq $0x8, %rax
addq $0x10, %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x80(%rsp), %rdx
callq 0xc7240
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x78(%rsp), %rdx
callq 0xc7240
movq %rax, 0x70(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x78(%rsp), %rax
jle 0xc692c
movq 0xa8(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0xc7380
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0x78(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0x70(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xc70d0
movq %rax, 0x58(%rsp)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0xae30
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %rax, %rcx
leaq 0x11fcdc(%rip), %rdx    # 0x1e6689
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x10540
movq %rax, 0x78(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x78(%rsp), %rax
jle 0xc6a0b
movq 0xa8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rsi
movq 0x98(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0xc7380
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
jmp 0xc6a1b
movq 0x78(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
cmpq $0x0, 0x98(%rsp)
jne 0xc6b6c
movsbl 0x8f(%rsp), %eax
cmpl $0x67, %eax
jne 0xc6aca
cmpq $0x10, 0x90(%rsp)
jne 0xc6aca
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rdi
callq 0xc7460
cltq
movq %rax, 0x78(%rsp)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq 0x78(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x78(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rax
movl 0x7e0(%rax), %eax
subl $0x4, %eax
cltq
movq %rax, 0x48(%rsp)
movsbl 0x8f(%rsp), %eax
cmpl $0x67, %eax
jne 0xc6b11
leaq 0x12b95d(%rip), %rax    # 0x1f2467
movq %rax, 0x38(%rsp)
jmp 0xc6b33
movsbl 0x8f(%rsp), %edx
leaq 0x127616(%rip), %rax    # 0x1ee136
leaq 0x12760a(%rip), %rcx    # 0x1ee131
cmpl $0x66, %edx
cmoveq %rcx, %rax
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rdx
movq 0x90(%rsp), %rax
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movb $0x1, %al
callq 0x9210
cltq
movq %rax, 0x78(%rsp)
jmp 0xc6c14
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movl 0x7e0(%rax), %eax
subl $0x4, %eax
cltq
movq %rax, 0x30(%rsp)
movsbl 0x8f(%rsp), %eax
cmpl $0x67, %eax
jne 0xc6bb3
leaq 0x12758f(%rip), %rax    # 0x1ee13b
movq %rax, 0x20(%rsp)
jmp 0xc6bd5
movsbl 0x8f(%rsp), %edx
leaq 0x127585(%rip), %rax    # 0x1ee147
leaq 0x127578(%rip), %rcx    # 0x1ee141
cmpl $0x66, %edx
cmoveq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq 0x98(%rsp), %rax
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %eax, %r8d
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movb $0x1, %al
callq 0x9210
cltq
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rdi
movq 0x80(%rsp), %rsi
callq 0xc7550
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc6e76
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movb $0x0, (%rax)
movq 0xa0(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0xa8(%rsp), %rax
movq 0x1f30(%rax), %rax
movsd %xmm0, 0x8(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x1f30(%rax), %rsi
movq 0x90(%rsp), %rcx
movb 0x8f(%rsp), %r8b
movl 0xc0(%rsp), %eax
xorl %edx, %edx
leaq 0x78(%rsp), %r9
movsbl %r8b, %r8d
movl %eax, (%rsp)
callq 0xc66e0
movq %rax, %rdi
callq 0x10340
movq %rax, 0x68(%rsp)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movb $0x0, (%rax)
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0xa8(%rsp), %rax
movq 0x1f28(%rax), %rax
movsd %xmm0, 0x8(%rax)
movq 0xa8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x1f28(%rax), %rsi
movq 0x90(%rsp), %rcx
movb 0x8f(%rsp), %r8b
movl 0xc0(%rsp), %eax
xorl %edx, %edx
leaq 0x78(%rsp), %r9
movsbl %r8b, %r8d
movl %eax, (%rsp)
callq 0xc66e0
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq 0x78(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0xa8(%rsp), %rax
movslq 0x7e0(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x2b, %ecx
movb %al, 0x1f(%rsp)
je 0xc6db6
movq 0x68(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, 0x1f(%rsp)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
movb 0x1f(%rsp), %cl
leaq 0x12558e(%rip), %rdx    # 0x1ec359
leaq 0x12d6e7(%rip), %rax    # 0x1f44b9
testb $0x1, %cl
cmovneq %rax, %rdx
movq 0x68(%rsp), %rcx
leaq 0x12b6bd(%rip), %r8     # 0x1f24a2
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0xabd0
movq %rax, 0x78(%rsp)
movq 0x68(%rsp), %rdi
callq 0x9050
movq 0x98(%rsp), %rax
cmpq 0x78(%rsp), %rax
jle 0xc6e4d
movq 0xa8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rsi
movq 0x98(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0xc7380
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
jmp 0xc6e5d
movq 0x78(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
jmp 0xc6e5f
movq 0xa8(%rsp), %rax
movq 0x830(%rax), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
addq $0xb8, %rsp
retq
nopw %cs:(%rax,%rax)