// File: jamesliu516[P]amrdg2d/face_flux_all.cpp
// Function: face_flux(Face&)
void face_flux(Face &fc)
{
     double uxl[4][3]={0.0},uxr[4][3]={0.0};
     
     OctCell *lsbl, *lsbl0;
     double xc0[2],xc1[2];
     
     double xii0[3][2]={0.0};
          
     double dx0,dy0,dx1,dy1;
     double dofp[4][6]={0.0};
     double dofn[4][6]={0.0};
     bool pflag2,nflag2; 
     lsbl0=fc.parent;
     lsbl=fc.neighbor;
     xc0[0]=lsbl0->xc1;
     xc0[1]=lsbl0->yc1;
     
     xc1[0]=lsbl->xc1;
     xc1[1]=lsbl->yc1;
     
     dx0=lsbl0->dx;
     dy0=lsbl0->dy;
     dx1=lsbl->dx;
     dy1=lsbl->dy;
      
     for(short j=0; j<3;++j){
        xii0[j][0]=fc.gs_pt[j][0];
        xii0[j][1]=fc.gs_pt[j][1];                 
      }

     if((!lsbl0->mvflg)||(!lsbl->mvflg)){
         for(short i1=0;i1<4;++i1){
             for(short j1=0;j1<6;++j1){
                 dofp[i1][j1]=lsbl0->dof[i1][j1];
                 dofn[i1][j1]=lsbl->dof[i1][j1];
             }
         }
     }
     else{
         pflag2=(lsbl0->flag==2);
         nflag2=(lsbl->flag==2);
         if((pflag2&& !nflag2) || (!pflag2&& nflag2)){
             //.....
             if(b_ARS){
                 if(pflag2) getGhostValueRiemann(lsbl0);
                 if(nflag2) getGhostValueRiemann(lsbl);
             }
             else{
                 if(pflag2) getGhostValueMagazine(lsbl0,mv_qvlvModify);
                 if(nflag2) getGhostValueMagazine(lsbl,mv_qvlvModify);
             }
             for(short i1=0;i1<4;++i1){
                 for(short j1=0;j1<6;++j1){
                     dofp[i1][j1]=lsbl0->dof[i1][j1];
                     dofn[i1][j1]=lsbl->dof[i1][j1];
                 }
             }
         }
         else {
             for(short i1=0;i1<4;++i1){
                 for(short j1=0;j1<6;++j1){
                     dofp[i1][j1]=lsbl0->dof[i1][j1];
                     dofn[i1][j1]=lsbl->dof[i1][j1];
                 }
             }
         }
     }

     /*
        for(short i1=0;i1<4;++i1){
        for(short j1=0;j1<6;++j1){
        dofp[i1][j1]=lsbl0->dof[i1][j1];
        dofn[i1][j1]=lsbl->dof[i1][j1];
        }
        }
        */
     for(short i=0; i< 4; i++)  {
         for(short j=0;j<3;j++) {
	    uxl[i][j]= n_approx_sol(xii0[j], xc0, dx0, dy0, dofp[i], nDOF );
	    uxr[i][j]= n_approx_sol(xii0[j], xc1, dx1, dy1, dofn[i], nDOF );
	    }
     }     
     
     SHBL ushl[3], ushr[3];
   //  JBBL ujbl[3], ujbr[3];     
     
     for(short j=0; j<3;j++) {
          ushl[j].q=uxl[0][j];
          ushl[j].qu=uxl[1][j];
          ushl[j].qv=uxl[2][j];         
          ushl[j].te=uxl[3][j];
          
          ushr[j].q=uxr[0][j];
          ushr[j].qu=uxr[1][j];
          ushr[j].qv=uxr[2][j];         
          ushr[j].te=uxr[3][j];
      }     
     
     PXYZ normal;
     
     normal.x=fc.nml[0];
     normal.y=fc.nml[1];
     
     double flx[3][4]={0.0};
     for(short j=0; j<3;++j) {
      //    shblToJbbl(&ushl[j], &ujbl[j]);
      //    shblToJbbl(&ushr[j], &ujbr[j]); 
  //        HLLC_flux(ujbl+j, ujbr+j, &normal, flx[j]); 

  //void HLLC_flux(SHBL &wl, SHBL &wr, PXYZ &normal, double flxface[4])  
         if(HLLCFLUX==0)
             GLF_flux(ushl[j], ushr[j], normal, flx[j]); 
         else
             HLLC_flux(ushl[j], ushr[j], normal, flx[j]); 
     }
     
     for(short j=0;j<3; ++j) {
        for(short i=0; i<4; ++i) {
           fc.faceflux[j][i]=flx[j][i];
         }
     }
/*
#ifdef KXRCF_LIM
     double u1,v1,u0,v0;
     double rtmp;
     JBBL uljb[3],urjb[3];
     double prel[3], prer[3];

     for(short j=0; j<3;++j) {
          shblToJbbl(&ushl[j], &uljb[j]);
          shblToJbbl(&ushr[j], &urjb[j]); 
          prel[j]=uljb[j].p;
          prer[j]=urjb[j].p;
     }
     u0=dofp[1][0]/dofp[0][0];
     v0=dofp[2][0]/dofp[0][0];
     u1=dofn[1][0]/dofn[0][0];
     v1=dofn[2][0]/dofn[0][0];
//den
 //    rtmp=(wei[0]*(uxl[0][0]-uxr[0][0])+wei[1]*(uxl[0][1]-uxr[0][1])
   //      +wei[2]*(uxl[0][2]-uxr[0][2]))*fc.area*0.5;
     //    
     //entropy
     rtmp=(wei[0]*(prel[0]/pow(uxl[0][0],GAMMA)-prer[0]/pow(uxr[0][0],GAMMA))
         +wei[1]*(prel[1]/pow(uxl[0][1],GAMMA)-prer[1]/pow(uxr[0][1],GAMMA)) 
         +wei[2]*(prel[2]/pow(uxl[0][2],GAMMA)-prer[2]/pow(uxr[0][2],GAMMA)) )*fc.area*0.5;
     if(u0*normal.x+v0*normal.y<0.0){
         lsbl0->kxq+=rtmp;
         lsbl0->inlen+=fc.area;
     }

     if(u1*normal.x+v1*normal.y>0.0){
         lsbl->kxq-=rtmp;
         lsbl->inlen+=fc.area;
     }

#endif
*/

 }

