// File: yupyub[P]PathFinding_Visual/DFS.cpp
// Function: DFS::DFS_H(int, int, int)
int DFS::DFS_H(int x,int y,int dir){ // DFS + Heuristic
    vv.state[x][y] = 3;
    vv.draw();
    itr++;
    printf("Total Iteration : %d\n",itr);
    printf("DFS Stack Count : %d\n",scnt);
    usleep(timeSet);
    vv.state[x][y] = 2;
    if(x == ex && y == ey) return 1;
    int si = 0;
    if(dir%2){
        if(ey>=y) si = 0;
        else si = 2;
    }
    else{
        if(ex>=x) si = 1;
        else si =3;
    }
    for(int i = 0;i<4;i++){
        int ni = (si+i)%4;
        int nx = x+dx[ni];
        int ny = y+dy[ni];
        if(nx<0||ny<0||nx>=vv.N||ny>=vv.M) continue;
        if(vv.map[nx][ny] != 1 && dist[nx][ny] > dist[x][y] + 1){
            if(dist[nx][ny] == INF){
                dist[nx][ny] = dist[x][y] + 1;
                scnt++;
                int ret = DFS_H(nx,ny,ni);
                scnt--;
                if(ret == 1)return 1;
            }
            else dist[nx][ny] = dist[x][y] + 1;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movq %rdi, %rax
addq $0x27100, %rax          # imm = 0x27100
movslq -0x14(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movl $0x3, (%rax,%rcx,4)
callq 0x89a0
movq -0x40(%rbp), %rax
movl 0x7531c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x7531c(%rax)
movl 0x7531c(%rax), %esi
leaq 0x45fd(%rip), %rdi      # 0xa221
movb $0x0, %al
callq 0x2030
movq -0x40(%rbp), %rax
movl 0x75318(%rax), %esi
leaq 0x45fb(%rip), %rdi      # 0xa237
movb $0x0, %al
callq 0x2030
movq -0x40(%rbp), %rax
movl 0x75320(%rax), %edi
callq 0x2260
movq -0x40(%rbp), %rcx
movq %rcx, %rax
addq $0x27100, %rax          # imm = 0x27100
movslq -0x14(%rbp), %rdx
imulq $0x320, %rdx, %rdx      # imm = 0x320
addq %rdx, %rax
movslq -0x18(%rbp), %rdx
movl $0x2, (%rax,%rdx,4)
movl -0x14(%rbp), %eax
cmpl 0x75310(%rcx), %eax
jne 0x5c9e
movq -0x40(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x75314(%rcx), %eax
jne 0x5c9e
movl $0x1, -0x4(%rbp)
jmp 0x5ee3
movl $0x0, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x5cd6
movq -0x40(%rbp), %rax
movl 0x75314(%rax), %eax
cmpl -0x18(%rbp), %eax
jl 0x5ccd
movl $0x0, -0x20(%rbp)
jmp 0x5cd4
movl $0x2, -0x20(%rbp)
jmp 0x5cf7
movq -0x40(%rbp), %rax
movl 0x75310(%rax), %eax
cmpl -0x14(%rbp), %eax
jl 0x5cee
movl $0x1, -0x20(%rbp)
jmp 0x5cf5
movl $0x3, -0x20(%rbp)
jmp 0x5cf7
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0x5edc
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
movl $0x4, %esi
cltd
idivl %esi
movl %edx, -0x28(%rbp)
movl -0x14(%rbp), %eax
movslq -0x28(%rbp), %rdx
addl 0x75324(%rcx,%rdx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x18(%rbp), %eax
movslq -0x28(%rbp), %rdx
addl 0x75334(%rcx,%rdx,4), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x5d69
cmpl $0x0, -0x30(%rbp)
jl 0x5d69
movq -0x40(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x4e200(%rcx), %eax
jge 0x5d69
movq -0x40(%rbp), %rcx
movl -0x30(%rbp), %eax
cmpl 0x4e204(%rcx), %eax
jl 0x5d6e
jmp 0x5ece
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x5ecc
movq -0x40(%rbp), %rcx
movq %rcx, %rax
addq $0x4e208, %rax          # imm = 0x4E208
movslq -0x2c(%rbp), %rdx
imulq $0x320, %rdx, %rdx      # imm = 0x320
addq %rdx, %rax
movslq -0x30(%rbp), %rdx
movl (%rax,%rdx,4), %eax
addq $0x4e208, %rcx          # imm = 0x4E208
movslq -0x14(%rbp), %rdx
imulq $0x320, %rdx, %rdx      # imm = 0x320
addq %rdx, %rcx
movslq -0x18(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x5ecc
movq -0x40(%rbp), %rax
addq $0x4e208, %rax          # imm = 0x4E208
movslq -0x2c(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
cmpl $0x3ade68b1, (%rax,%rcx,4) # imm = 0x3ADE68B1
jne 0x5e89
movq -0x40(%rbp), %rdi
movq %rdi, %rax
addq $0x4e208, %rax          # imm = 0x4E208
movslq -0x14(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movq %rdi, %rax
addq $0x4e208, %rax          # imm = 0x4E208
movslq -0x2c(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x75318(%rdi), %eax
addl $0x1, %eax
movl %eax, 0x75318(%rdi)
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0x28(%rbp), %ecx
callq 0x5bc0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x34(%rbp)
movl 0x75318(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x75318(%rax)
cmpl $0x1, -0x34(%rbp)
jne 0x5e87
movl $0x1, -0x4(%rbp)
jmp 0x5ee3
jmp 0x5eca
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x4e208, %rcx          # imm = 0x4E208
movslq -0x14(%rbp), %rdx
imulq $0x320, %rdx, %rdx      # imm = 0x320
addq %rdx, %rcx
movslq -0x18(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
addl $0x1, %edx
addq $0x4e208, %rax          # imm = 0x4E208
movslq -0x2c(%rbp), %rcx
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x5ecc
jmp 0x5ece
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5cfe
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)