// File: /workspace/github_c_makefile_star2_O3/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 0xf9e8b
movq %rsi, %r15
movq 0x50(%rbx), %rax
movq %rsi, 0x10(%rax)
movq 0x50(%rbx), %rax
movq $0x1, 0x18(%rax)
addq $0x20, 0x50(%rbx)
movq 0x110(%rbx), %rax
cmpq %rsi, %rax
je 0xf9ee0
movq %rdx, %r13
xorl %ebp, %ebp
movq %r15, %r14
movq 0x8(%r14), %r12
cmpb $0x13, (%r12)
jne 0xf9eee
addq 0x8(%r12), %rbp
movq 0x10(%r14), %r14
cmpq %rax, %r14
jne 0xf9db7
testq %rbp, %rbp
je 0xf9ee0
cmpq 0x2a8(%rbx), %rbp
jle 0xfa177
addq $-0x20, 0x50(%rbx)
movq 0x1948(%rbx), %r14
movq 0x820(%rbx), %rax
movslq 0x7dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rbx)
leaq 0x216f8(%rip), %rcx     # 0x11b512
movq %rcx, 0x10(%rax)
movq $0x46, 0x8(%rax)
movq 0x1f00(%rbx), %rcx
movq %rbp, 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 %r13, 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 %r14, %rsi
callq 0x38dfa
jmp 0xfa12a
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xf9eaa
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r14
movq $0x200013, (%r14)       # imm = 0x200013
movq 0x850(%rbx), %r15
testq %r15, %r15
je 0xfa02f
movq 0x18(%r15), %rax
movq %rax, 0x850(%rbx)
jmp 0xfa0cf
addq $-0x20, 0x50(%rbx)
movq 0x8(%r15), %r14
jmp 0xfa12a
testb $0x40, 0x3(%r12)
je 0xf9fc7
cmpb $0x1, 0x24c(%rbx)
jne 0xf9fc7
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8a63
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x89ff
cmpq 0x128(%rbx), %rax
je 0xf9fc7
testq %rbp, %rbp
je 0xfa1d5
movq %rax, (%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %r12
cmpq %r15, %r14
je 0xf9f79
movq 0x10(%r12), %r13
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
movq %r13, %rdi
callq 0x83e0
movq 0x8(%r15), %rax
movq 0x10(%r15), %r15
addq 0x8(%rax), %r13
cmpq %r14, %r15
jne 0xf9f54
addq $-0x20, 0x50(%rbx)
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xf9f9d
movq %rbx, %rdi
callq 0xa550
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 %r14, 0x10(%rdx)
movq %rbx, %rdi
movq (%rsp), %rsi
jmp 0xfa1e3
movq 0x8(%r13), %r13
cmpq %r15, %r14
je 0xfa13c
xorl %eax, %eax
movq 0x10(%r15), %r15
incq %rax
cmpq %r14, %r15
jne 0xf9fd6
leaq 0x1(%rax), %r14
cmpl $0x7fe, %eax            # imm = 0x7FE
jbe 0xfa142
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xfa010
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r14, 0x8(%rdx)
jmp 0xfa14d
movq 0x838(%rbx), %r15
testq %r15, %r15
jne 0xfa07a
movl $0x2800, %edi           # imm = 0x2800
callq 0x8480
movq %rax, %r15
movq %rax, 0x838(%rbx)
addq $0x28, %rax
movl $0xff, %ecx
movq %rax, -0x10(%rax)
movl $0x0, -0x20(%rax)
addq $0x28, %rax
decl %ecx
jne 0xfa058
movq $0x0, -0x10(%rax)
movl $0x0, -0x20(%rax)
movq 0x18(%r15), %rax
movq %rax, 0x838(%rbx)
movq 0x8c8(%rbx), %rcx
leaq 0x8(%rcx), %rdx
cmpq $0x10000, %rdx          # imm = 0x10000
jbe 0xfa0b3
movl $0x10000, %edi          # imm = 0x10000
callq 0x8480
movq %rax, 0x8d0(%rbx)
movl $0x8, %edx
xorl %ecx, %ecx
jmp 0xfa0ba
movq 0x8d0(%rbx), %rax
addq %rax, %rcx
movq %rdx, 0x8c8(%rbx)
movq %rcx, (%r15)
movl $0x3, 0x8(%r15)
movq $0x1, 0x10(%r15)
movq %r15, 0x20(%r14)
movq (%r15), %rax
movq %rax, 0x10(%r14)
movb $0x0, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %rax, 0x18(%r14)
movq 0x738(%rbx), %rbx
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
cmpq 0x8(%rbx), %rsi
jne 0xfa11e
leaq (%rsi,%rsi), %rcx
movq %rcx, 0x8(%rbx)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x8510
movq %rax, (%rbx)
movq 0x10(%rbx), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, 0x10(%rbx)
movq %r14, (%rax,%rsi,8)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r14d
leaq 0x4c807(%rip), %rax     # 0x146950
movq (%rax,%r14,8), %rdx
movq 0x140(%rbx), %r8
movq 0x5099d(%rip), %r9      # 0x14aaf8
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa4e4
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xeab0
movq %rax, %r14
movq 0x110(%rbx), %rax
cmpq %r15, %rax
je 0xfa1cb
movq 0x10(%r14), %r12
movq 0x8(%r15), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
jle 0xfa1bf
movq 0x10(%rcx), %rsi
movq %r12, %rdi
callq 0x83e0
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdx
movq 0x110(%rbx), %rax
addq %rdx, %r12
movq 0x10(%r15), %r15
cmpq %rax, %r15
jne 0xfa197
addq $-0x20, 0x50(%rbx)
jmp 0xfa12a
addq $-0x20, 0x50(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaee6