// File: /workspace/github_cpp_makefile_star2_O1/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)
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x20(%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 0x13323
movq %rax, 0x8(%r15)
movq %r12, %rdi
callq 0x8e7f
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x8d78
movq %rax, 0x28(%rsp)
movq %r12, %rdi
callq 0x8d78
movq %rax, 0x30(%rsp)
movq %rax, %rdi
callq 0x8dfc
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x8dfc
movq %rax, 0x40(%rsp)
movq %rax, %rdi
callq 0x8f00
movq %rax, 0x48(%rsp)
movq %r12, %rdi
callq 0x8f00
movq %rax, 0x50(%rsp)
movq %rax, %rdi
callq 0x8e7f
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 0x13274
xorl %ebp, %ebp
leaq 0x68(%rsp), %r12
movq 0x20(%rsp,%rbp,8), %rdi
movq %r12, %rsi
callq 0x13274
incq %rbp
cmpq $0x8, %rbp
jne 0x133bf
movq 0x80(%rsp), %r12
cmpq %r13, %r12
je 0x1345f
movq 0x20(%r12), %rax
cmpw $0x0, 0x1b0(%rax)
jne 0x1344f
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 0xad7c(%rip), %xmm0     # 0x1e1a0
addsd %xmm0, %xmm1
ucomisd %xmm0, %xmm1
jb 0x1344f
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x13442
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1344f
leaq 0x20(%r12), %rdx
movq %r15, %rdi
callq 0xc2bc
movq %r12, %rdi
callq 0x3260
movq %rax, %r12
cmpq %r13, %rax
jne 0x133e2
movq 0x8(%r15), %rax
cmpq (%r15), %rax
jne 0x1356a
movq 0x11b55(%rip), %r15     # 0x24fc8
leaq 0xb474(%rip), %rsi      # 0x1e8ee
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 0x11b23(%rip), %rdi     # 0x24fc8
callq 0x3040
movq %rax, %rdi
callq 0x3170
movsd (%r14), %xmm0
movq 0x11b0a(%rip), %rdi     # 0x24fc8
callq 0x3300
movq %rax, %r15
leaq 0xb929(%rip), %rsi      # 0x1edf6
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movsd 0x8(%r14), %xmm0
movq %r15, %rdi
callq 0x3300
movq %rax, %r14
leaq 0xb411(%rip), %rsi      # 0x1e903
movl $0x2, %edx
movq %rax, %rdi
callq 0x3250
movsd (%rbx), %xmm0
movq %r14, %rdi
callq 0x3300
movq %rax, %r14
leaq 0xb8e0(%rip), %rsi      # 0x1edf5
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 0x11a80(%rip), %rdi     # 0x24fe0
leaq 0x1c(%rsp), %rsi
callq 0x3130
leaq 0x68(%rsp), %rdi
callq 0x4f00
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1358c
jmp 0x1358c
jmp 0x1358c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4f00
movq %rbx, %rdi
callq 0x3370