// File: /workspace/github_c_makefile_star2_O0/vasusharma7[P]Text-Editor/stdedit.c
// Function: dict
char* dict(int t){
    point *temp = data.front;
    int y,x;
    getyx(stdscr,y,x);
    int i,j,k;
    for(i = 0; i < (stline + y); i++){
        temp = temp->tail;
    }
    char *str = (char *)calloc(100,1);
    char ch;
    i = 0;
    k = t;
    while( !isEmptys(&(temp->element)) && (t > 0) && ((ch = ipoploc(&(temp->element),t-1)) != ' ')){
        str[i++] = ch;
        move(y,--x);
        if(i > 5){
            for(j = 0, k = strlen(str) - 1; j < k; j++, k--){
                ch = str[j];
                str[j] = str[k];
                str[k] = ch;
            }
            return str;
        }
        t--;
    }
    
    if(isEmptys(&(temp->element)))
        move(y,0);
    else{
        k = k - strlen(str) - 1; 
        move(y,k);
        add_char(' ', y+stline, k++);
        move(y,k);
    }
    for(j = 0, k = strlen(str) - 1; j < k; j++, k--){
        ch = str[j];
        str[j] = str[k];
        str[k] = ch;
    }
    
    if(strlen(str) <= 1)
        return str;
    k = 1;
    char *word;
    char **dict = (char **)calloc(4,sizeof(char *));
    i = 0;
    char *filename = (char *)calloc(12,1);

    if (str[0] >= 65 && str[0] <= 90){
        sprintf(filename,"dict/%c.txt",str[0] + 32);
    }
    else{
        sprintf(filename,"dict/%c.txt",str[0]);
    }
    FILE *fp = fopen(filename,"r+");
    if(!fp)
        return str;
    int q;
    while(word = get_word(fp)){ 
        if(strstr(word,"\n"))
            continue;
        for(q = 0; q < strlen(str); q++){
            if (str[q] >= 65 && str[q] <= 90){
                word[q] = word[q] - 32;         
            }
        }
        if(strlen(str) == 2){
            if(strstr(word,str) && word[1] == str[1]){
                dict[i++] = word;
            }
        }
        else if(strlen(str) == 3){
            if(strstr(word,str) && word[1] == str[1] && word[2] == str[2]){
                dict[i++] = word;
            }
        }
        else if(strlen(str) == 4){
            if(strstr(word,str) && word[1] == str[1] && word[2] == str[2] && word[3] == str[3]){
                dict[i++] = word;
            }
        }
        else if(strlen(str) == 5){
            if(strstr(word,str) && word[1] == str[1] && word[2] == str[2] && word[3] == str[3] && word[4] == str[4]){
                dict[i++] = word;
            }
        }
        if(i == 4)
            break;
    }
    int count = i;
    if (count == 0){
        fclose(fp);
        return str;
    }
    WINDOW  *dict_win = create_newwin(count*2, 20,y,x+strlen(str));
    int g,mark = 1,choice = 0;
    printopt(dict_win,dict,mark,count);
    while(1){
        g = wgetch(dict_win);
        switch(g){
            case KEY_UP:
                if(mark == 1)
                    mark = count;  
                else
                    mark--;
                break;
            case KEY_DOWN:
                if(mark == count)
                    mark = 1;  
                else
                    mark++;
                break;
            case 10:
                choice = mark;
                break;
            
            default:
                choice = -1;
                break;
        }
        printopt(dict_win,dict,mark,count);
        if(choice != 0)
            break;
    }
    if(choice == -1){
        destroy_win(dict_win);
        fclose(fp);
        return str;
    }
    else{
        destroy_win(dict_win);
        fclose(fp);
        return dict[mark-1];

    }
    fclose(fp);
    destroy_win(dict_win);
    return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0xc(%rbp)
leaq 0x8b3b(%rip), %rax      # 0xd1e0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
xorl %eax, %eax
movq 0x892b(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x46cc
movq 0x891f(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x80(%rbp)
jmp 0x46d6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x80(%rbp)
jmp 0x46d6
movl -0x80(%rbp), %eax
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
movq 0x88fb(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x4700
movq 0x88ef(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x84(%rbp)
jmp 0x470d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x84(%rbp)
jmp 0x470d
movl -0x84(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0x8a7d(%rip), %rcx      # 0xd1a4
movl (%rcx), %ecx
addl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4746
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x471d
movl $0x64, %edi
movl $0x1, %esi
callq 0x2180
movq %rax, -0x38(%rbp)
movl $0x0, -0x24(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x27c0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x85(%rbp)
jne 0x47b5
xorl %eax, %eax
cmpl $0x0, -0xc(%rbp)
movb %al, -0x85(%rbp)
jle 0x47b5
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
movl -0xc(%rbp), %esi
subl $0x1, %esi
callq 0x26d0
movb %al, -0x39(%rbp)
movsbl %al, %eax
cmpl $0x20, %eax
setne %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
testb $0x1, %al
jne 0x47c4
jmp 0x487d
movb -0x39(%rbp), %dl
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq 0x87fd(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
addl $-0x1, %edx
movl %edx, -0x20(%rbp)
callq 0x2240
cmpl $0x5, -0x24(%rbp)
jle 0x486f
movl $0x0, -0x28(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
subq $0x1, %rax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x4862
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x39(%rbp), %dl
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4814
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4e41
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x4766
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x27c0
cmpl $0x0, %eax
je 0x48a5
movq 0x874a(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x1c(%rbp), %esi
xorl %edx, %edx
callq 0x2240
jmp 0x4918
movslq -0x2c(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
movq %rax, %rcx
movq -0x90(%rbp), %rax
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x2c(%rbp)
movq 0x870c(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x1c(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x2240
movl -0x1c(%rbp), %esi
leaq 0x88b8(%rip), %rax      # 0xd1a4
addl (%rax), %esi
movl -0x2c(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x20, %edi
callq 0x31f0
movq 0x86d6(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl -0x1c(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x2240
movl $0x0, -0x28(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
subq $0x1, %rax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x497d
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x39(%rbp), %dl
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x492f
movq -0x38(%rbp), %rdi
callq 0x20b0
cmpq $0x1, %rax
ja 0x4999
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4e41
movl $0x1, -0x2c(%rbp)
movl $0x4, %edi
movl $0x8, %esi
callq 0x2180
movq %rax, -0x50(%rbp)
movl $0x0, -0x24(%rbp)
movl $0xc, %edi
movl $0x1, %esi
callq 0x2180
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0x4a03
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5a, %eax
jg 0x4a03
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rax
movsbl (%rax), %edx
addl $0x20, %edx
leaq 0x561b(%rip), %rsi      # 0xa015
movb $0x0, %al
callq 0x2290
jmp 0x4a1c
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rax
movsbl (%rax), %edx
leaq 0x5600(%rip), %rsi      # 0xa015
movb $0x0, %al
callq 0x2290
movq -0x58(%rbp), %rdi
leaq 0x55fa(%rip), %rsi      # 0xa021
callq 0x2230
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x4a44
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4e41
jmp 0x4a46
movq -0x60(%rbp), %rdi
callq 0x44b0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x4cc6
movq -0x48(%rbp), %rdi
leaq 0x5a51(%rip), %rsi      # 0xa4b9
callq 0x22e0
cmpq $0x0, %rax
je 0x4a75
jmp 0x4a46
movl $0x0, -0x64(%rbp)
movslq -0x64(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x4aea
movq -0x38(%rbp), %rax
movslq -0x64(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x4add
movq -0x38(%rbp), %rax
movslq -0x64(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0x4add
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x20, %eax
movb %al, %dl
movq -0x48(%rbp), %rax
movslq -0x64(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x4adf
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x4a7c
movq -0x38(%rbp), %rdi
callq 0x20b0
cmpq $0x2, %rax
jne 0x4b3f
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x22e0
cmpq $0x0, %rax
je 0x4b3a
movq -0x48(%rbp), %rax
movsbl 0x1(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4b3a
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4cb9
movq -0x38(%rbp), %rdi
callq 0x20b0
cmpq $0x3, %rax
jne 0x4ba8
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x22e0
cmpq $0x0, %rax
je 0x4ba3
movq -0x48(%rbp), %rax
movsbl 0x1(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4ba3
movq -0x48(%rbp), %rax
movsbl 0x2(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4ba3
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4cb7
movq -0x38(%rbp), %rdi
callq 0x20b0
cmpq $0x4, %rax
jne 0x4c25
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x22e0
cmpq $0x0, %rax
je 0x4c20
movq -0x48(%rbp), %rax
movsbl 0x1(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4c20
movq -0x48(%rbp), %rax
movsbl 0x2(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4c20
movq -0x48(%rbp), %rax
movsbl 0x3(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4c20
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4cb5
movq -0x38(%rbp), %rdi
callq 0x20b0
cmpq $0x5, %rax
jne 0x4cb3
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x22e0
cmpq $0x0, %rax
je 0x4cb1
movq -0x48(%rbp), %rax
movsbl 0x1(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4cb1
movq -0x48(%rbp), %rax
movsbl 0x2(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4cb1
movq -0x48(%rbp), %rax
movsbl 0x3(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4cb1
movq -0x48(%rbp), %rax
movsbl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4cb1
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4cb3
jmp 0x4cb5
jmp 0x4cb7
jmp 0x4cb9
cmpl $0x4, -0x24(%rbp)
jne 0x4cc1
jmp 0x4cc6
jmp 0x4a46
movl -0x24(%rbp), %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x68(%rbp)
jne 0x4ce8
movq -0x60(%rbp), %rdi
callq 0x20a0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4e41
movl -0x68(%rbp), %eax
shll %eax
movl %eax, -0xa8(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movslq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
movl -0xa8(%rbp), %edi
movl -0xa4(%rbp), %edx
movq %rax, %rcx
movq -0xa0(%rbp), %rax
addq %rcx, %rax
movl %eax, %ecx
movl $0x14, %esi
callq 0x2b30
movq %rax, -0x70(%rbp)
movl $0x1, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x78(%rbp), %edx
movl -0x68(%rbp), %ecx
callq 0x4570
movq -0x70(%rbp), %rdi
callq 0x2080
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0xac(%rbp)
subl $0xa, %eax
je 0x4dc9
jmp 0x4d76
movl -0xac(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x4dad
jmp 0x4d85
movl -0xac(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
jne 0x4dd1
jmp 0x4d94
cmpl $0x1, -0x78(%rbp)
jne 0x4da2
movl -0x68(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x4dab
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x4dd8
movl -0x78(%rbp), %eax
cmpl -0x68(%rbp), %eax
jne 0x4dbe
movl $0x1, -0x78(%rbp)
jmp 0x4dc7
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x4dd8
movl -0x78(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x4dd8
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x78(%rbp), %edx
movl -0x68(%rbp), %ecx
callq 0x4570
cmpl $0x0, -0x7c(%rbp)
je 0x4df3
jmp 0x4df8
jmp 0x4d5a
cmpl $-0x1, -0x7c(%rbp)
jne 0x4e1a
movq -0x70(%rbp), %rdi
callq 0x2bb0
movq -0x60(%rbp), %rdi
callq 0x20a0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4e41
movq -0x70(%rbp), %rdi
callq 0x2bb0
movq -0x60(%rbp), %rdi
callq 0x20a0
movq -0x50(%rbp), %rax
movl -0x78(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nop