// File: /workspace/github_c_makefile_star2_O0/vasusharma7[P]Text-Editor/undo.c
// Function: undo_replace
void undo_replace(event e){

    int rpt, j, k,i,y,x,t,r;
        point *temp = data.front;
        node *trace = temp->element.store;
        char *rplmt = e.p3;
        char *querry = e.p4;
        for(i = 0; i <= lines; i++){
            rpt = 0;
            j = 0;
            k = 0;
            trace = temp->element.store;
            char *str = (char *)calloc(2,1);
            while(rpt == 1 || (trace->next != NULL)){
                getyx(stdscr,y,x);
                if(trace->next->next == NULL)
                    rpt = 1;
                if(rpt == 1 || trace->val == ' ' || trace->val == '\n' ){
                    
                    k = 0;
                    getyx(stdscr,y,x);
                    if(!strcmp(str,querry)){
                        if(i >= (by - 5))
                                stline = i - (by - 5) + 1;
                            else
                                stline = 0;
                        
                            t = j;
                            r = strlen(querry);
                            while(r--){
                                if(!isEmptys(&(temp->element)) && t > 0){
                                    ipoploc(&(temp->element),t - 1);
                                    t--;
                                    j--;
                                }
                            }
                            for(r = 0; r < strlen(rplmt); r++) {
                                getyx(stdscr,y,x);
                                int mk = add_char(rplmt[r],i,t);
                                if( (t >= (bx - 3)) || (getwidth(i) >= (bx-3)) && ( mk != 0)){
                                    t = mk;
                                    j = mk;
                                }
                                else{
                                    t++;
                                    j++;
                                }
                            }
                        
                    }
                    trace = trace->next;
                    j++;
                    free(str);
                    str = (char *)calloc(1,2);
                    continue;            
            }
            str[k++] = trace->val;
            str = realloc(str,j+2);
            j++;
            trace = trace->next;
        }
        temp = temp->tail;
    }
    display(stline);
    refresh();
    x = y;
    y = x;
    return;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0x10(%rbp), %rax
leaq 0x645d(%rip), %rcx      # 0xd1e0
movq (%rcx), %rcx
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x30(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
leaq 0x63d9(%rip), %rcx      # 0xd190
cmpl (%rcx), %eax
jg 0x7175
movl $0x0, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x2, %edi
movl $0x1, %esi
callq 0x2180
movq %rax, -0x48(%rbp)
movb $0x1, %al
cmpl $0x1, -0x4(%rbp)
movb %al, -0x4d(%rbp)
je 0x6e0d
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
setne %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x6e19
jmp 0x715c
xorl %eax, %eax
movq 0x61be(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x6e39
movq 0x61b2(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x6e43
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x54(%rbp)
jmp 0x6e43
movl -0x54(%rbp), %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
movq 0x618e(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x6e6a
movq 0x6182(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x6e74
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x58(%rbp)
jmp 0x6e74
movl -0x58(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x6e90
movl $0x1, -0x4(%rbp)
cmpl $0x1, -0x4(%rbp)
je 0x6eb4
movq -0x30(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x20, %eax
je 0x6eb4
movq -0x30(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0xa, %eax
jne 0x7110
movl $0x0, -0xc(%rbp)
xorl %eax, %eax
movq 0x611c(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x6edb
movq 0x6110(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0x6ee5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x5c(%rbp)
jmp 0x6ee5
movl -0x5c(%rbp), %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
movq 0x60ec(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x6f0c
movq 0x60e0(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0x6f16
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x60(%rbp)
jmp 0x6f16
movl -0x60(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2190
cmpl $0x0, %eax
jne 0x70da
movl -0x10(%rbp), %eax
leaq 0x6258(%rip), %rcx      # 0xd194
movl (%rcx), %ecx
subl $0x5, %ecx
cmpl %ecx, %eax
jl 0x6f64
movl -0x10(%rbp), %ecx
leaq 0x6245(%rip), %rax      # 0xd194
movl (%rax), %eax
subl $0x5, %eax
subl %eax, %ecx
addl $0x1, %ecx
leaq 0x6244(%rip), %rax      # 0xd1a4
movl %ecx, (%rax)
jmp 0x6f71
leaq 0x6239(%rip), %rax      # 0xd1a4
movl $0x0, (%rax)
movl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x20b0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x20(%rbp)
cmpl $0x0, %eax
je 0x6fd2
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
callq 0x27c0
cmpl $0x0, %eax
jne 0x6fd0
cmpl $0x0, -0x1c(%rbp)
jle 0x6fd0
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movl -0x1c(%rbp), %esi
subl $0x1, %esi
callq 0x26d0
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x6f83
movl $0x0, -0x20(%rbp)
movslq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20b0
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jae 0x70d8
xorl %eax, %eax
movq 0x5fdd(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x701a
movq 0x5fd1(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl (%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x7024
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x6c(%rbp)
jmp 0x7024
movl -0x6c(%rbp), %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
movq 0x5fad(%rip), %rcx      # 0xcfe0
cmpq (%rcx), %rax
je 0x704b
movq 0x5fa1(%rip), %rax      # 0xcfe0
movq (%rax), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x70(%rbp)
jmp 0x7055
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x70(%rbp)
jmp 0x7055
movl -0x70(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb (%rax,%rcx), %al
movl -0x10(%rbp), %esi
movl -0x1c(%rbp), %edx
movsbl %al, %edi
callq 0x31f0
movl %eax, -0x4c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x611b(%rip), %rcx      # 0xd19c
movl (%rcx), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jge 0x70a8
movl -0x10(%rbp), %edi
callq 0x3ad0
leaq 0x6103(%rip), %rcx      # 0xd19c
movl (%rcx), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jl 0x70b6
cmpl $0x0, -0x4c(%rbp)
je 0x70b6
movl -0x4c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x8(%rbp)
jmp 0x70c8
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x70ca
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6fd9
jmp 0x70da
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x48(%rbp), %rdi
callq 0x2030
movl $0x1, %edi
movl $0x2, %esi
callq 0x2180
movq %rax, -0x48(%rbp)
jmp 0x6df3
movq -0x30(%rbp), %rax
movb 0x8(%rax), %dl
movq -0x48(%rbp), %rax
movl -0xc(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xc(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x48(%rbp), %rdi
movl -0x8(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x2210
movq %rax, -0x48(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x6df3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x6dad
leaq 0x6028(%rip), %rax      # 0xd1a4
movl (%rax), %edi
callq 0x2cb0
movq 0x5e56(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x20f0
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x14(%rbp)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)