// File: /workspace/github_c_makefile_star2_O1/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 0x68550
movq 0x8(%r14), %rax
movq %rax, (%rsp)
movq 0x10(%r12), %rax
movq 0x110(%rbx), %rcx
cmpq %rcx, %rax
je 0x6857e
movq 0x8(%rax), %r13
cmpq %rcx, 0x10(%rax)
je 0x68587
movq 0x16b0(%rbx), %rsi
leaq 0x8(%rsp), %r8
movq %rsp, %r9
movq %rbx, %rdi
movq %r12, %rdx
movl $0x3, %ecx
callq 0xa0e7c
movq %rax, %r15
cmpq 0x140(%rbx), %rax
sete %al
jmp 0x68589
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 0xf1ae
movq 0x188(%rbx), %r13
jmp 0x68591
movb $0x1, %al
testb %al, %al
je 0x686c6
cmpb $0x22, (%r13)
jne 0x685c3
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
subq %rsi, %rdx
je 0x685bb
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 0x686c6
cmpq 0x120(%rbx), %r13
je 0x685fb
movq 0x16b0(%rbx), %rdx
movq 0xf1cee(%rip), %r8      # 0x15a2c8
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 0xf3da
movq 0x8(%rsp), %r12
testq %r12, %r12
jne 0x6860f
movq (%rsp), %rax
cmpq 0x8(%r14), %rax
je 0x685bb
movq (%rsp), %r13
subq %r12, %r13
addq 0x10(%r14), %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x68632
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r15
movq $0x200013, (%r15)       # imm = 0x200013
leaq 0x1(%r13), %rsi
movq %rbx, %rdi
callq 0xa305
movq %rax, 0x20(%r15)
movq (%rax), %rdi
movq %rdi, 0x10(%r15)
testq %r13, %r13
jle 0x68676
movq %r12, %rsi
movq %r13, %rdx
callq 0x93e0
movq 0x10(%r15), %rax
movb $0x0, (%rax,%r13)
movq %r13, 0x8(%r15)
movq $0x0, 0x18(%r15)
movq 0x738(%rbx), %rbx
movq 0x8(%rbx), %rsi
cmpq %rsi, 0x10(%rbx)
jne 0x686b3
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 %r15, (%rax,%rcx,8)
movq %r15, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq