// File: /workspace/github_cpp_makefile_star2_O2/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)
leaq 0x70(%rsp), %r13
andl $0x0, (%r13)
andq $0x0, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
andq $0x0, 0x20(%r13)
movapd %xmm0, 0x40(%rsp)
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x11775
movq %rax, 0x8(%r15)
movq %r12, %rdi
callq 0x858f
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x8488
movq %rax, 0x28(%rsp)
movq %r12, %rdi
callq 0x8488
movq %rax, 0x30(%rsp)
movq %rax, %rdi
callq 0x850c
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x850c
movq %rax, 0x40(%rsp)
movq %rax, %rdi
callq 0x8610
movq %rax, 0x48(%rsp)
movq %r12, %rdi
callq 0x8610
movq %rax, 0x50(%rsp)
movq %rax, %rdi
callq 0x858f
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 0x116cc
xorl %ebp, %ebp
leaq 0x68(%rsp), %r12
cmpq $0x8, %rbp
je 0x11829
movq 0x20(%rsp,%rbp,8), %rdi
movq %r12, %rsi
callq 0x116cc
incq %rbp
jmp 0x11811
movq 0x80(%rsp), %r12
cmpq %r13, %r12
je 0x1189c
movq 0x20(%r12), %rax
cmpw $0x0, 0x1b0(%rax)
jne 0x1188f
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 0x99a8(%rip), %xmm0     # 0x1b220
addsd %xmm0, %xmm1
ucomisd %xmm0, %xmm1
jb 0x1188f
leaq 0x20(%r12), %rsi
movq %r15, %rdi
callq 0xb262
movq %r12, %rdi
callq 0x3220
movq %rax, %r12
jmp 0x11831
movq 0x8(%r15), %rax
cmpq (%r15), %rax
jne 0x11942
movq 0x11710(%rip), %rdi     # 0x22fc0
leaq 0xa047(%rip), %rsi      # 0x1b8fe
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
movsd (%r14), %xmm0
movq 0x116f0(%rip), %rdi     # 0x22fc0
callq 0x32e0
leaq 0xa4a2(%rip), %rsi      # 0x1bd7e
movq %rax, %rdi
callq 0x31d0
movsd 0x8(%r14), %xmm0
movq %rax, %rdi
callq 0x32e0
leaq 0xa01a(%rip), %rsi      # 0x1b913
movq %rax, %rdi
callq 0x31d0
movsd (%rbx), %xmm0
movq %rax, %rdi
callq 0x32e0
leaq 0xa469(%rip), %rsi      # 0x1bd7d
movq %rax, %rdi
callq 0x31d0
movsd 0x8(%rbx), %xmm0
movq %rax, %rdi
callq 0x32e0
movq %rax, %rdi
callq 0x30d0
movq 0x116a8(%rip), %rdi     # 0x22fe0
leaq 0x1c(%rsp), %rsi
callq 0x3110
leaq 0x68(%rsp), %rdi
callq 0x4c62
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11964
jmp 0x11964
jmp 0x11964
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4c62
movq %rbx, %rdi
callq 0x3350