// File: /workspace/github_c_makefile_star2_O3/vasusharma7[P]Text-Editor/stdedit.c
// Function: readfile
int readfile(int fdw){
    char buffer[2];
    int x,y,mk;
    point *temp = data.front;
    clear();
    move(0,0);
    stline = 0;
    int count = 0;
    while(read(fdw,buffer,1)){
        getyx(stdscr,y,x);
        if(buffer[0] == '\t' || buffer[0] == '\r')
            continue;
        // if(stline > 0){
        //     display(stline);
        //     break;
        // }
        if(buffer[0] == '\n'){
            add_char(buffer[0],y+stline,x);
                y++;
                lines++;
                if(y >= (by - 4)){
                    stline++;
                    add_line(y+stline - 1);
                }
                else if(lines >= (by - 4)){
                    
                    add_line(y+stline);
                }
                else{
                    add_line(y + stline);
                }
                if(y >= (by - 4))
                    move(by - 5,0);
                else
                    move(y,0);
        }
        else{
            mk = add_char(buffer[0],y+stline,x);
                if( ((x >= (bx - 3)) || (getwidth(y+stline) >= bx-3)) && (mk != 0)){
                    y++;
                    if(y >= (by - 4)){
                        stline++;
                        move(by - 5,mk);
                    }
                    else{
                        move(y,mk);
                    }
                }
                else{
                    move(y,++x);
                }
        }
    }
    stline = 0;
    clear();
    display(0);
    refresh();
    move(0,0);
    refresh();
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x6c63(%rip), %r14      # 0x9fe0
movq (%r14), %rdi
callq 0x20a0
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leaq 0x6e04(%rip), %r13      # 0xa19c
movl $0x0, (%r13)
leaq -0x2a(%rbp), %rsi
movl $0x1, %edx
movl %ebx, %edi
callq 0x2170
testq %rax, %rax
je 0x3509
movl %ebx, -0x30(%rbp)
movq (%r14), %rax
testq %rax, %rax
je 0x33cf
movswl (%rax), %r15d
movswl 0x2(%rax), %r12d
jmp 0x33db
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movb -0x2a(%rbp), %al
movl %eax, %ecx
andb $-0x5, %cl
cmpb $0x9, %cl
je 0x34f0
movl (%r13), %esi
addl %r15d, %esi
cmpb $0xa, %al
jne 0x344d
movl $0xa, %edi
movl %r12d, %edx
callq 0x2b38
incl %r15d
leaq 0x6d7a(%rip), %rax      # 0xa188
incl (%rax)
leaq 0x6d75(%rip), %rax      # 0xa18c
movl (%rax), %eax
addl $-0x4, %eax
movl (%r13), %edi
cmpl %eax, %r15d
jl 0x342c
leal 0x1(%rdi), %eax
movl %eax, (%r13)
addl %r15d, %edi
callq 0x29a6
leaq 0x6d51(%rip), %rax      # 0xa18c
movl (%rax), %esi
leal -0x4(%rsi), %eax
movq (%r14), %rdi
cmpl %eax, %r15d
jge 0x34b1
movl %r15d, %esi
jmp 0x34b4
movq %r14, %rbx
movq %r13, %r14
movsbl %al, %edi
movl %r12d, %edx
callq 0x2b38
movl %eax, %r13d
leaq 0x6d2c(%rip), %rax      # 0xa194
movl (%rax), %eax
addl $-0x3, %eax
cmpl %eax, %r12d
jge 0x348d
movl (%r14), %edi
addl %r15d, %edi
callq 0x305b
leaq 0x6d10(%rip), %rcx      # 0xa194
movl (%rcx), %ecx
addl $-0x3, %ecx
cmpl %ecx, %eax
jl 0x34bd
testl %r13d, %r13d
je 0x34bd
incl %r15d
leaq 0x6cf0(%rip), %rax      # 0xa18c
movl (%rax), %esi
leal -0x4(%rsi), %eax
cmpl %eax, %r15d
jge 0x34d6
movq (%rbx), %rdi
movl %r15d, %esi
movl %r13d, %edx
jmp 0x34c9
addl $-0x5, %esi
xorl %edx, %edx
callq 0x2230
jmp 0x34f0
movq (%rbx), %rdi
incl %r12d
movl %r15d, %esi
movl %r12d, %edx
callq 0x2230
movq %r14, %r13
movq %rbx, %r14
jmp 0x34ed
incl (%r14)
movq (%rbx), %rdi
addl $-0x5, %esi
movl %r13d, %edx
movq %r14, %r13
movq %rbx, %r14
callq 0x2230
movl -0x30(%rbp), %ebx
movl $0x1, %edx
movl %ebx, %edi
leaq -0x2a(%rbp), %rsi
callq 0x2170
testq %rax, %rax
jne 0x33bc
movl $0x0, (%r13)
movq (%r14), %rdi
callq 0x20a0
xorl %edi, %edi
callq 0x284e
movq (%r14), %rdi
callq 0x2100
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
movq (%r14), %rdi
callq 0x2100
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq