// File: nandakishoremmn2[P]multigrid/multigrid.cpp
// Function: MultiGrid::restrict()
void MultiGrid::restrict()
{
	// Restrict values from temp to *grid2.temp
	real **temp2 = grid2->temp;
	int n2 = grid2->getSize();

	for (int i = 1; i < n2-1; ++i)
	{
		for (int j = 1; j < n2-1; ++j)
		{
			// Weighted average from all 9 points
			temp2[i][j] = 4.0*temp[2*i][2*j];
			temp2[i][j] += 2.0*( temp[2*i+1][2*j] + temp[2*i-1][2*j] + temp[2*i][2*j-1] + temp[2*i][2*j+1] );
			temp2[i][j] += 1.0*( temp[2*i+1][2*j+1] + temp[2*i-1][2*j-1] + temp[2*i+1][2*j-1] + temp[2*i-1][2*j+1] );
			temp2[i][j] /= 16.0;
		}
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x10(%rbp)
movq (%rax), %rdi
callq 0x2230
movl %eax, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2718
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2708
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
movslq %edx, %rdx
movsd 0x2b9a(%rip), %xmm0     # 0x5108
mulsd (%rcx,%rdx,8), %xmm0
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x1c(%rbp), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
movslq %edx, %rdx
addsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
subl $0x1, %edx
movslq %edx, %rdx
addsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
addsd (%rcx,%rdx,8), %xmm0
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x1c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
subl $0x1, %edx
movslq %edx, %rdx
addsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movl -0x18(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x1c(%rbp), %edx
shll %edx
subl $0x1, %edx
movslq %edx, %rdx
addsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
shll %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
addsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x2a1f(%rip), %xmm1     # 0x5110
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2539
jmp 0x270a
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2521
addq $0x30, %rsp
popq %rbp
retq
nop