// File: jamesliu516[P]amrdg2d/solveAMR.cpp
// Function: creatsolcoarseparent(bodygridclass*, bodygridclass**)
void creatsolcoarseparent(OctCell *parent,OctCell *pp[4])
{
    for(int i=0;i<4;++i) {
        parent->dof[i][0]=0.25*(pp[0]->dof[i][0]+pp[1]->dof[i][0]
            +pp[2]->dof[i][0]+pp[3]->dof[i][0]);
      
        parent->dof[i][1]=0.125*(pp[0]->dof[i][1]+pp[1]->dof[i][1]
            +pp[2]->dof[i][1]+pp[3]->dof[i][1])
            +0.375*(-pp[0]->dof[i][0]+pp[1]->dof[i][0]
                -pp[3]->dof[i][0]+pp[2]->dof[i][0]);

        parent->dof[i][2]=0.125*(pp[0]->dof[i][2]+pp[1]->dof[i][2]
            +pp[2]->dof[i][2]+pp[3]->dof[i][2])
            +0.375*(-pp[0]->dof[i][0]-pp[1]->dof[i][0]
                +pp[3]->dof[i][0]+pp[2]->dof[i][0]);

        parent->dof[i][3]=0.0625*(pp[0]->dof[i][3]+pp[1]->dof[i][3]
            +pp[2]->dof[i][3]+pp[3]->dof[i][3])
            +0.1875*(-pp[0]->dof[i][2]+pp[1]->dof[i][2]
                -pp[3]->dof[i][2]+pp[2]->dof[i][2])
            +0.1875*(-pp[0]->dof[i][1]-pp[1]->dof[i][1]
                +pp[3]->dof[i][1]+pp[2]->dof[i][1])
            +0.5625*(pp[0]->dof[i][0]-pp[1]->dof[i][0]
                -pp[3]->dof[i][0]+pp[2]->dof[i][0]);

        parent->dof[i][4]=0.0625*(pp[0]->dof[i][4]+pp[1]->dof[i][4]
            +pp[2]->dof[i][4]+pp[3]->dof[i][4])
            +0.46875*(-pp[0]->dof[i][1]+pp[1]->dof[i][1]
                -pp[3]->dof[i][1]+pp[2]->dof[i][1]);

        parent->dof[i][5]=0.0625*(pp[0]->dof[i][5]+pp[1]->dof[i][5]
            +pp[2]->dof[i][5]+pp[3]->dof[i][5])
            +0.46875*(-pp[0]->dof[i][2]-pp[1]->dof[i][2]
                +pp[3]->dof[i][2]+pp[2]->dof[i][2]);
    }
    parent->level0=pp[0]->level0;
    for(int i=0; i<4;++i){
        parent->children[i]=NULL;
      if(pp[i]!=NULL)delete pp[i];//TODO
//        if(pp[i]!=NULL)ColCoa.insert(pp[i]);//TODO
    }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
cmpl $0x4, 0x14(%rsp)
jge 0x3ccb9
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm1
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm1
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm1
movsd 0x3254(%rip), %xmm0     # 0x3f7a0
mulsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm2
movsd 0x3546(%rip), %xmm1     # 0x3fbb8
mulsd %xmm2, %xmm1
movsd 0x3532(%rip), %xmm2     # 0x3fbb0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm2
movsd 0x340f(%rip), %xmm1     # 0x3fbb8
mulsd %xmm2, %xmm1
movsd 0x33fb(%rip), %xmm2     # 0x3fbb0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x18(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x18(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x18(%rax), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd 0x10(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm2
movsd 0x32c4(%rip), %xmm1     # 0x3fba8
mulsd %xmm2, %xmm1
movsd 0x32a0(%rip), %xmm2     # 0x3fb90
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd 0x8(%rax), %xmm1
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm1
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm1
movsd 0x321a(%rip), %xmm2     # 0x3fba8
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movsd 0x318f(%rip), %xmm2     # 0x3fba0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x20(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x20(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x20(%rax), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd 0x8(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm2
movsd 0x3058(%rip), %xmm1     # 0x3fb98
mulsd %xmm2, %xmm1
movsd 0x3044(%rip), %xmm2     # 0x3fb90
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x28(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x28(%rax), %xmm0
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x28(%rax), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
subsd 0x10(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm2
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm2
movsd 0x2f1d(%rip), %xmm1     # 0x3fb98
mulsd %xmm2, %xmm1
movsd 0x2f09(%rip), %xmm2     # 0x3fb90
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
addq $0x30, %rax
movslq 0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x3c4c6
movq 0x18(%rsp), %rax
movq (%rax), %rax
movw 0x1fa(%rax), %cx
movq 0x20(%rsp), %rax
movw %cx, 0x1fa(%rax)
movl $0x0, 0x10(%rsp)
cmpl $0x4, 0x10(%rsp)
jge 0x3cd43
movq 0x20(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq $0x0, 0x258(%rax,%rcx,8)
movq 0x18(%rsp), %rax
movslq 0x10(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x3cd34
movq 0x18(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x3cd32
movq 0x8(%rsp), %rdi
movl $0x360, %esi            # imm = 0x360
callq 0x3260
jmp 0x3cd34
jmp 0x3cd36
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x3ccdc
addq $0x28, %rsp
retq
nopl (%rax,%rax)