// File: /workspace/github_cpp_makefile_star2_O3/jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: findIntpltCell(bodygridclass*, pointxy const&, pointxy const&, std::vector<bodygridclass*, std::allocator<bodygridclass*>>&)
void findIntpltCell(OctCell * incell, const PXYZ &gstp, const PXYZ &smtricp, vector< OctCell * > &grid) 
{
    PXYZ drct, drct1;  
    OctCell *pp[8]={NULL};
    set<OctCell*> grid_set;

    grid.clear();
    pp[0]=EastNeighbor(incell);
    pp[1]=NorthNeighbor(pp[0]);
    pp[2]=NorthNeighbor(incell);
    pp[3]=WestNeighbor(pp[2]);
    pp[4]=WestNeighbor(incell);
    pp[5]=SouthNeighbor(pp[4]);
    pp[6]=SouthNeighbor(incell);
    pp[7]=EastNeighbor(pp[6]);

    drct.x=smtricp.x-gstp.x;
    drct.y=smtricp.y-gstp.y;
    // cout<<iy<<" "<<ix<<endl;
    //cout<<smtricp.x<<" "<<smtricp.y<<endl;
    insert_cell(incell, grid_set);
    for(int ii=0;ii<8;++ii) insert_cell(pp[ii], grid_set);

    for(set<OctCell*>::iterator itset=grid_set.begin(); itset!=grid_set.end(); ++itset) {
        if((*itset)->flag==0) {
            drct1.x= (*itset)->xc1-gstp.x;
            drct1.y= (*itset)->yc1-gstp.y;  
            if(drct.x*drct1.x+drct.y*drct1.y+1.0 >= 1.0) {
                grid.push_back(*itset); 
            }          
        }
    }

#ifdef DEBUG
    int itm;
    if(grid.size()==0){
        cout << "wrong findIntpltCell"<< endl;
        cout<<gstp.x<<" "<<gstp.y<<", "<<smtricp.x<<"  "<<smtricp.y<<endl;
        cin>>itm;
    }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
leaq 0x70(%rsp), %r13
movl $0x0, (%r13)
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rax, 0x20(%r13)
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x12d16
movq %rax, 0x8(%r15)
movq %r12, %rdi
callq 0x8d37
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x8c30
movq %rax, 0x28(%rsp)
movq %r12, %rdi
callq 0x8c30
movq %rax, 0x30(%rsp)
movq %rax, %rdi
callq 0x8cb4
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x8cb4
movq %rax, 0x40(%rsp)
movq %rax, %rdi
callq 0x8db8
movq %rax, 0x48(%rsp)
movq %r12, %rdi
callq 0x8db8
movq %rax, 0x50(%rsp)
movq %rax, %rdi
callq 0x8d37
movq %rax, 0x58(%rsp)
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
subsd (%r14), %xmm0
movsd %xmm0, 0x10(%rsp)
subsd 0x8(%r14), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0x12c6a
xorl %ebp, %ebp
leaq 0x68(%rsp), %r12
movq 0x20(%rsp,%rbp,8), %rdi
movq %r12, %rsi
callq 0x12c6a
incq %rbp
cmpq $0x8, %rbp
jne 0x12db2
movq 0x80(%rsp), %r12
cmpq %r13, %r12
je 0x12e52
movq 0x20(%r12), %rax
cmpw $0x0, 0x1b0(%rax)
jne 0x12e42
movsd 0x278(%rax), %xmm0
movsd 0x280(%rax), %xmm1
subsd (%r14), %xmm0
mulsd 0x10(%rsp), %xmm0
subsd 0x8(%r14), %xmm1
mulsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0xa389(%rip), %xmm0     # 0x1d1a0
addsd %xmm0, %xmm1
ucomisd %xmm0, %xmm1
jb 0x12e42
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x12e35
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x12e42
leaq 0x20(%r12), %rdx
movq %r15, %rdi
callq 0xc142
movq %r12, %rdi
callq 0x3260
movq %rax, %r12
cmpq %r13, %rax
jne 0x12dd5
movq 0x8(%r15), %rax
cmpq (%r15), %rax
jne 0x12f5d
movq 0x11162(%rip), %r15     # 0x23fc8
leaq 0xaa61(%rip), %rsi      # 0x1d8ce
movl $0x14, %edx
movq %r15, %rdi
callq 0x3250
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
movq 0x11130(%rip), %rdi     # 0x23fc8
callq 0x3040
movq %rax, %rdi
callq 0x3170
movsd (%r14), %xmm0
movq 0x11117(%rip), %rdi     # 0x23fc8
callq 0x3300
movq %rax, %r15
leaq 0xaf3e(%rip), %rsi      # 0x1ddfe
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movsd 0x8(%r14), %xmm0
movq %r15, %rdi
callq 0x3300
movq %rax, %r14
leaq 0xa9fe(%rip), %rsi      # 0x1d8e3
movl $0x2, %edx
movq %rax, %rdi
callq 0x3250
movsd (%rbx), %xmm0
movq %r14, %rdi
callq 0x3300
movq %rax, %r14
leaq 0xaef5(%rip), %rsi      # 0x1ddfd
movl $0x2, %edx
movq %rax, %rdi
callq 0x3250
movsd 0x8(%rbx), %xmm0
movq %r14, %rdi
callq 0x3300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3170
movq 0x1108d(%rip), %rdi     # 0x23fe0
leaq 0x1c(%rsp), %rsi
callq 0x3130
leaq 0x68(%rsp), %rdi
callq 0x4e40
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12f7f
jmp 0x12f7f
jmp 0x12f7f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4e40
movq %rbx, %rdi
callq 0x3370