// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: g_string_append_1
static s7_pointer g_string_append_1(s7_scheme *sc, s7_pointer args, s7_pointer caller)
    {
#define H_string_append "(string-append str1 ...) appends all its string arguments into one string"
#define Q_string_append sc->pcl_s

        s7_int len = 0;
        s7_pointer x, newstr;
        char *pos;

        if (is_null(args))
            return(make_string_with_length(sc, "", 0));

        push_stack_no_let_no_code(sc, OP_GC_PROTECT, args);
        /* get length for new string */
        for (x = args; is_not_null(x); x = cdr(x))
        {
            s7_pointer p;
            p = car(x);
            if (!is_string(p))
            {
                /* look for string-append and if found, cobble up a plausible intermediate call */
                if (has_active_methods(sc, p))
                {
                    s7_pointer func;
                    func = find_method(sc, find_let(sc, p), caller);
                    if (func != sc->undefined)
                    {
                        s7_pointer y;
                        if (len == 0)
                        {
                            unstack(sc);
                            return(s7_apply_function(sc, func, x)); /* not args (string-append "" "" ...) */
                        }
                        newstr = make_empty_string(sc, len, 0);
                        for (pos = string_value(newstr), y = args; y != x; pos += string_length(car(y)), y = cdr(y))
                            memcpy(pos, string_value(car(y)), string_length(car(y)));
                        unstack(sc);
                        return(s7_apply_function(sc, func, cons(sc, newstr, x)));
                    }
                }
                return(wrong_type_argument(sc, caller, position_of(x, args), p, T_STRING));
            }
            len += string_length(p);
        }

        if (len == 0)
        {
            unstack(sc);
            return(car(args));
        }

        if (len > sc->max_string_length)
        {
            unstack(sc);
            return(s7_error(sc, sc->out_of_range_symbol,
                        set_elist_4(sc, wrap_string(sc, "~S new string length, ~D, is larger than (*s7* 'max-string-length): ~D", 70),
                            caller,
                            wrap_integer1(sc, len),
                            wrap_integer2(sc, sc->max_string_length))));
        }

        newstr = make_empty_string(sc, len, 0);
        for (pos = string_value(newstr), x = args; is_not_null(x); pos += string_length(car(x)), x = cdr(x))
            if (string_length(car(x)) > 0)
                memcpy(pos, string_value(car(x)), string_length(car(x)));
        unstack(sc);
        return(newstr);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq %rsi, 0x110(%rdi)
je 0xc7056
movq %rdx, %r12
movq %rsi, %r14
movq 0x50(%rbx), %rax
movq %rsi, 0x10(%rax)
movq 0x50(%rbx), %rax
movq $0x1, 0x18(%rax)
addq $0x20, 0x50(%rbx)
movq 0x110(%rbx), %rax
xorl %r13d, %r13d
movq %rsi, %r15
cmpq %rax, %r15
je 0xc7075
movq 0x8(%r15), %rbp
cmpb $0x13, (%rbp)
jne 0xc712c
addq 0x8(%rbp), %r13
movq 0x10(%r15), %r15
jmp 0xc7039
leaq 0x21411(%rip), %rsi     # 0xe846e
movq %rbx, %rdi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd11d
testq %r13, %r13
je 0xc7234
cmpq 0x2a8(%rbx), %r13
jle 0xc723f
addq $-0x20, 0x50(%rbx)
movq 0x1948(%rbx), %r15
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x203f7(%rip), %rcx     # 0xe74b2
movq %rcx, 0x10(%rax)
movq $0x46, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
movq %r13, 0x8(%rcx)
movq 0x1f00(%rbx), %rcx
movq 0x2a8(%rbx), %rdx
movq 0x1f08(%rbx), %rsi
movq %rdx, 0x8(%rsi)
movq 0x1f08(%rbx), %rdx
movq 0x6f0(%rbx), %rsi
movq %rax, 0x8(%rsi)
movq 0x10(%rsi), %rax
movq %r12, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x6f0(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2cdc0
jmp 0xc728b
testb $0x40, 0x3(%rbp)
je 0xc71a8
cmpb $0x1, 0x24c(%rbx)
jne 0xc71a8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x88f3
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x888f
cmpq 0x128(%rbx), %rax
je 0xc71a8
testq %r13, %r13
je 0xc72e7
movq %rax, %rbp
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd239
movq %rax, %r12
movq 0x10(%rax), %r13
cmpq %r15, %r14
je 0xc729d
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
movq %r13, %rdi
callq 0x83e0
movq 0x8(%r14), %rax
movq 0x10(%r14), %r14
addq 0x8(%rax), %r13
jmp 0xc717d
movq 0x8(%r12), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x72a82
movslq %eax, %r14
cmpl $0x7ff, %r14d           # imm = 0x7FF
ja 0xc71d1
leaq 0x4e785(%rip), %rax     # 0x115950
movq (%rax,%r14,8), %rdx
jmp 0xc720a
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xc71f0
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r14, 0x8(%rdx)
movq 0x140(%rbx), %r8
movq 0x528e0(%rip), %r9      # 0x119af8
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9bbb
addq $-0x20, 0x50(%rbx)
movq 0x8(%r14), %r15
jmp 0xc728b
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd239
movq %rax, %r15
movq 0x10(%rax), %r12
cmpq 0x110(%rbx), %r14
je 0xc7286
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
jle 0xc727d
movq 0x10(%rax), %rsi
movq %r12, %rdi
callq 0x83e0
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
addq %rdx, %r12
movq 0x10(%r14), %r14
jmp 0xc7253
addq $-0x20, 0x50(%rbx)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $-0x20, 0x50(%rbx)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xc72c1
movq %rbx, %rdi
callq 0x9c27
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0x200001, (%rdx)       # imm = 0x200001
movq %r12, 0x8(%rdx)
movq %r15, 0x10(%rdx)
movq %rbx, %rdi
movq %rbp, %rsi
jmp 0xc72f5
addq $-0x20, 0x50(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa34c