// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
andq $0x0, 0x10(%rsp)
movq %rdi, %r14
movq 0x8(%rsi), %rbx
cmpb $0x13, (%rbx)
jne 0x4f537
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%r15), %rax
movq 0x110(%r14), %rcx
cmpq %rcx, %rax
je 0x4f55f
movq 0x8(%rax), %r12
cmpq %rcx, 0x10(%rax)
je 0x4f566
movq 0x16b0(%r14), %rsi
pushq $0x3
popq %rcx
leaq 0x10(%rsp), %r8
leaq 0x8(%rsp), %r9
movq %r14, %rdi
movq %r15, %rdx
callq 0x7b9f4
cmpq 0x140(%r14), %rax
jne 0x4f595
jmp 0x4f566
movq 0x16b0(%r14), %rdx
pushq $0x13
popq %r8
pushq $0x1
popq %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xcd70
movq 0x188(%r14), %r12
cmpb $0x22, (%r12)
jne 0x4f5a1
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
subq %rsi, %rdx
je 0x4f592
movq 0x8(%r12), %rax
movq 0x48(%rax), %rax
addq 0x10(%rbx), %rsi
movq %r14, %rdi
movq %r12, %rcx
callq *0x10(%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq 0x120(%r14), %r12
je 0x4f5d5
movq 0x16b0(%r14), %rdx
movq 0xd1d10(%rip), %r8      # 0x1212c8
pushq $0x2
popq %r9
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xcf9a
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
testq %rsi, %rsi
jne 0x4f5ea
cmpq 0x8(%rbx), %rdx
je 0x4f592
subq %rsi, %rdx
addq 0x10(%rbx), %rsi
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xd11d