// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
leaq 0x922e(%rip), %rax      # 0xd1e0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x9020(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x2090
movq 0x9011(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x2240
leaq 0x91c2(%rip), %rax      # 0xd1a4
movl $0x0, (%rax)
movl $0x0, -0x24(%rbp)
movl -0x4(%rbp), %edi
leaq -0x6(%rbp), %rsi
movl $0x1, %edx
callq 0x2170
cmpq $0x0, %rax
je 0x4270
xorl %eax, %eax
movq 0x8fcd(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x402a
movq 0x8fc1(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x4034
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x28(%rbp)
jmp 0x4034
movl -0x28(%rbp), %eax
movl %eax, -0x10(%rbp)
xorl %eax, %eax
movq 0x8f9d(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x405b
movq 0x8f91(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4065
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x2c(%rbp)
jmp 0x4065
movl -0x2c(%rbp), %eax
movl %eax, -0xc(%rbp)
movsbl -0x6(%rbp), %eax
cmpl $0x9, %eax
je 0x407d
movsbl -0x6(%rbp), %eax
cmpl $0xd, %eax
jne 0x4082
jmp 0x3fef
movsbl -0x6(%rbp), %eax
cmpl $0xa, %eax
jne 0x418f
movb -0x6(%rbp), %al
movl -0x10(%rbp), %esi
leaq 0x9108(%rip), %rcx      # 0xd1a4
addl (%rcx), %esi
movl -0xc(%rbp), %edx
movsbl %al, %edi
callq 0x31f0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
leaq 0x90d7(%rip), %rax      # 0xd190
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x90cb(%rip), %rax      # 0xd190
movl %ecx, (%rax)
movl -0x10(%rbp), %eax
leaq 0x90c3(%rip), %rcx      # 0xd194
movl (%rcx), %ecx
subl $0x4, %ecx
cmpl %ecx, %eax
jl 0x4105
leaq 0x90c3(%rip), %rax      # 0xd1a4
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x90b7(%rip), %rax      # 0xd1a4
movl %ecx, (%rax)
movl -0x10(%rbp), %edi
leaq 0x90ab(%rip), %rax      # 0xd1a4
addl (%rax), %edi
subl $0x1, %edi
callq 0x2ef0
jmp 0x4144
leaq 0x9084(%rip), %rax      # 0xd190
movl (%rax), %eax
leaq 0x907f(%rip), %rcx      # 0xd194
movl (%rcx), %ecx
subl $0x4, %ecx
cmpl %ecx, %eax
jl 0x4131
movl -0x10(%rbp), %edi
leaq 0x907c(%rip), %rax      # 0xd1a4
addl (%rax), %edi
callq 0x2ef0
jmp 0x4142
movl -0x10(%rbp), %edi
leaq 0x9069(%rip), %rax      # 0xd1a4
addl (%rax), %edi
callq 0x2ef0
jmp 0x4144
movl -0x10(%rbp), %eax
leaq 0x9046(%rip), %rcx      # 0xd194
movl (%rcx), %ecx
subl $0x4, %ecx
cmpl %ecx, %eax
jl 0x4176
movq 0x8e82(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
leaq 0x902c(%rip), %rax      # 0xd194
movl (%rax), %esi
subl $0x5, %esi
xorl %edx, %edx
callq 0x2240
jmp 0x418a
movq 0x8e63(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x10(%rbp), %esi
xorl %edx, %edx
callq 0x2240
jmp 0x426b
movb -0x6(%rbp), %al
movl -0x10(%rbp), %esi
leaq 0x9008(%rip), %rcx      # 0xd1a4
addl (%rcx), %esi
movl -0xc(%rbp), %edx
movsbl %al, %edi
callq 0x31f0
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
leaq 0x8fe6(%rip), %rcx      # 0xd19c
movl (%rcx), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jge 0x41e0
movl -0x10(%rbp), %edi
leaq 0x8fdb(%rip), %rax      # 0xd1a4
addl (%rax), %edi
callq 0x3ad0
leaq 0x8fc5(%rip), %rcx      # 0xd19c
movl (%rcx), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jl 0x424e
cmpl $0x0, -0x14(%rbp)
je 0x424e
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
leaq 0x8f9b(%rip), %rcx      # 0xd194
movl (%rcx), %ecx
subl $0x4, %ecx
cmpl %ecx, %eax
jl 0x4237
leaq 0x8f9b(%rip), %rax      # 0xd1a4
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x8f8f(%rip), %rax      # 0xd1a4
movl %ecx, (%rax)
movq 0x8dc2(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
leaq 0x8f6c(%rip), %rax      # 0xd194
movl (%rax), %esi
subl $0x5, %esi
movl -0x14(%rbp), %edx
callq 0x2240
jmp 0x424c
movq 0x8da2(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x2240
jmp 0x4269
movq 0x8d8b(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x10(%rbp), %esi
movl -0xc(%rbp), %edx
addl $0x1, %edx
movl %edx, -0xc(%rbp)
callq 0x2240
jmp 0x426b
jmp 0x3fef
leaq 0x8f2d(%rip), %rax      # 0xd1a4
movl $0x0, (%rax)
movq 0x8d5c(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x2090
xorl %edi, %edi
callq 0x2cb0
movq 0x8d46(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x20f0
movq 0x8d37(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x2240
movq 0x8d24(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x20f0
movl $0x1, %eax
addq $0x30, %rsp
popq %rbp
retq
nop