// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, %r14
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %r12
leaq (%rcx,%rdx), %rax
cmpq $0x201, %rax            # imm = 0x201
leaq 0x200(%rax,%rax), %rax
movl $0x400, %ebx            # imm = 0x400
cmovgeq %rax, %rbx
movq %rbx, 0x38(%rsp)
movslq 0x7e0(%rdi), %rax
cmpq %rax, %rbx
jle 0x7313d
movq %r15, 0x8(%rsp)
movq %r13, %r15
movl %r8d, %r13d
movq %r14, %rbp
movq %rdi, %r14
movq 0x830(%rdi), %rdi
testq %rdi, %rdi
je 0x73114
movq %rbx, %rsi
callq 0x8510
jmp 0x7311c
movq %rbx, %rdi
callq 0x8480
movq %r14, %rdi
movq %rax, 0x830(%r14)
movl %ebx, 0x7e0(%r14)
movl %ebx, %eax
movq %rbp, %r14
movl %r13d, %r8d
movq %r15, %r13
movq 0x8(%rsp), %r15
movzbl (%r12), %ecx
cmpl $0xd, %ecx
je 0x73204
cmpl $0xc, %ecx
je 0x731a3
cmpl $0xb, %ecx
jne 0x7325b
testq %r15, %r15
je 0x733e0
movq 0x8(%r12), %rsi
leaq 0x38(%rsp), %rbx
movq %rdi, %r13
movq %rbx, %rdx
callq 0x73b88
movq %rax, %r12
movq (%rbx), %rcx
cmpq %r15, %rcx
jge 0x7340a
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x73c32
movq %r15, (%r14)
movq 0x830(%r13), %r12
jmp 0x73470
movq 0x830(%rdi), %rbx
movq 0x8(%r12), %rsi
movq %rdi, %rbp
callq 0x73af1
movq %rax, %r13
movq 0x10(%r12), %rsi
movq %rbp, %rdi
callq 0x91f9
leaq 0x67986(%rip), %rdx     # 0xdab54
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xb3a5
cmpq %r15, %rax
jge 0x73357
movq 0x830(%rbp), %rsi
movq %rbp, %rdi
movq %r15, %rdx
movq %rax, %rcx
callq 0x73c32
jmp 0x7335a
testq %r15, %r15
je 0x73380
movq %rdi, %rbx
movq 0x830(%rdi), %rdi
addl $-0x4, %eax
movslq %eax, %rsi
cmpb $0x66, %r8b
leaq 0x6f3e4(%rip), %rax     # 0xe260c
leaq 0x6f3e3(%rip), %rcx     # 0xe2612
cmoveq %rax, %rcx
cmpb $0x67, %r8b
leaq 0x6f3c8(%rip), %rdx     # 0xe2606
cmovneq %rcx, %rdx
movsd 0x8(%r12), %xmm0
movl %r15d, %ecx
movl %r13d, %r8d
movb $0x1, %al
callq 0x8210
jmp 0x73455
movq %r14, 0x8(%rsp)
movq 0x830(%rdi), %rax
xorl %ecx, %ecx
movb %cl, (%rax)
movsd 0x10(%r12), %xmm0
movq 0x1f30(%rdi), %rax
movsd %xmm0, 0x8(%rax)
movq 0x1f30(%rdi), %rsi
movsbl %r8b, %ebx
leaq 0x38(%rsp), %r9
movq %rdi, %r14
xorl %edx, %edx
movq %r13, %rcx
movl %ebx, %r8d
callq 0x730a4
movq %rax, %rdi
callq 0xb284
movq %rax, %rbp
movq 0x830(%r14), %rax
xorl %ecx, %ecx
movb %cl, (%rax)
movsd 0x8(%r12), %xmm0
movq 0x1f28(%r14), %rax
movsd %xmm0, 0x8(%rax)
movq 0x1f28(%r14), %rsi
movq %r14, %rdi
xorl %edx, %edx
movq %r13, %rcx
movl %ebx, %r8d
leaq 0x38(%rsp), %rbx
movq %rbx, %r9
callq 0x730a4
movq 0x830(%r14), %rax
movq (%rbx), %rcx
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x830(%r14), %rdi
movslq 0x7e0(%r14), %rsi
movb (%rbp), %al
addb $-0x2b, %al
leaq 0x7515f(%rip), %rcx     # 0xe846e
leaq 0x6d50e(%rip), %rdx     # 0xe0824
testb $-0x3, %al
cmoveq %rcx, %rdx
leaq 0x731f9(%rip), %r8      # 0xe651c
movq %rbp, %rcx
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x90f7
movq %rax, %rbx
movq %rbp, %rdi
callq 0x8050
cmpq %r15, %rbx
jge 0x73369
movq 0x830(%r14), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x73c32
jmp 0x7336c
movq %rax, %r15
movq %r15, (%r14)
movq 0x830(%rbp), %r12
jmp 0x73470
movq %rbx, %r15
movq 0x8(%rsp), %rax
movq %r15, (%rax)
movq 0x830(%r14), %r12
jmp 0x73470
cmpb $0x67, %r8b
setne %cl
cmpq $0x10, %r13
setne %dl
orb %cl, %dl
jne 0x7340f
movq 0x8(%r12), %xmm0
movq 0x830(%rdi), %rbx
movq %xmm0, %r15
xorl %r8d, %r8d
testq %r15, %r15
jns 0x733b4
movb $0x2d, (%rbx)
pushq $0x1
popq %r8
movl %r8d, %eax
addq %rax, %rbx
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x73494
jp 0x73494
movw $0x2e30, (%rbx)         # imm = 0x2E30
movb $0x30, 0x2(%rbx)
pushq $0x3
popq %r13
jmp 0x7392f
testb $0x8, 0x3(%r12)
jne 0x73485
movq 0x8(%r12), %rsi
movq %r14, %rdx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x73b88
movq %rcx, (%r14)
jmp 0x73470
addl $-0x4, %eax
cmpb $0x66, %r8b
leaq 0x6f1df(%rip), %rcx     # 0xe25fc
leaq 0x6f1dd(%rip), %r9      # 0xe2601
cmoveq %rcx, %r9
cmpb $0x67, %r8b
movq %rdi, %rbx
movq 0x830(%rdi), %rdi
movslq %eax, %rsi
leaq 0x730a1(%rip), %rdx     # 0xe64e1
cmovneq %r9, %rdx
movsd 0x8(%r12), %xmm0
movl %r13d, %ecx
movb $0x1, %al
callq 0x8210
cltq
movq %rax, (%r14)
movq 0x830(%rbx), %rdi
movq %r14, %rsi
callq 0x73cb4
movq 0x830(%rbx), %r12
movq %r12, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl 0x18(%r12), %eax
movq %rax, (%r14)
addq $0x19, %r12
jmp 0x73470
movabsq $0x10000000000000, %rdx # imm = 0x10000000000000
movq %r15, %rax
notq %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
testq %rcx, %rax
jne 0x734c9
testq %r15, %r15
js 0x73890
movb $0x2b, (%rbx)
incq %rbx
pushq $0x6
jmp 0x73892
movl %r8d, 0x4(%rsp)
movq %rdi, 0x10(%rsp)
pushq $0x1
popq %rsi
leaq -0x1(%rdx), %rax
andq %r15, %rax
movq %r15, %r8
shrq $0x34, %r8
andl $0x7ff, %r8d            # imm = 0x7FF
movq %rax, %r9
orq %rdx, %r9
testl %r8d, %r8d
cmoveq %rax, %r9
leaq 0x1(,%r9,2), %rax
cmpl $0x1, %r8d
movl %r8d, %r10d
adcl $0x0, %r10d
movl $0x43e, %edi            # imm = 0x43E
subl %r10d, %edi
addl $0xfffffc19, %r10d      # imm = 0xFFFFFC19
pushq $0xb
popq %r11
btq $0x35, %rax
jb 0x73532
addq %rax, %rax
incl %r11d
decl %r10d
incl %edi
jmp 0x7351e
movq %rbx, 0x18(%rsp)
shlq $0xa, %rax
movq %rax, 0x58(%rsp)
negl %edi
movl %edi, 0x60(%rsp)
xorl %ecx, %ecx
cmpq %rdx, %r9
sete %cl
movl %ecx, %eax
incb %cl
movq %r9, %rbx
shlq %cl, %rbx
notl %eax
decq %rbx
addl %r11d, %eax
movl %eax, %ecx
shlq %cl, %rbx
movq %rbx, 0x68(%rsp)
movl %edi, 0x70(%rsp)
cmpl $0x1, %r8d
adcl $0xfffffbc2, %r8d       # imm = 0xFFFFFBC2
testq %rdx, %r9
jne 0x73586
addq %r9, %r9
decl %r8d
jmp 0x73579
shlq $0xb, %r9
movq %r9, 0x78(%rsp)
movl %r8d, 0x80(%rsp)
negl %r10d
cvtsi2sd %r10d, %xmm0
mulsd 0x5eb51(%rip), %xmm0    # 0xd20f8
cvttsd2si %xmm0, %eax
addl $0x15c, %eax            # imm = 0x15C
pushq $0x8
popq %rcx
cltd
idivl %ecx
movl %eax, %ebp
leaq 0x61d71(%rip), %rax     # 0xd5330
pushq $-0x1
popq %rcx
movslq %ebp, %r8
shlq $0x4, %r8
movl 0x8(%r8,%rax), %edx
leal (%rdi,%rdx), %r10d
movl %esi, %r9d
cmpl $-0x7c, %r10d
jl 0x735e4
movl %ecx, %r9d
cmpl $-0x5f, %r10d
jl 0x735e9
addl %r9d, %ebp
jmp 0x735c2
movq %r15, 0x48(%rsp)
movq %r14, 0x8(%rsp)
addq %r8, %rax
shll $0x3, %ebp
movq (%rax), %rax
leaq 0x88(%rsp), %rbx
movq %rax, (%rbx)
movl %edx, 0x8(%rbx)
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x73d2b
movq %rax, %r14
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x73d2b
movq %rax, %r12
movl %edx, %r13d
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x73d2b
notq %rax
leaq -0x1(%r12), %rsi
movq %rsi, %rcx
subq %r14, %rcx
movq %rcx, 0x40(%rsp)
negl %r13d
pushq $0x1
popq %rdx
movl %r13d, %ecx
shlq %cl, %rdx
leaq (%r12,%rax), %r10
decq %r10
movq %rdx, 0x50(%rsp)
leaq -0x1(%rdx), %rdi
movq %rdi, %r11
andq %rsi, %r11
shrq %cl, %rsi
xorl %r15d, %r15d
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %r9d, %r9d
cmpl $0xa, %r15d
je 0x7370b
leaq 0x62211(%rip), %rax     # 0xd58a0
movq 0x50(%rax,%r15,8), %r8
xorl %r12d, %r12d
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq %rax, %rcx
andq %r14, %rcx
setne %dl
testl %r9d, %r9d
setne %bl
orb %dl, %bl
cmpb $0x1, %bl
jne 0x736c4
addb $0x30, %al
movslq %r9d, %rdx
incl %r9d
movb %al, 0x20(%rsp,%rdx)
movl %r9d, %r12d
imulq %r8, %rcx
subq %rcx, %rsi
movq %rsi, %rax
movl %r13d, %ecx
shlq %cl, %rax
addq %r11, %rax
incq %r15
movl %r12d, %r9d
cmpq %r10, %rax
ja 0x7367e
movl %r13d, %ecx
shlq %cl, %r8
leaq 0x20(%rsp), %rdi
movl %r12d, %esi
movq %r10, %rdx
movq %rax, %rcx
movq 0x40(%rsp), %r9
callq 0x73d8f
pushq $0xa
popq %rax
movl %eax, %r14d
subl %r15d, %r14d
jmp 0x73776
xorl %r14d, %r14d
imulq $0xa, %r11, %r11
movq %r11, %rax
movl %r13d, %ecx
shrq %cl, %rax
movl %eax, %ecx
orl %r9d, %ecx
movl $0x0, %r12d
je 0x73737
addb $0x30, %al
movslq %r9d, %rcx
incl %r9d
movb %al, 0x20(%rsp,%rcx)
movl %r9d, %r12d
imulq $0xa, %r10, %r10
andq %rdi, %r11
decq %r14
movl %r12d, %r9d
cmpq %r10, %r11
jae 0x7370e
movq 0x40(%rsp), %r9
leaq 0x6214b(%rip), %rax     # 0xd58a0
imulq 0x98(%rax,%r14,8), %r9
leaq 0x20(%rsp), %rdi
movl %r12d, %esi
movq %r10, %rdx
movq %r11, %rcx
movq 0x50(%rsp), %r8
callq 0x73d8f
subl %ebp, %r14d
leal 0x15c(%r14), %r15d
leal (%r14,%r12), %r13d
addl $0x15c, %r13d           # imm = 0x15C
pushq $0x1
popq %rcx
movl %ecx, %eax
subl %r13d, %eax
testl %r13d, %r13d
leal 0x15b(%r14,%r12), %ebp
cmovlel %eax, %ebp
testl %r15d, %r15d
js 0x737fa
leal 0x7(%r12), %eax
cmpl %eax, %ebp
jge 0x737fa
movslq %r12d, %rbx
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
callq 0x83e0
addq %r14, %rbx
movl %r15d, %edx
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x8270
movslq %r13d, %rax
movw $0x302e, (%r14,%rax)    # imm = 0x302E
addl $0x2, %r13d
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %r8d
jmp 0x7392f
testl %r15d, %r15d
jns 0x73812
cmpl $-0x7, %r15d
ja 0x7394f
cmpl $0x3, %ebp
jle 0x7394f
movq 0x48(%rsp), %rax
shrq $0x3f, %rax
pushq $0x12
popq %r14
subl %eax, %r14d
cmpl %r12d, %r14d
cmovgel %r12d, %r14d
movb 0x20(%rsp), %al
movq 0x18(%rsp), %rbx
movb %al, (%rbx)
cmpl $0x2, %r12d
jl 0x73854
movb $0x2e, 0x1(%rbx)
leaq 0x2(%rbx), %rdi
leaq 0x21(%rsp), %rsi
leal -0x1(%r14), %edx
callq 0x83e0
leal 0x1(%r14), %ecx
movl %ecx, %esi
movb $0x65, (%rbx,%rsi)
addl %r15d, %r14d
setle %al
addb %al, %al
addb $0x2b, %al
leaq 0x2(%rsi), %r13
movslq %ecx, %rdx
movb %al, 0x1(%rbx,%rdx)
cmpl $0x63, %ebp
jg 0x738c2
movl %r13d, %esi
cmpl $0x9, %ebp
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %r8d
jg 0x738ef
jmp 0x7391b
pushq $0x5
popq %r13
decq %rdx
xorl %eax, %eax
testq %rdx, %r15
setne %al
leal 0x69(%rax,%rax,4), %ecx
pushq $0x6e
popq %rdx
pushq $0x61
popq %rsi
cmovel %edx, %esi
shlb $0x3, %al
orb $0x66, %al
movb %cl, (%rbx)
movb %sil, 0x1(%rbx)
movb %al, 0x2(%rbx)
movw $0x302e, 0x3(%rbx)      # imm = 0x302E
jmp 0x7392f
pushq $0x64
popq %rdi
movl %ebp, %eax
xorl %edx, %edx
divl %edi
leal 0x30(%rax), %edx
addq $0x3, %rsi
movb %dl, (%rbx,%r13)
imull $-0x64, %eax, %eax
addl %eax, %ebp
cmpl $0xa, %ebp
movq 0x8(%rsp), %r14
movl 0x4(%rsp), %r8d
jl 0x7390c
movq 0x10(%rsp), %rdi
movl %ebp, %eax
xorl %edx, %edx
pushq $0xa
popq %rcx
divl %ecx
leal 0x30(%rax), %ecx
movl %esi, %edx
incl %esi
movb %cl, (%rbx,%rdx)
imull $-0xa, %eax, %eax
addl %eax, %ebp
movl %esi, %r13d
jmp 0x7391b
addl $0x4, %ecx
movb $0x30, (%rbx,%rsi)
movl %ecx, %r13d
movq 0x10(%rsp), %rdi
movl %ebp, %eax
cltd
pushq $0xa
popq %rcx
idivl %ecx
addb $0x30, %dl
movl %r13d, %eax
incl %r13d
movb %dl, (%rbx,%rax)
addl %r8d, %r13d
movslq %r13d, %rax
movq 0x830(%rdi), %rcx
movb $0x0, (%rcx,%rax)
movq %rax, (%r14)
movq 0x830(%rdi), %r12
jmp 0x73470
testl %r13d, %r13d
jle 0x73994
movl $0xfffffea4, %ebx       # imm = 0xFFFFFEA4
subl %r14d, %ebx
movl %r13d, %r13d
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r13, %rdx
callq 0x83e0
leaq (%r14,%r13), %rdi
incq %rdi
movb $0x2e, -0x1(%rdi)
leaq (%rsp,%r13), %rsi
addq $0x20, %rsi
movq %rbx, %rdx
callq 0x83e0
incl %r12d
jmp 0x739d1
movl %r13d, %eax
negl %eax
movq 0x18(%rsp), %r14
movw $0x2e30, (%r14)         # imm = 0x2E30
leaq 0x2(%r14), %rdi
movl %eax, %ebx
pushq $0x30
popq %rsi
movq %rbx, %rdx
callq 0x8270
leaq (%r14,%rbx), %rdi
addq $0x2, %rdi
movslq %r12d, %rdx
leaq 0x20(%rsp), %rsi
callq 0x83e0
subl %r13d, %r12d
addl $0x2, %r12d
movl %r12d, %r13d
jmp 0x737e6