// File: /workspace/github_c_makefile_star2_O1/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
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
cmpq $0x0, 0x4b8(%rdi)
jne 0x9a5a7
movq $0x400, 0x4c0(%r14) # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x9480
movq %rax, 0x4b8(%r14)
movq 0x4b8(%r14), %r12
movq 0x4c0(%r14), %rbp
movzbl %bl, %eax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
movq %r15, (%rsp)
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdx
movq %r12, %rdi
movl %ebp, %esi
callq 0x9330
testq %rax, %rax
je 0x9a694
movq %rax, %rbx
movq %rbp, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r12, %rdi
movl $0xa, %esi
callq 0x91d0
testq %rax, %rax
je 0x9a6a2
movq %rax, %rbp
movq 0x8(%r15), %rax
incl 0x20(%rax)
movq 0x4b8(%r14), %r12
movq 0x90(%r14), %rax
cmpq 0x98(%r14), %rax
ja 0x9a631
movq %r14, %rdi
callq 0xb389
addq 0x8(%rsp), %rbp
subq %rbx, %rbp
addq 0x20(%rsp), %rbp
movq 0x90(%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r14)
movq -0x8(%rax), %r13
movq $0x200013, (%r13)       # imm = 0x200013
leaq 0x1(%rbp), %rsi
movq %r14, %rdi
callq 0xa305
movq %rax, 0x20(%r13)
movq (%rax), %rdi
movq %rdi, 0x10(%r13)
testq %rbp, %rbp
jle 0x9a683
movq %r12, %rsi
movq %rbp, %rdx
callq 0x93e0
movq 0x10(%r13), %rax
movb $0x0, (%rax,%rbp)
movq %rbp, 0x8(%r13)
jmp 0x9a735
movq 0xb40c5(%rip), %r13     # 0x14e760
xorl %eax, %eax
jmp 0x9a784
movq 0x4b8(%r14), %rbp
movq %rbp, %rdi
callq 0x91a0
leaq 0x1(%rax), %rbx
movq 0x4c0(%r14), %r15
cmpq %r15, %rbx
jae 0x9a78e
movq %rax, %r12
movq 0x90(%r14), %rax
cmpq 0x98(%r14), %rax
ja 0x9a6e0
movq %r14, %rdi
callq 0xb389
movq 0x90(%r14), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%r14)
movq -0x8(%rax), %r13
movq $0x200013, (%r13)       # imm = 0x200013
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa305
movq %rax, 0x20(%r13)
movq (%rax), %rdi
movq %rdi, 0x10(%r13)
testq %r12, %r12
movq (%rsp), %r15
jle 0x9a728
movq %rbp, %rsi
movq %r12, %rdx
callq 0x93e0
movq 0x10(%r13), %rax
movb $0x0, (%rax,%r12)
movq %r12, 0x8(%r13)
movq $0x0, 0x18(%r13)
movq 0x738(%r14), %rbx
movq 0x8(%rbx), %rsi
cmpq %rsi, 0x10(%rbx)
jne 0x9a765
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 %r13, (%rax,%rcx,8)
xorl %eax, %eax
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rbp
testb %al, %al
jne 0x9a5ca
jmp 0x9a7c3
leaq (%r15,%r15), %rsi
movq %rsi, 0x4c0(%r14)
movq %rbp, %rdi
callq 0x9510
movq %rax, 0x4b8(%r14)
leaq -0x1(%r15), %rcx
movq %rcx, 0x8(%rsp)
leaq (%rax,%r15), %r12
decq %r12
movb $0x1, %al
movq %r15, %rbp
movq (%rsp), %r15
jmp 0x9a784
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq