// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: integer_to_string_any_base
static size_t integer_to_string_any_base(char *p, s7_int n, int32_t radix)  /* called by number_to_string_with_radix */
    {
        s7_int i, len, end;
        bool sign;
        s7_int pown;

        if ((radix < 2) || (radix > 16))
            return(0);

        if (n == s7_int_min) /* can't negate this, so do it by hand */
        {
            static const char *mnfs[17] = {"","",
                "-1000000000000000000000000000000000000000000000000000000000000000", "-2021110011022210012102010021220101220222",
                "-20000000000000000000000000000000", "-1104332401304422434310311213", "-1540241003031030222122212",
                "-22341010611245052052301", "-1000000000000000000000", "-67404283172107811828",	"-9223372036854775808",
                "-1728002635214590698",	"-41a792678515120368", "-10b269549075433c38", "-4340724c6c71dc7a8", "-160e2ad3246366808", "-8000000000000000"};

            len = safe_strlen(mnfs[radix]);
            memcpy((void *)p, (void *)mnfs[radix], len);
            p[len] = '\0';
            return(len);
        }

        sign = (n < 0);
        if (sign) n = -n;

        /* the previous version that counted up to n, rather than dividing down below n, as here,
         *   could be confused by large ints on 64 bit machines
         */
        pown = n;
        for (i = 1; i < 100; i++)
        {
            if (pown < radix)
                break;
            pown /= (s7_int)radix;
        }
        len = i - 1;
        if (sign) len++;
        end = 0;
        if (sign)
        {
            p[0] = '-';
            end++;
        }
        for (i = len; i >= end; i--)
        {
            p[i] = dignum[n % radix];
            n /= radix;
        }
        p[len + 1] = '\0';
        return(len + 1);
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
cmpl $0x2, 0x2c(%rsp)
jl 0xc6f20
cmpl $0x10, 0x2c(%rsp)
jle 0xc6f2e
movq $0x0, 0x40(%rsp)
jmp 0xc70c6
movq 0x30(%rsp), %rax
cmpq 0x15361e(%rip), %rax    # 0x21a558
jne 0xc6f92
movslq 0x2c(%rsp), %rcx
leaq 0x14eb78(%rip), %rax    # 0x215ac0
movq (%rax,%rcx,8), %rdi
callq 0xa430
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
movslq 0x2c(%rsp), %rcx
leaq 0x14eb59(%rip), %rax    # 0x215ac0
movq (%rax,%rcx,8), %rsi
movq 0x18(%rsp), %rdx
callq 0x93e0
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0xc70c6
cmpq $0x0, 0x30(%rsp)
setl %al
andb $0x1, %al
movb %al, 0xf(%rsp)
testb $0x1, 0xf(%rsp)
je 0xc6fb4
xorl %eax, %eax
subq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
movq $0x1, 0x20(%rsp)
cmpq $0x64, 0x20(%rsp)
jge 0xc7000
movq (%rsp), %rax
movslq 0x2c(%rsp), %rcx
cmpq %rcx, %rax
jge 0xc6fde
jmp 0xc7000
movslq 0x2c(%rsp), %rcx
movq (%rsp), %rax
cqto
idivq %rcx
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0xc6fc6
movq 0x20(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x18(%rsp)
testb $0x1, 0xf(%rsp)
je 0xc7023
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
testb $0x1, 0xf(%rsp)
je 0xc7049
movq 0x38(%rsp), %rax
movb $0x2d, (%rax)
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x10(%rsp), %rax
jl 0xc70a9
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
cqto
idivq %rcx
leaq 0x11a5cb(%rip), %rax    # 0x1e1640
movb (%rax,%rdx), %dl
movq 0x38(%rsp), %rax
movq 0x20(%rsp), %rcx
movb %dl, (%rax,%rcx)
movslq 0x2c(%rsp), %rcx
movq 0x30(%rsp), %rax
cqto
idivq %rcx
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0xc7053
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movb $0x0, 0x1(%rax,%rcx)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq