// File: jamesliu516[P]amrdg2d/rk.cpp
// Function: fn_RKTVD(bodygridclass*, int, int)
void fn_RKTVD(OctCell *unp, int nstp, int rkstp)
{
    int im,jm;
#ifdef LOCAL_TIME 
    double dt=unp->dt1;
#endif
    if(nstp<NpreTimeStp){
        dt=small_dt;
    }

    switch(rkstp){
    case 0:
        for(im=0; im<4; im++) {
            for(jm=0; jm<nDOF; jm++) {
                unp->dof[im][jm]=unp->dof0[im][jm]
                    - dt*unp->invM[jm] * unp->residual[im][jm];
            }
        }
        break;
    case 1:
        for(im=0; im<4; im++) {
            for(jm=0; jm<nDOF; jm++) {
                unp->dof[im][jm]=0.75*unp->dof0[im][jm]
                    + 0.25*(unp->dof[im][jm]- dt*unp->invM[jm]
                        * unp->residual[im][jm]);
            }
        }
        break;
    case 2:
        for(im=0; im<4; im++) {
            for(jm=0; jm<nDOF; jm++) {
                unp->dof[im][jm]=1.0/3.0*unp->dof0[im][jm] 
                    + 2.0/3.0*(unp->dof[im][jm]
                        - dt*unp->invM[jm] * unp->residual[im][jm]);
            }
        }
        break;
    }
    unp->bAvg=true;
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl %edx, -0x10(%rsp)
cmpl $-0x19, -0xc(%rsp)
jge 0x2e7d7
leaq 0x21fd5(%rip), %rax     # 0x507a0
movsd 0x110f5(%rip), %xmm0    # 0x3f8c8
movsd %xmm0, (%rax)
movl -0x10(%rsp), %eax
movl %eax, -0x1c(%rsp)
testl %eax, %eax
je 0x2e806
jmp 0x2e7e5
movl -0x1c(%rsp), %eax
subl $0x1, %eax
je 0x2e8ed
jmp 0x2e7f4
movl -0x1c(%rsp), %eax
subl $0x2, %eax
je 0x2ea0f
jmp 0x2eb2e
movl $0x0, -0x14(%rsp)
cmpl $0x4, -0x14(%rsp)
jge 0x2e8e8
movl $0x0, -0x18(%rsp)
cmpl $0x6, -0x18(%rsp)
jge 0x2e8d6
movq -0x8(%rsp), %rax
addq $0xf0, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x21f4c(%rip), %rax     # 0x507a0
movsd (%rax), %xmm0
movq -0x8(%rsp), %rax
movslq -0x18(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq -0x8(%rsp), %rax
addq $0x2a0, %rax            # imm = 0x2A0
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x8(%rsp), %rax
addq $0x30, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rsp)
jmp 0x2e821
jmp 0x2e8d8
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x2e80e
jmp 0x2eb2e
movl $0x0, -0x14(%rsp)
cmpl $0x4, -0x14(%rsp)
jge 0x2ea0a
movl $0x0, -0x18(%rsp)
cmpl $0x6, -0x18(%rsp)
jge 0x2e9f8
movq -0x8(%rsp), %rax
addq $0xf0, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rsp), %rax
addq $0x30, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x21e46(%rip), %rax     # 0x507a0
movsd (%rax), %xmm2
movq -0x8(%rsp), %rax
movslq -0x18(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm2
movq -0x8(%rsp), %rax
addq $0x2a0, %rax            # imm = 0x2A0
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm3
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd 0x10deb(%rip), %xmm1    # 0x3f7a0
mulsd %xmm2, %xmm1
movsd 0x10f17(%rip), %xmm2    # 0x3f8d8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x8(%rsp), %rax
addq $0x30, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rsp)
jmp 0x2e908
jmp 0x2e9fa
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x2e8f5
jmp 0x2eb2e
movl $0x0, -0x14(%rsp)
cmpl $0x4, -0x14(%rsp)
jge 0x2eb2c
movl $0x0, -0x18(%rsp)
cmpl $0x6, -0x18(%rsp)
jge 0x2eb1a
movq -0x8(%rsp), %rax
addq $0xf0, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rsp), %rax
addq $0x30, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x21d24(%rip), %rax     # 0x507a0
movsd (%rax), %xmm2
movq -0x8(%rsp), %rax
movslq -0x18(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm2
movq -0x8(%rsp), %rax
addq $0x2a0, %rax            # imm = 0x2A0
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm3
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd 0x10df9(%rip), %xmm1    # 0x3f8d0
mulsd %xmm2, %xmm1
movsd 0x10c55(%rip), %xmm2    # 0x3f738
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x8(%rsp), %rax
addq $0x30, %rax
movslq -0x14(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rsp)
jmp 0x2ea2a
jmp 0x2eb1c
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x2ea17
jmp 0x2eb2e
movq -0x8(%rsp), %rax
movb $0x1, 0x206(%rax)
retq
nopl (%rax,%rax)