// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: file_read_line
static s7_pointer file_read_line(s7_scheme *sc, s7_pointer port, bool with_eol, bool copied)
    {
        char *buf;
        s7_int read_size, previous_size = 0;

        if (!sc->read_line_buf)
        {
            sc->read_line_buf_size = 1024;
            sc->read_line_buf = (char *)malloc(sc->read_line_buf_size);
        }

        buf = sc->read_line_buf;
        read_size = sc->read_line_buf_size;

        while (true)
        {
            char *p, *rtn;
            size_t len;

            p = fgets(buf, read_size, port_file(port));
            if (!p)
                return(eof_object);

            rtn = strchr(buf, (int)'\n');
            if (rtn)
            {
                port_line_number(port)++;
                return(make_string_with_length(sc, sc->read_line_buf, (with_eol) ? (previous_size + rtn - p + 1) : (previous_size + rtn - p)));
            }
            /* if no newline, then either at eof or need bigger buffer */
            len = strlen(sc->read_line_buf);

            if ((len + 1) < (size_t)sc->read_line_buf_size)
                return(make_string_with_length(sc, sc->read_line_buf, len));

            previous_size = sc->read_line_buf_size;
            sc->read_line_buf_size *= 2;
            sc->read_line_buf = (char *)realloc(sc->read_line_buf, sc->read_line_buf_size);
            read_size = previous_size;
            previous_size -= 1;
            buf = (char *)(sc->read_line_buf + previous_size);
        }
        return(eof_object);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq 0x4b8(%rdi), %r15
testq %r15, %r15
je 0x93e8b
movl 0x4c0(%rbx), %esi
jmp 0x93eaf
movq $0x400, 0x4c0(%rbx) # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x8480
movq %rax, %r15
movq %rax, 0x4b8(%rbx)
movl $0x400, %esi            # imm = 0x400
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
movq %r15, %rdi
callq 0x8330
testq %rax, %rax
je 0x94063
movq %rax, %r12
movq %r15, %rdi
movl $0xa, %esi
callq 0x81d0
testq %rax, %rax
je 0x94001
xorl %r15d, %r15d
movq 0x8(%r14), %rcx
incl 0x20(%rcx)
addq %rax, %r15
subq %r12, %r15
movq 0x4b8(%rbx), %r13
movzbl 0x4(%rsp), %r12d
addq %r15, %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x93f20
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
leaq 0x1(%r12), %rsi
movq %rbx, %rdi
callq 0x9357
movq %rax, 0x20(%r14)
movq (%rax), %rdi
movq %rdi, 0x10(%r14)
testq %r12, %r12
jle 0x93f62
movq %r13, %rsi
movq %r12, %rdx
callq 0x83e0
movq 0x10(%r14), %rdi
movb $0x0, (%rdi,%r12)
movq %r12, 0x8(%r14)
movq $0x0, 0x18(%r14)
movq 0x738(%rbx), %rbx
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
cmpq 0x8(%rbx), %rsi
jne 0x93fa2
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)
jmp 0x9406a
leaq (%r15,%r15), %rsi
movq %rsi, 0x4c0(%rbx)
movq %r13, %rdi
callq 0x8510
movq %rax, 0x4b8(%rbx)
leaq (%rax,%r15), %r13
decq %r13
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
movq %r13, %rdi
movl %r15d, %esi
callq 0x8330
testq %rax, %rax
je 0x94063
movq %rax, %r12
movq %r13, %rdi
movl $0xa, %esi
callq 0x81d0
testq %rax, %rax
jne 0x9407c
movq 0x4b8(%rbx), %r13
movq %r13, %rdi
callq 0x81a0
leaq 0x1(%rax), %rbp
movq 0x4c0(%rbx), %r15
cmpq %r15, %rbp
jae 0x93fb3
movq %rax, %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0x94042
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 %rbx, %rdi
movq %rbp, %rsi
jmp 0x93f3e
movq 0xb26f6(%rip), %r14     # 0x146760
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %r15
jmp 0x93ee4