// Assembly:
subq $0x468, %rsp            # imm = 0x468
movq %rdi, 0x460(%rsp)
leaq 0x400(%rsp), %rdi
xorl %esi, %esi
movl $0x60, %edx
callq 0x3150
leaq 0x3a0(%rsp), %rdi
xorl %esi, %esi
movl $0x60, %edx
callq 0x3150
leaq 0x340(%rsp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x3150
leaq 0x260(%rsp), %rdi
xorl %esi, %esi
movl $0xc0, %edx
callq 0x3150
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
movl $0xc0, %edx
callq 0x3150
movq 0x460(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x390(%rsp)
movq 0x460(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x398(%rsp)
movq 0x390(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x380(%rsp)
movq 0x390(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x388(%rsp)
movq 0x398(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x370(%rsp)
movq 0x398(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x378(%rsp)
movq 0x390(%rsp), %rax
movsd 0x288(%rax), %xmm0
movsd %xmm0, 0x338(%rsp)
movq 0x390(%rsp), %rax
movsd 0x290(%rax), %xmm0
movsd %xmm0, 0x330(%rsp)
movq 0x398(%rsp), %rax
movsd 0x288(%rax), %xmm0
movsd %xmm0, 0x328(%rsp)
movq 0x398(%rsp), %rax
movsd 0x290(%rax), %xmm0
movsd %xmm0, 0x320(%rsp)
movw $0x0, 0x19c(%rsp)
movswl 0x19c(%rsp), %eax
cmpl $0x3, %eax
jge 0x1fca0
movq 0x460(%rsp), %rax
addq $0x20, %rax
movswq 0x19c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movswq 0x19c(%rsp), %rcx
leaq 0x340(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x460(%rsp), %rax
addq $0x20, %rax
movswq 0x19c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movswq 0x19c(%rsp), %rcx
leaq 0x340(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movw 0x19c(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x19c(%rsp)
jmp 0x1fbfc
movq 0x390(%rsp), %rax
testb $0x1, 0x1b4(%rax)
je 0x1fcc6
movq 0x398(%rsp), %rax
testb $0x1, 0x1b4(%rax)
jne 0x1fdd5
movw $0x0, 0x19a(%rsp)
movswl 0x19a(%rsp), %eax
cmpl $0x4, %eax
jge 0x1fdd0
movw $0x0, 0x198(%rsp)
movswl 0x198(%rsp), %eax
cmpl $0x6, %eax
jge 0x1fdb5
movq 0x390(%rsp), %rax
addq $0x30, %rax
movswq 0x19a(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x198(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x19a(%rsp), %rcx
leaq 0x260(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x198(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x398(%rsp), %rax
addq $0x30, %rax
movswq 0x19a(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x198(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x19a(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x198(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movw 0x198(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x198(%rsp)
jmp 0x1fceb
jmp 0x1fdb7
movw 0x19a(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x19a(%rsp)
jmp 0x1fcd0
jmp 0x2008c
movq 0x390(%rsp), %rax
movswl 0x1b0(%rax), %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movb %al, 0x19f(%rsp)
movq 0x398(%rsp), %rax
movswl 0x1b0(%rax), %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movb %al, 0x19e(%rsp)
testb $0x1, 0x19f(%rsp)
je 0x1fe25
testb $0x1, 0x19e(%rsp)
je 0x1fe41
testb $0x1, 0x19f(%rsp)
jne 0x1ff7e
testb $0x1, 0x19e(%rsp)
je 0x1ff7e
testb $0x1, 0x19f(%rsp)
je 0x1fe58
movq 0x390(%rsp), %rdi
callq 0x2c2a0
testb $0x1, 0x19e(%rsp)
je 0x1fe6f
movq 0x398(%rsp), %rdi
callq 0x2c2a0
movw $0x0, 0x196(%rsp)
movswl 0x196(%rsp), %eax
cmpl $0x4, %eax
jge 0x1ff79
movw $0x0, 0x194(%rsp)
movswl 0x194(%rsp), %eax
cmpl $0x6, %eax
jge 0x1ff5e
movq 0x390(%rsp), %rax
addq $0x30, %rax
movswq 0x196(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x194(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x196(%rsp), %rcx
leaq 0x260(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x194(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x398(%rsp), %rax
addq $0x30, %rax
movswq 0x196(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x194(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x196(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x194(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movw 0x194(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x194(%rsp)
jmp 0x1fe94
jmp 0x1ff60
movw 0x196(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x196(%rsp)
jmp 0x1fe79
jmp 0x2008a
movw $0x0, 0x192(%rsp)
movswl 0x192(%rsp), %eax
cmpl $0x4, %eax
jge 0x20088
movw $0x0, 0x190(%rsp)
movswl 0x190(%rsp), %eax
cmpl $0x6, %eax
jge 0x2006d
movq 0x390(%rsp), %rax
addq $0x30, %rax
movswq 0x192(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x190(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x192(%rsp), %rcx
leaq 0x260(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x190(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x398(%rsp), %rax
addq $0x30, %rax
movswq 0x192(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x190(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movswq 0x192(%rsp), %rcx
leaq 0x1a0(%rsp), %rax
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswq 0x190(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movw 0x190(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x190(%rsp)
jmp 0x1ffa3
jmp 0x2006f
movw 0x192(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x192(%rsp)
jmp 0x1ff88
jmp 0x2008a
jmp 0x2008c
movw $0x0, 0x18e(%rsp)
movswl 0x18e(%rsp), %eax
cmpl $0x4, %eax
jge 0x201ea
movw $0x0, 0x18c(%rsp)
movswl 0x18c(%rsp), %eax
cmpl $0x3, %eax
jge 0x201cf
movswq 0x18c(%rsp), %rax
leaq 0x340(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
leaq 0x380(%rsp), %rsi
movsd 0x338(%rsp), %xmm0
movsd 0x330(%rsp), %xmm1
movswq 0x18e(%rsp), %rax
leaq 0x260(%rsp), %rdx
imulq $0x30, %rax, %rax
addq %rax, %rdx
movl $0x6, %ecx
callq 0x1f830
movswq 0x18e(%rsp), %rcx
leaq 0x400(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movswq 0x18c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movswq 0x18c(%rsp), %rax
leaq 0x340(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
leaq 0x370(%rsp), %rsi
movsd 0x328(%rsp), %xmm0
movsd 0x320(%rsp), %xmm1
movswq 0x18e(%rsp), %rax
leaq 0x1a0(%rsp), %rdx
imulq $0x30, %rax, %rax
addq %rax, %rdx
movl $0x6, %ecx
callq 0x1f830
movswq 0x18e(%rsp), %rcx
leaq 0x3a0(%rsp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movswq 0x18c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movw 0x18c(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x18c(%rsp)
jmp 0x200b1
jmp 0x201d1
movw 0x18e(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x18e(%rsp)
jmp 0x20096
leaq 0x120(%rsp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x21aa0
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, 0x30(%rsp)
jne 0x20203
leaq 0xc0(%rsp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21aa0
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, 0x18(%rsp)
jne 0x20243
movw $0x0, 0xbe(%rsp)
movswl 0xbe(%rsp), %eax
cmpl $0x3, %eax
jge 0x20414
movswq 0xbe(%rsp), %rax
movsd 0x400(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0x120(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movswq 0xbe(%rsp), %rax
movsd 0x418(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0x120(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movswq 0xbe(%rsp), %rax
movsd 0x430(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0x120(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movswq 0xbe(%rsp), %rax
movsd 0x448(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0x120(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movswq 0xbe(%rsp), %rax
movsd 0x3a0(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0xc0(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movswq 0xbe(%rsp), %rax
movsd 0x3b8(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0xc0(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movswq 0xbe(%rsp), %rax
movsd 0x3d0(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0xc0(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movswq 0xbe(%rsp), %rax
movsd 0x3e8(%rsp,%rax,8), %xmm0
movswq 0xbe(%rsp), %rcx
leaq 0xc0(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movw 0xbe(%rsp), %ax
addw $0x1, %ax
movw %ax, 0xbe(%rsp)
jmp 0x20274
leaq 0xa8(%rsp), %rdi
callq 0x6310
movq 0x460(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x460(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0xb0(%rsp)
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x60, %edx
callq 0x3150
movw $0x0, 0x3e(%rsp)
movswl 0x3e(%rsp), %eax
cmpl $0x3, %eax
jge 0x204c8
movswq 0x3e(%rsp), %rax
leaq 0x120(%rsp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
movswq 0x3e(%rsp), %rax
leaq 0xc0(%rsp), %rsi
shlq $0x5, %rax
addq %rax, %rsi
movswq 0x3e(%rsp), %rax
leaq 0x40(%rsp), %rcx
shlq $0x5, %rax
addq %rax, %rcx
leaq 0xa8(%rsp), %rdx
callq 0x23080
movw 0x3e(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x3e(%rsp)
jmp 0x20465
movw $0x0, 0x3c(%rsp)
movswl 0x3c(%rsp), %eax
cmpl $0x3, %eax
jge 0x2054d
movw $0x0, 0x3a(%rsp)
movswl 0x3a(%rsp), %eax
cmpl $0x4, %eax
jge 0x2053b
movswq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0x3a(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x460(%rsp), %rax
addq $0x50, %rax
movswq 0x3c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0x3a(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movw 0x3a(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x3a(%rsp)
jmp 0x204e0
jmp 0x2053d
movw 0x3c(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x3c(%rsp)
jmp 0x204cf
addq $0x468, %rsp            # imm = 0x468
retq
nopw %cs:(%rax,%rax)