// File: /workspace/github_c_makefile_star2_O3/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 0xdab1f(%rip), %rdx     # 0x14a970
cmpb $0x0, (%rax,%rdx)
je 0x6fee5
movq 0x10(%rcx), %rdx
cmpb $0x1, (%rdx)
jne 0x6ff0f
movq 0x8(%rdx), %rsi
cmpb $0xb, (%rsi)
jne 0x6ff47
movq 0x8(%rsi), %rdx
leaq -0x11(%rdx), %rax
cmpq $-0xf, %rax
jae 0x6ff9a
movq 0x1370(%rbx), %rax
movq 0x8(%rax), %rax
movq 0xd6ac7(%rip), %rcx     # 0x146960
movq 0xe5790(%rip), %rdx     # 0x155630
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), %r12
movq 0x1ee8(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x38dfa
jmp 0x7011c
movq 0x1370(%rbx), %rdx
movq 0xe54ad(%rip), %r8      # 0x1553a0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %r9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe659
cmpb $0xb, %al
jne 0x6ff6d
testb $0x8, 0x3(%r14)
jne 0x6ffd6
movq 0x8(%r14), %rsi
movl 0xdab00(%rip), %eax     # 0x14aa28
shlq $0x3f, %rax
cmpq %rsi, %rax
jne 0x6ffe4
leaq 0xa673c(%rip), %r14     # 0x116678
movl $0x14, %r15d
jmp 0x7006a
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 0xe42d
movslq 0x468(%rbx), %rcx
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x67, %r8d
movq %r15, %r9
callq 0x8f49e
movq %rax, %r14
movq (%r15), %r15
jmp 0x7006a
movslq 0x468(%rbx), %r8
leaq 0x10(%rsp), %r15
movq %r15, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
movl $0x67, %r9d
callq 0xd7ce
movq (%r15), %rdx
movq %rbx, %rdi
movq %rax, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x37ebe
movzbl 0x18(%r14), %r15d
addq $0x19, %r14
jmp 0x7006a
leaq 0xb0f(%rbx), %r14
leaq 0xb0e(%rbx), %rdi
movb $0x0, 0xb0f(%rbx)
movq %rsi, %rcx
negq %rcx
cmovsq %rsi, %rcx
movq $-0x1, %r8
xorl %r15d, %r15d
leaq 0xa652c(%rip), %r9      # 0x116540
movabsq $-0x3333333333333333, %r10 # imm = 0xCCCCCCCCCCCCCCCD
movq %rcx, %rax
mulq %r10
shrq $0x3, %rdx
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
movq %rcx, %r11
subq %rax, %r11
movb (%r9,%r11), %al
movb %al, 0x1(%rdi,%r8)
incq %r15
decq %r8
cmpq $0x9, %rcx
movq %rdx, %rcx
ja 0x7001e
testq %rsi, %rsi
js 0x70058
subq %r15, %r14
jmp 0x7006a
movb $0x2d, 0x1(%rdi,%r8)
subq %r15, %rdi
negq %r8
movq %r8, %r15
movq %rdi, %r14
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x70089
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r12
movq $0x200013, (%r12)       # imm = 0x200013
leaq 0x1(%r15), %rsi
movq %rbx, %rdi
callq 0x9357
movq %rax, 0x20(%r12)
movq (%rax), %rdi
movq %rdi, 0x10(%r12)
testq %r15, %r15
jle 0x700ce
movq %r14, %rsi
movq %r15, %rdx
callq 0x83e0
movq 0x10(%r12), %rdi
movb $0x0, (%rdi,%r15)
movq %r15, 0x8(%r12)
movq $0x0, 0x18(%r12)
movq 0x738(%rbx), %rbx
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
cmpq 0x8(%rbx), %rsi
jne 0x70110
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%rbx)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%rbx)
movq 0x10(%rbx), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%rbx)
movq %r12, (%rax,%rsi,8)
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq