// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: make_function
static s7_pointer make_function(s7_scheme *sc, const char *name, s7_function f, s7_int req, s7_int opt, bool rst, const char *doc, s7_pointer x, c_proc_t *ptr)
                {
                    uint32_t ftype = T_C_FUNCTION;
                    if (req == 0)
                    {
                        if (rst)
                            ftype = T_C_ANY_ARGS_FUNCTION;
                        else
                        {
                            if (opt != 0)
                                ftype = T_C_OPT_ARGS_FUNCTION;
                        }
                    }
                    else
                    {
                        if (rst)
                            ftype = T_C_RST_ARGS_FUNCTION;
                    }

                    set_type(x, ftype);

                    c_function_data(x) = ptr;
                    c_function_call(x) = f;               /* f is T_App but needs cast */
                    c_function_set_base(x, x);
                    c_function_set_setter(x, sc->F);
                    c_function_name(x) = name;            /* (procedure-name proc) => (format #f "~A" proc) */
                    c_function_name_length(x) = safe_strlen(name);
                    if (doc)
                        c_function_documentation(x) = make_permanent_c_string(sc, doc);
                    else c_function_documentation(x) = NULL;
                    c_function_signature(x) = sc->F;

                    c_function_required_args(x) = req;
                    c_function_optional_args(x) = opt;    /* T_C_FUNCTION_STAR type may be set later, so T_Fst not usable here */
                    if (rst)
                        c_function_all_args(x) = MAX_ARITY;
                    else c_function_all_args(x) = req + opt;

                    c_function_class(x) = ++sc->f_class;
                    c_function_chooser(x) = fallback_chooser;
                    c_function_opt_data(x) = NULL;
                    c_function_marker(x) = NULL;
                    c_function_symbol(x) = NULL;

                    return(x);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r15
movq %rdi, %r14
movq 0x60(%rsp), %rax
movq 0x58(%rsp), %rbx
testq %rcx, %rcx
je 0x404bf
movzbl %r9b, %edi
leaq (%rdi,%rdi,2), %rdi
addq $0x30, %rdi
jmp 0x404da
movl $0x31, %edi
testb %r9b, %r9b
jne 0x404da
xorl %edi, %edi
testq %r15, %r15
setne %dil
leaq 0x30(,%rdi,2), %rdi
movq 0x50(%rsp), %r13
movq %rdi, (%rbx)
movq %rax, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
movq %rbx, 0x28(%rax)
movq 0x120(%r14), %rax
movq 0x8(%rbx), %rdx
movq %rax, 0x30(%rdx)
movq 0x8(%rbx), %rax
movq %rsi, (%rax)
xorl %eax, %eax
testq %rsi, %rsi
je 0x40520
cmpb $0x0, (%rsi)
je 0x40520
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
cmpb $0x0, (%rsi)
leaq 0x1(%rsi), %rsi
jne 0x40515
movq 0x8(%rbx), %rdx
movl %eax, 0x8(%rdx)
testq %r13, %r13
je 0x4054b
cmpb $0x0, (%r13)
je 0x40553
movq $-0x1, %rax
leaq 0x1(%rax), %rbp
cmpb $0x0, 0x1(%r13,%rax)
movq %rbp, %rax
jne 0x4053a
jmp 0x40555
xorl %r12d, %r12d
jmp 0x405e3
xorl %ebp, %ebp
movq %rcx, 0x10(%rsp)
movl %r9d, 0xc(%rsp)
leaq 0x8(%rbp), %rcx
movq %rcx, %r12
andq $-0x8, %r12
movq 0x8c8(%r14), %rax
addq %r12, %rax
cmpq $0x10001, %rax          # imm = 0x10001
jb 0x405b1
cmpq $0x200, %rcx            # imm = 0x200
jb 0x40592
movq %r12, %rdi
callq 0x9480
movq %rax, %r12
jmp 0x405c6
movl $0x10000, %edi          # imm = 0x10000
callq 0x9480
movq %rax, 0x8d0(%r14)
movq $0x0, 0x8c8(%r14)
movq %r12, %rax
movq 0x8d0(%r14), %r12
addq 0x8c8(%r14), %r12
movq %rax, 0x8c8(%r14)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x93e0
movb $0x0, (%r12,%rbp)
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %rcx
movq 0x8(%rbx), %rax
movq %r12, 0x10(%rax)
movq 0x120(%r14), %rax
movq 0x8(%rbx), %rdx
movq %rax, 0x38(%rdx)
movq %rcx, 0x18(%rbx)
movq %r15, 0x20(%rbx)
addq %rcx, %r15
testb %r9b, %r9b
movl $0x20000000, %eax       # imm = 0x20000000
cmoveq %r15, %rax
movq %rax, 0x28(%rbx)
movl 0x224(%r14), %eax
incl %eax
movl %eax, 0x224(%r14)
movq 0x8(%rbx), %rcx
movl %eax, 0xc(%rcx)
movq 0x8(%rbx), %rax
leaq 0x603b4(%rip), %rcx     # 0xa09eb
movq %rcx, 0x48(%rax)
movq 0x8(%rbx), %rax
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq 0x8(%rbx), %rax
movq %rcx, 0x60(%rax)
movq 0x8(%rbx), %rax
movq %rcx, 0x58(%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq