// File: /workspace/github_c_makefile_star2_O1/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
subq $0x38, %rsp
movq %rdx, 0x18(%rsp)
cmpq %rsi, 0x110(%rdi)
movq %rdi, 0x8(%rsp)
je 0x102cd5
movq %rsi, %r14
movq 0x50(%rdi), %rax
movq %rsi, 0x10(%rax)
movq 0x50(%rdi), %rax
movq $0x1, 0x18(%rax)
addq $0x20, 0x50(%rdi)
cmpq %rsi, 0x110(%rdi)
je 0x102d32
xorl %r13d, %r13d
movq %r14, %rbp
movq 0x8(%rbp), %r15
movb (%r15), %bl
cmpb $0x13, %bl
jne 0x102ad0
addq 0x8(%r15), %r13
jmp 0x102cb4
testb $0x40, 0x3(%r15)
movq %r13, 0x30(%rsp)
je 0x102c19
cmpb $0x1, 0x24c(%rdi)
jne 0x102c19
movb %bl, 0x17(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x9a55
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rdx
callq 0x99ef
movq 0x8(%rsp), %rdi
movq %rax, %rbx
movq 0x128(%rdi), %rax
cmpq %rax, %rbx
je 0x102c0c
movq %rax, 0x28(%rsp)
testq %r13, %r13
je 0x102bea
movq %r13, %rsi
xorl %edx, %edx
callq 0xf83b
movq %rax, 0x20(%rsp)
cmpq %r14, %rbp
je 0x102b7b
movq 0x20(%rsp), %rax
movq 0x10(%rax), %r12
movq %r14, %r13
movq 0x8(%r13), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
movq %r12, %rdi
callq 0x93e0
movq 0x8(%r13), %rax
movq 0x10(%r13), %r13
addq 0x8(%rax), %r12
cmpq %rbp, %r13
jne 0x102b56
movq 0x8(%rsp), %rdx
addq $-0x20, 0x50(%rdx)
movq 0x90(%rdx), %rax
cmpq 0x98(%rdx), %rax
ja 0x102ba4
movq 0x8(%rsp), %rdi
callq 0xb389
movq 0x8(%rsp), %rdx
movq 0x90(%rdx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rdx)
movq -0x8(%rax), %rdx
movq $0x200001, (%rdx)       # imm = 0x200001
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rdx)
movq %rbp, 0x10(%rdx)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xbd41
movq 0x8(%rsp), %rdi
movq %rax, %r12
movq 0x30(%rsp), %r13
jmp 0x102c07
addq $-0x20, 0x50(%rdi)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0xbd41
movq 0x8(%rsp), %rdi
movq %rax, %r12
movq 0x28(%rsp), %rax
cmpq %rax, %rbx
movb 0x17(%rsp), %bl
jne 0x102cb4
movl $0x1, %eax
cmpq %r14, %rbp
je 0x102c31
movq %r14, %rcx
incl %eax
movq 0x10(%rcx), %rcx
cmpq %rbp, %rcx
jne 0x102c26
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %r12
movslq %eax, %r13
cmpl $0x7ff, %r13d           # imm = 0x7FF
ja 0x102c53
leaq 0x4bd03(%rip), %rax     # 0x14e950
movq (%rax,%r13,8), %rdx
jmp 0x102c93
movq 0x90(%rdi), %rax
cmpq 0x98(%rdi), %rax
ja 0x102c72
movq 0x8(%rsp), %rdi
callq 0xb389
movq 0x8(%rsp), %rdi
movq 0x90(%rdi), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rdi)
movq -0x8(%rax), %rdx
movq $0xb, (%rdx)
movq %r13, 0x8(%rdx)
movq 0x140(%rdi), %r8
movq 0x4fe57(%rip), %r9      # 0x152af8
movq %r12, %rsi
movq %r15, %rcx
callq 0xb31d
movq %rax, %r12
movq 0x30(%rsp), %r13
cmpb $0x13, %bl
jne 0x102f78
movq 0x10(%rbp), %rbp
movq 0x8(%rsp), %rdi
cmpq 0x110(%rdi), %rbp
jne 0x102abb
jmp 0x102d35
movq 0x90(%rdi), %rax
cmpq 0x98(%rdi), %rax
ja 0x102cf4
movq 0x8(%rsp), %rdi
callq 0xb389
movq 0x8(%rsp), %rdi
movq 0x90(%rdi), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rdi)
movq -0x8(%rax), %r12
movq $0x200013, (%r12)       # imm = 0x200013
movq 0x850(%rdi), %r14
testq %r14, %r14
je 0x102dfc
movq 0x18(%r14), %rax
movq %rax, 0x850(%rdi)
jmp 0x102eba
xorl %r13d, %r13d
testq %r13, %r13
je 0x102dee
cmpq 0x2a8(%rdi), %r13
jle 0x102f1b
addq $-0x20, 0x50(%rdi)
movq 0x1948(%rdi), %r12
movq 0x820(%rdi), %rax
movslq 0x7dc(%rdi), %rcx
movq (%rax,%rcx,8), %rax
incl %ecx
andl $0x7, %ecx
movl %ecx, 0x7dc(%rdi)
leaq 0x21687(%rip), %rcx     # 0x124402
movq %rcx, 0x10(%rax)
movq $0x46, 0x8(%rax)
movq 0x1f00(%rdi), %rcx
movq %r13, 0x8(%rcx)
movq 0x1f00(%rdi), %rcx
movq 0x2a8(%rdi), %rdx
movq 0x1f08(%rdi), %rsi
movq %rdx, 0x8(%rsi)
movq 0x1f08(%rdi), %rdx
movq 0x6f0(%rdi), %rsi
movq %rax, 0x8(%rsi)
movq 0x10(%rsi), %rax
movq 0x18(%rsp), %rsi
movq %rsi, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x6f0(%rdi), %rdx
movq %r12, %rsi
callq 0x3b366
jmp 0x102f78
addq $-0x20, 0x50(%rdi)
movq 0x8(%r14), %r12
jmp 0x102f78
cmpq $0x0, 0x838(%rdi)
jne 0x102e47
movl $0x2800, %edi           # imm = 0x2800
callq 0x9480
movq 0x8(%rsp), %rdi
movq %rax, 0x838(%rdi)
addq $0x28, %rax
movl $0xff, %ecx
movq %rax, -0x10(%rax)
movl $0x0, -0x20(%rax)
addq $0x28, %rax
decl %ecx
jne 0x102e25
movq $0x0, -0x10(%rax)
movl $0x0, -0x20(%rax)
movq 0x838(%rdi), %r14
movq 0x18(%r14), %rax
movq %rax, 0x838(%rdi)
movl $0x0, 0x8(%r14)
movq 0x8c8(%rdi), %rax
addq $0x8, %rax
cmpq $0x10001, %rax          # imm = 0x10001
jb 0x102e9a
movl $0x10000, %edi          # imm = 0x10000
callq 0x9480
movq 0x8(%rsp), %rdi
movq %rax, 0x8d0(%rdi)
movq $0x0, 0x8c8(%rdi)
movl $0x8, %eax
movq 0x8d0(%rdi), %rcx
addq 0x8c8(%rdi), %rcx
movq %rax, 0x8c8(%rdi)
movq %rcx, (%r14)
movl $0x3, 0x8(%r14)
movq $0x1, 0x10(%r14)
movq %r14, 0x20(%r12)
movq (%r14), %rax
movq %rax, 0x10(%r12)
movb $0x0, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %rax, 0x18(%r12)
movq 0x738(%rdi), %rbx
movq 0x8(%rbx), %rsi
cmpq %rsi, 0x10(%rbx)
jne 0x102f06
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq %r12, (%rax,%rcx,8)
jmp 0x102f78
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf83b
movq 0x8(%rsp), %rcx
movq %rax, %r12
cmpq %r14, 0x110(%rcx)
je 0x102f73
movq 0x10(%r12), %r15
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
jle 0x102f5e
movq 0x10(%rax), %rsi
movq %r15, %rdi
callq 0x93e0
movq 0x8(%rsp), %rcx
movq 0x8(%r14), %rax
movq 0x10(%r14), %r14
addq 0x8(%rax), %r15
cmpq 0x110(%rcx), %r14
jne 0x102f40
addq $-0x20, 0x50(%rcx)
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq