// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore.xo.c
// Function: x_btcl_function_s_call
er_t x_btcl_function_s_call( x_btcl_function_s* o, x_source_point_s* source_point, x_btcl_frame_s* lexical_frame, bcore_arr_sr_s* arg_list, sr_s* result )
{
    // bcore_x_btcl.x:811:1
    
    const x_btcl_signature_s* signature = o->signature;
    if( arg_list->size < signature->arg_list.size )
    {
        sr_s_asm(result,x_btcl_function_s_setup_wrapped_function(x_btcl_function_s_create(),o, arg_list) );
        return  0;
    }
    else if( arg_list->size == signature->arg_list.size )
    {
        if( o->block )
        {BLM_INIT_LEVEL(3);
            x_btcl_frame_s* frame = ((x_btcl_frame_s*)BLM_LEVEL_T_PUSH(3,x_btcl_frame_s,x_btcl_frame_s_create()));
            BLM_TRY(x_btcl_function_s_setup_frame(o,lexical_frame, source_point, frame ))
            for(sz_t i = 0; i < signature->arg_list.size; i++ ) sr_s_fork_from(x_btcl_frame_s_var_set(frame,signature->arg_list.data[ i ], sr_null() ),&(arg_list->data[ i ] ));
            sr_s_clear(result);
            BLM_TRY(x_btcl_block_s_eval(o->block,frame, result ))
            x_btcl_clone_if_weak(result );
        BLM_DOWN();}
        else if( o->external_function )
        {
            BLM_TRY(x_btcl_external_function_s_execute(o->external_function,source_point, lexical_frame, arg_list, result ))
        }
        else if( o->wrapped_function )
        {BLM_INIT_LEVEL(4);
            bcore_arr_sr_s* full_arg_list = ((bcore_arr_sr_s*)BLM_LEVEL_T_PUSH(4,bcore_arr_sr_s,bcore_arr_sr_s_create()));
            for(sz_t i = 0; i < o->wrapped_arg_list->size; i++ ) sr_s_fork_from(bcore_arr_sr_s_push_sr(full_arg_list,sr_null() ),&(o->wrapped_arg_list->data[ i ] ));
            for(sz_t i = 0; i < arg_list->size          ; i++ ) sr_s_fork_from(bcore_arr_sr_s_push_sr(full_arg_list,sr_null() ),&(arg_list->data[ i ] ));
            BLM_TRY(x_btcl_function_s_call(o->wrapped_function,source_point, lexical_frame, full_arg_list, result ))
        BLM_DOWN();}
        else
        {
            BLM_TRY(x_source_point_s_parse_error_fa(source_point,"Internal error: Function is incomplete.\n" ))
        }
    
        // chain of functions ...
        if( o->tail )
        {
            BLM_TRY(x_btcl_function_s_call_unary(o->tail,source_point, lexical_frame, result, result ))
        }
        return  0;
    }
    else
    {
        BLM_TRY(x_source_point_s_parse_error_fa(source_point,"Too many arguments. Function accepts #<sz_t> argument#<sc_t>.\n", signature->arg_list.size, signature->arg_list.size != 1 ? "s" : "" ))
    }
    return  0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r8, %rbx
movq %rcx, %r13
movq %rdx, %r15
movq %rdi, %r12
movq 0x8(%rdi), %r14
movq 0x30(%r14), %rdx
cmpq %rdx, 0x10(%rcx)
jae 0x95fee
callq 0x95afd
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x95d32
movq %rbx, %rdi
callq 0x112baf
testq %r14, %r14
je 0x960be
movq (%r14), %rdi
callq 0x1123e1
jmp 0x960c0
movq %rsi, %rbp
jne 0x9608a
cmpq $0x0, 0x10(%r12)
je 0x960d7
leaq 0x112dc6(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xe0431
movq %r15, 0x20(%rsp)
movq 0x28(%rsp), %r15
movq $0x3, 0x10(%r15)
callq 0x86f00
movabsq $-0x8f0f83b86d2b0b3, %rdx # imm = 0xF70F07C4792D4F4D
movl $0x3, %esi
movq %r15, %rdi
movq %rax, %rcx
callq 0xe0676
movq %rax, %r15
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x95e72
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x96116
movq 0x28(%rsp), %rdi
callq 0xe0b30
xorl %eax, %eax
movq 0x68(%rsp), %r13
jmp 0x96385
cmpq $0x1, %rdx
leaq 0xbd65a(%rip), %rax     # 0x1536ef
leaq 0xaea0c(%rip), %rcx     # 0x144aa8
cmoveq %rax, %rcx
leaq 0xadd6f(%rip), %rsi     # 0x143e16
movq %rbp, %rdi
xorl %eax, %eax
callq 0x95f0b
movq %rax, %r13
testq %rax, %rax
jne 0x96102
jmp 0x963d0
xorl %eax, %eax
movq %r14, (%rbx)
movq %rax, 0x8(%rbx)
movq $0x2, 0x10(%rbx)
xorl %r13d, %r13d
jmp 0x963d0
movq 0x18(%r12), %rdi
testq %rdi, %rdi
je 0x96212
movq %rbp, %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rbx, %r8
callq 0x95566
movq %rax, %r13
testq %rax, %rax
je 0x9638e
leaq 0x112cc7(%rip), %rax    # 0x1a8dd0
movq (%rax), %rdi
callq 0xe0b30
jmp 0x963d0
movq %r15, 0x60(%rsp)
movq %rbp, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
cmpq $0x0, 0x30(%r14)
je 0x96189
movq 0x60(%rsp), %rax
leaq 0x78(%rax), %r15
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0xddff8
movq 0x8(%r13), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x112dbc
incq %rbp
addq $0x18, %rbx
cmpq 0x30(%r14), %rbp
jb 0x96139
movq 0x58(%rsp), %rbx
testq %rbx, %rbx
movq 0x68(%rsp), %r13
movq 0x60(%rsp), %r14
je 0x961d8
movq 0x10(%rbx), %rax
movq %rax, 0x40(%rsp)
movups (%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
testb $0x2, %al
je 0x961ca
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x112485
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x10(%r12), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x8b0fe
movq %rax, %r15
testq %rax, %rax
je 0x961fd
movq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r15, %r13
testq %r15, %r15
movq 0x50(%rsp), %rbp
je 0x96371
xorl %eax, %eax
jmp 0x96385
cmpq $0x0, 0x20(%r12)
je 0x963e5
movq %r15, 0x20(%rsp)
movq %rbp, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
leaq 0x112b9c(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xe0431
movq 0x30(%rsp), %r15
movq $0x4, 0x10(%r15)
xorl %eax, %eax
callq 0xc494c
movabsq $-0x78ea303a4f284a4, %rdx # imm = 0xF8715CFC5B0D7B5C
movl $0x4, %esi
movq %r15, %rdi
movq %rax, %rcx
callq 0xe0676
movq %rax, %rbp
movq 0x28(%r12), %rax
cmpq $0x0, 0x10(%rax)
je 0x962e1
xorl %ebx, %ebx
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0xc4cee
movq 0x28(%r12), %rcx
movq 0x8(%rcx), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x112dbc
incq %r14
movq 0x28(%r12), %rax
addq $0x18, %rbx
cmpq 0x10(%rax), %r14
jb 0x9628b
cmpq $0x0, 0x10(%r13)
movq 0x20(%rsp), %r15
je 0x9633b
xorl %ebx, %ebx
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0xc4cee
movq 0x8(%r13), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x112dbc
incq %r14
addq $0x18, %rbx
cmpq 0x10(%r13), %r14
jb 0x962f2
movq 0x20(%r12), %rdi
movq 0x50(%rsp), %r14
movq %r14, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq 0x58(%rsp), %rbx
movq %rbx, %r8
callq 0x95f8f
movq %rax, %r13
testq %rax, %rax
je 0x963fb
movq 0x30(%rsp), %rdi
jmp 0x9610c
movq %rbx, %rdi
callq 0x8a9ee
leaq 0x28(%rsp), %rdi
callq 0xe0b11
movb $0x1, %al
movq 0x20(%rsp), %r15
testb %al, %al
je 0x963d0
movq 0x30(%r12), %rdi
testq %rdi, %rdi
je 0x960cf
movq %rbp, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %rbx, %r8
callq 0x91cc3
movq %rax, %rbx
testq %rax, %rax
je 0x963c7
leaq 0x112a14(%rip), %rax    # 0x1a8dd0
movq (%rax), %rdi
callq 0xe0b30
movq %rbx, %r13
testq %rbx, %rbx
je 0x960cf
movq %r13, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xada01(%rip), %rsi     # 0x143ded
movq %rbp, %rdi
xorl %eax, %eax
callq 0x95f0b
jmp 0x960f6
leaq 0x30(%rsp), %rdi
callq 0xe0b11
movq %r14, %rbp
jmp 0x9638e