// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_number_to_string
static s7_pointer g_number_to_string(s7_scheme *sc, s7_pointer args)
    {
#define H_number_to_string "(number->string num (radix 10)) converts the number num into a string."
#define Q_number_to_string s7_make_signature(sc, 3, sc->is_string_symbol, sc->is_number_symbol, sc->is_integer_symbol)

        s7_int nlen = 0, radix; /* ignore cppcheck complaint about radix! */
        char *res;
        s7_pointer x;

        x = car(args);
        if (!s7_is_number(x))
            return(method_or_bust_with_type(sc, x, sc->number_to_string_symbol, args, a_number_string, 1));

        if (is_pair(cdr(args)))
        {
            s7_pointer y;
            y = cadr(args);
            if (s7_is_integer(y))
                radix = s7_integer(y);
            else return(method_or_bust(sc, y, sc->number_to_string_symbol, args, T_INTEGER, 2));
            if ((radix < 2) || (radix > 16))
                return(out_of_range(sc, sc->number_to_string_symbol, small_int(2), y, a_valid_radix_string));
#if (WITH_GMP)
            if (!s7_is_bignum(x))
#endif
            {
                block_t *b;
                b = number_to_string_with_radix(sc, x, radix, 0, sc->float_format_precision, 'g', &nlen);
                return(block_to_string(sc, b, nlen));
            }
        }
#if WITH_GMP
        else radix = 10;
        if (s7_is_bignum(x))
        {
            s7_pointer p;
            res = big_number_to_string_with_radix(x, radix, 0, &nlen, P_WRITE);
            p = make_string_with_length(sc, res, nlen);
            free(res);
            return(p);
        }
        res = number_to_string_base_10(sc, x, 0, sc->float_format_precision, 'g', &nlen, P_WRITE);
#else
        if (is_t_integer(x))
        {
            if (has_print_name(x))
            {
                nlen = print_name_length(x);
                res = (char *)print_name(x);
            }
            else res = integer_to_string(sc, integer(x), &nlen);
        }
        else res = number_to_string_base_10(sc, x, 0, sc->float_format_precision, 'g', &nlen, P_WRITE);
#endif
        return(make_string_with_length(sc, res, nlen));
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rcx
movq %rdi, %rbx
movq $0x0, 0x10(%rsp)
movq 0x8(%rsi), %r14
movzbl (%r14), %eax
leaq 0xdd30c(%rip), %rdx     # 0x152970
cmpb $0x0, (%rax,%rdx)
je 0x756f8
movq 0x10(%rcx), %rdx
cmpb $0x1, (%rdx)
jne 0x75722
movq 0x8(%rdx), %rsi
cmpb $0xb, (%rsi)
jne 0x7575d
movq 0x8(%rsi), %rdx
leaq -0x11(%rdx), %rax
cmpq $-0xf, %rax
jae 0x757aa
movq 0x1370(%rbx), %rax
movq 0x8(%rax), %rax
movq 0xd92b4(%rip), %rcx     # 0x14e960
movq 0xe7f7d(%rip), %rdx     # 0x15d630
movq 0x1ee8(%rbx), %rdi
movq 0x10(%rdi), %rdi
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rsi, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x1948(%rbx), %r15
movq 0x1ee8(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3b366
jmp 0x75938
movq 0x1370(%rbx), %rdx
movq 0xe7c9a(%rip), %r8      # 0x15d3a0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xf3da
cmpb $0xb, %al
jne 0x75783
testb $0x8, 0x3(%r14)
jne 0x757e6
movq 0x8(%r14), %rsi
movl 0xdd2ed(%rip), %eax     # 0x152a28
shlq $0x3f, %rax
cmpq %rsi, %rax
jne 0x757f9
movq $0x14, 0x10(%rsp)
leaq 0xa9e10(%rip), %r14     # 0x11f568
jmp 0x75886
movq 0x1370(%rbx), %rdx
movq %rbx, %rdi
movl $0xb, %r8d
movl $0x2, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xf1ae
movslq 0x468(%rbx), %rcx
leaq 0x10(%rsp), %r9
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x67, %r8d
callq 0x95820
movq %rax, %r14
jmp 0x75886
movslq 0x468(%rbx), %r8
leaq 0x10(%rsp), %r15
movq %r15, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
movl $0x67, %r9d
callq 0xe55c
movq (%r15), %rdx
movq %rbx, %rdi
movq %rax, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3a419
movzbl 0x18(%r14), %eax
movq %rax, 0x10(%rsp)
addq $0x19, %r14
jmp 0x75886
leaq 0xb0f(%rbx), %rdi
leaq 0xb0e(%rbx), %r14
movb $0x0, 0xb0f(%rbx)
movq %rsi, %rcx
negq %rcx
cmovsq %rsi, %rcx
movq $-0x1, %r8
xorl %r9d, %r9d
leaq 0xa9c07(%rip), %r10     # 0x11f430
movabsq $-0x3333333333333333, %r11 # imm = 0xCCCCCCCCCCCCCCCD
movq %rcx, %rax
mulq %r11
shrq $0x3, %rdx
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
movq %rcx, %r15
subq %rax, %r15
movb (%r10,%r15), %al
movb %al, 0x1(%r14,%r8)
incq %r9
decq %r8
cmpq $0x9, %rcx
movq %rdx, %rcx
ja 0x75833
testq %rsi, %rsi
js 0x75875
subq %r9, %rdi
movq %r9, 0x10(%rsp)
movq %rdi, %r14
jmp 0x75886
movb $0x2d, 0x1(%r14,%r8)
subq %r9, %r14
negq %r8
movq %r8, 0x10(%rsp)
movq 0x10(%rsp), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x758a3
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x200013, (%r15)       # imm = 0x200013
leaq 0x1(%r12), %rsi
movq %rbx, %rdi
callq 0xa305
movq %rax, 0x20(%r15)
movq (%rax), %rdi
movq %rdi, 0x10(%r15)
testq %r12, %r12
jle 0x758e8
movq %r14, %rsi
movq %r12, %rdx
callq 0x93e0
movq 0x10(%r15), %rax
movb $0x0, (%rax,%r12)
movq %r12, 0x8(%r15)
movq $0x0, 0x18(%r15)
movq 0x738(%rbx), %rbx
movq 0x8(%rbx), %rsi
cmpq %rsi, 0x10(%rbx)
jne 0x75925
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq %r15, (%rax,%rcx,8)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq