// File: /workspace/github_c_makefile_star2_O2/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 0x6d10(%rip), %r14      # 0x9fe0
movq (%r14), %rdi
callq 0x20a0
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leaq 0x6eb1(%rip), %r15      # 0xa19c
andl $0x0, (%r15)
movl %ebx, -0x2c(%rbp)
movl %ebx, %edi
leaq -0x2e(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0x2170
testq %rax, %rax
je 0x3424
movq (%r14), %rax
pushq $-0x1
popq %r12
movl %r12d, %r13d
testq %rax, %rax
je 0x3321
movswl (%rax), %r13d
movswl 0x2(%rax), %r12d
movb -0x2e(%rbp), %al
movl %eax, %ecx
andb $-0x5, %cl
cmpb $0x9, %cl
je 0x32f2
movl (%r15), %esi
addl %r13d, %esi
cmpb $0xa, %al
jne 0x338a
pushq $0xa
popq %rdi
movl %r12d, %edx
callq 0x2aa9
incl %r13d
leaq 0x6e3b(%rip), %rax      # 0xa188
incl (%rax)
leaq 0x6e36(%rip), %rax      # 0xa18c
movl (%rax), %eax
addl $-0x4, %eax
movl (%r15), %edi
cmpl %eax, %r13d
jl 0x3369
leal 0x1(%rdi), %eax
movl %eax, (%r15)
addl %r13d, %edi
callq 0x2928
leaq 0x6e14(%rip), %rax      # 0xa18c
movl (%rax), %esi
leal -0x4(%rsi), %eax
movq (%r14), %rdi
cmpl %eax, %r13d
jge 0x33e8
movl %r13d, %esi
jmp 0x33eb
movq %r14, %rbx
movsbl %al, %edi
movl %r12d, %edx
callq 0x2aa9
movl %eax, %r14d
leaq 0x6df2(%rip), %rax      # 0xa194
movl (%rax), %eax
addl $-0x3, %eax
cmpl %eax, %r12d
jge 0x33c7
movl (%r15), %edi
addl %r13d, %edi
callq 0x2fb6
leaq 0x6dd6(%rip), %rcx      # 0xa194
movl (%rcx), %ecx
addl $-0x3, %ecx
cmpl %ecx, %eax
jl 0x33f7
testl %r14d, %r14d
je 0x33f7
incl %r13d
leaq 0x6db6(%rip), %rax      # 0xa18c
movl (%rax), %esi
leal -0x4(%rsi), %eax
cmpl %eax, %r13d
jge 0x3408
movq (%rbx), %rdi
movl %r13d, %esi
jmp 0x3411
addl $-0x5, %esi
xorl %edx, %edx
callq 0x2230
jmp 0x32f2
movq %rbx, %r14
movq (%rbx), %rdi
incl %r12d
movl %r13d, %esi
movl %r12d, %edx
jmp 0x3417
incl (%r15)
movq (%rbx), %rdi
addl $-0x5, %esi
movl %r14d, %edx
movq %rbx, %r14
callq 0x2230
movl -0x2c(%rbp), %ebx
jmp 0x32f2
andl $0x0, (%r15)
movq (%r14), %rdi
callq 0x20a0
xorl %edi, %edi
callq 0x27dc
movq (%r14), %rdi
callq 0x2100
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
movq (%r14), %rdi
callq 0x2100
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq