// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_gensym
static s7_pointer g_gensym(s7_scheme *sc, s7_pointer args)
    {
#define H_gensym "(gensym (prefix \"gensym\")) returns a new, unused symbol"
#define Q_gensym s7_make_signature(sc, 2, sc->is_gensym_symbol, sc->is_string_symbol)

        const char *prefix;
        char *name, *p, *base;
        s7_int len, plen, nlen;
        uint32_t location;
        uint64_t hash;
        s7_pointer x, str, stc;
        block_t *b, *ib;

        /* get symbol name */
        if (is_not_null(args))
        {
            s7_pointer gname;
            gname = car(args);
            if (!is_string(gname))
                return(method_or_bust_one_arg(sc, gname, sc->gensym_symbol, args, T_STRING));
            prefix = string_value(gname);
            plen = safe_strlen(prefix);
        }
        else
        {
            prefix = "gensym";
            plen = 6;
        }
        len = plen + 32; /* why 32 -- we need room for the gensym_counter integer, but (length "9223372036854775807") = 19 */

        b = mallocate(sc, len + sizeof(block_t) + 2 * sizeof(s7_cell));
        /* only 16 of block_t size is actually needed here because only the ln.tag (symbol_tag2) field is used in the embedded block_t */
        base = (char *)block_data(b);
        str = (s7_cell *)base;
        stc = (s7_cell *)(base + sizeof(s7_cell));
        ib = (block_t *)(base + 2 * sizeof(s7_cell));
        name = (char *)(base + sizeof(block_t) + 2 * sizeof(s7_cell));

        name[0] = '{';
        if (plen > 0) memcpy((void *)(name + 1), prefix, plen);
        name[plen + 1] = '}';
        name[plen + 2] = '-'; /* {gensym}-nnn */

        p = pos_int_to_str(sc, sc->gensym_counter++, &len, '\0');
        memcpy((void *)(name + plen + 3), (void *)p, len);
        nlen = len + plen + 2;

        hash = raw_string_hash((const uint8_t *)name, nlen);
        location = hash % SYMBOL_TABLE_SIZE;

        /* make-string for symbol name */
#if S7_DEBUGGING
        typeflag(str) = 0; /* here and below, this is needed to avoid set_type check errors (mallocate above) */
#endif
        set_type(str, T_STRING | T_IMMUTABLE | T_UNHEAP);
        string_length(str) = nlen;
        string_value(str) = name;
        string_hash(str) = hash;

        /* allocate the symbol in the heap so GC'd when inaccessible */
        new_cell(sc, x, T_SYMBOL | T_GENSYM);
        symbol_set_name_cell(x, str);
        symbol_info(x) = ib;
        set_global_slot(x, sc->undefined);
        /* set_initial_slot(x, sc->undefined); */
        symbol_set_local_unchecked(x, 0LL, sc->nil);
        symbol_set_ctr(x, 0);
        symbol_set_tag(x, 0);
        symbol_set_tag2(x, 0);
        symbol_clear_type(x);
        gensym_block(x) = b;

        /* place new symbol in symbol-table, but using calloc so we can easily free it (remove it from the table) in GC sweep */
#if S7_DEBUGGING
        typeflag(stc) = 0;
#endif
        set_type(stc, T_PAIR | T_IMMUTABLE | T_UNHEAP);
        set_car(stc, x);
        set_cdr(stc, vector_element(sc->symbol_table, location));
        vector_element(sc->symbol_table, location) = stc;
        pair_set_raw_hash(stc, hash);
        pair_set_raw_len(stc, (uint32_t)string_length(str));
        pair_set_raw_name(stc, string_value(str));

        add_gensym(sc, x);
        return(x);
    }

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq 0x110(%rcx), %rax
je 0x66599
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x13, %eax
je 0x6657a
movq 0x88(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x88(%rsp), %rax
movq 0xf40(%rax), %rdx
movq 0x80(%rsp), %rcx
movl $0x13, %r8d
callq 0xcfd30
movq %rax, 0x90(%rsp)
jmp 0x66904
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0xa430
movq %rax, 0x50(%rsp)
jmp 0x665ae
leaq 0x17ca1e(%rip), %rax    # 0x1e2fbe
movq %rax, 0x78(%rsp)
movq $0x6, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x58(%rsp)
movq 0x88(%rsp), %rdi
movq 0x58(%rsp), %rsi
addq $0x28, %rsi
addq $0x60, %rsi
callq 0xaa80
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x60(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x10(%rsp)
movq 0x60(%rsp), %rax
addq $0x28, %rax
addq $0x60, %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movb $0x7b, (%rax)
cmpq $0x0, 0x50(%rsp)
jle 0x66648
movq 0x70(%rsp), %rdi
addq $0x1, %rdi
movq 0x78(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x93e0
movq 0x70(%rsp), %rax
movq 0x50(%rsp), %rcx
movb $0x7d, 0x1(%rax,%rcx)
movq 0x70(%rsp), %rax
movq 0x50(%rsp), %rcx
movb $0x2d, 0x2(%rax,%rcx)
movq 0x88(%rsp), %rdi
movq 0x88(%rsp), %rcx
movl 0x220(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x220(%rcx)
movl %eax, %eax
movl %eax, %esi
leaq 0x58(%rsp), %rdx
xorl %ecx, %ecx
callq 0xd1410
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
addq 0x50(%rsp), %rdi
addq $0x3, %rdi
movq 0x68(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x93e0
movq 0x58(%rsp), %rax
addq 0x50(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xa540
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movl $0x7fed, %ecx           # imm = 0x7FED
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x44(%rsp)
movq 0x28(%rsp), %rax
movabsq $0x4000000001000013, %rcx # imm = 0x4000000001000013
movq %rcx, (%rax)
movq 0x48(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x88(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x88(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x6675e
movq 0x88(%rsp), %rdi
callq 0xc670
movq 0x88(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq $0x2000000a, (%rax)     # imm = 0x2000000A
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x20(%rax)
movq 0x88(%rsp), %rax
movq 0x128(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x88(%rsp), %rax
movq 0x110(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x30(%rsp), %rax
movq $0x0, 0x20(%rax)
movq 0x30(%rsp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x2c(%rax)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movl $0x0, 0xc(%rax)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq $0x0, 0x10(%rax)
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x28(%rax)
movq 0x20(%rsp), %rax
movabsq $0x4000000001000001, %rcx # imm = 0x4000000001000001
movq %rcx, (%rax)
movq 0x30(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rax
movq 0x148(%rax), %rax
movq 0x10(%rax), %rax
movl 0x44(%rsp), %ecx
movq (%rax,%rcx,8), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rdx
movq 0x88(%rsp), %rax
movq 0x148(%rax), %rax
movq 0x10(%rax), %rax
movl 0x44(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x2c(%rax)
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x88(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1b9d60
movq 0x30(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)