// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_write_string
static s7_pointer g_write_string(s7_scheme *sc, s7_pointer args)
    {
#define H_write_string "(write-string str port start end) writes str to port."
#define Q_write_string s7_make_circular_signature(sc, 3, 4, sc->is_string_symbol, sc->is_string_symbol, s7_make_signature(sc, 2, sc->is_output_port_symbol, sc->not_symbol), sc->is_integer_symbol)
        s7_pointer str, port;
        s7_int start = 0, end;

        str = car(args);
        if (!is_string(str))
            return(method_or_bust(sc, str, sc->write_string_symbol, args, T_STRING, 1));

        end = string_length(str);
        if (!is_null(cdr(args)))
        {
            s7_pointer inds;
            port = cadr(args);
            inds = cddr(args);
            if (!is_null(inds))
            {
                s7_pointer p;
                p = start_and_end(sc, sc->write_string_symbol, args, 3, &start, &end);
                if (p != sc->unused) return(p);
            }
        }
        else port = sc->output_port;
        if (!is_output_port(port))
        {
            if (port == sc->F)
            {
                s7_int len;
                if ((start == 0) && (end == string_length(str)))
                    return(str);
                len = (s7_int)(end - start);
                return(make_string_with_length(sc, (char *)(string_value(str) + start), len));
            }
            return(method_or_bust_with_type(sc, port, sc->write_string_symbol, args, an_output_port_string, 2));
        }
        if (start == end)
            return(str);
        port_write_string(port)(sc, (char *)(string_value(str) + start), (end - start), port);
        return(str);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq $0x0, 0x8(%rsp)
movq 0x8(%rsi), %r14
cmpb $0x13, (%r14)
jne 0x63535
movq 0x8(%r14), %rax
movq %rax, (%rsp)
movq 0x10(%r12), %rax
movq 0x110(%rbx), %rcx
cmpq %rcx, %rax
je 0x63563
movq 0x8(%rax), %r13
cmpq %rcx, 0x10(%rax)
je 0x6356a
movq 0x16b0(%rbx), %rsi
leaq 0x8(%rsp), %r8
movq %rsp, %r9
movq %rbx, %rdi
movq %r12, %rdx
movl $0x3, %ecx
callq 0x9a55e
movq %rax, %r15
cmpq 0x140(%rbx), %rax
jne 0x6369c
jmp 0x6356a
movq 0x16b0(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
movl $0x13, %r8d
movl $0x1, %r9d
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe42d
movq 0x188(%rbx), %r13
cmpb $0x22, (%r13)
jne 0x6359c
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
subq %rsi, %rdx
je 0x63594
movq 0x8(%r13), %rax
movq 0x48(%rax), %rax
addq 0x10(%r14), %rsi
movq %rbx, %rdi
movq %r13, %rcx
callq *0x10(%rax)
movq %r14, %r15
jmp 0x6369c
cmpq 0x120(%rbx), %r13
je 0x635d4
movq 0x16b0(%rbx), %rdx
movq 0xeed15(%rip), %r8      # 0x1522c8
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rcx
movl $0x2, %r9d
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe659
movq 0x8(%rsp), %r13
movq (%rsp), %r12
testq %r13, %r13
jne 0x635e8
cmpq 0x8(%r14), %r12
je 0x63594
subq %r13, %r12
addq 0x10(%r14), %r13
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x6360e
movq %rbx, %rdi
callq 0xa550
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x200013, (%r15)       # imm = 0x200013
leaq 0x1(%r12), %rsi
movq %rbx, %rdi
callq 0x9357
movq %rax, 0x20(%r15)
movq (%rax), %rdi
movq %rdi, 0x10(%r15)
testq %r12, %r12
jle 0x63650
movq %r13, %rsi
movq %r12, %rdx
callq 0x83e0
movq 0x10(%r15), %rdi
movb $0x0, (%rdi,%r12)
movq %r12, 0x8(%r15)
movq $0x0, 0x18(%r15)
movq 0x738(%rbx), %rbx
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
cmpq 0x8(%rbx), %rsi
jne 0x63690
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 %r15, (%rax,%rsi,8)
movq %r15, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq