// File: hamikm[P]Raytracer/src/arealight.hh
// Function: arealight<double, double, double, 3>::constructorHelper(mvector<double, 3> const&)
void constructorHelper(const mvector<vec_T, dim> &upDirection) {
		// Compute uhat by taking the cross product of the surface normal
		// and the up vector then normalizing.
		uhat = upDirection % norm;
		uhat = uhat.norm();

		// Compute vhat by taking the cross product of the surface normal
		// and uhat then normalizing.
		vhat = norm % uhat;
		vhat = vhat.norm();

		// Compute number of lights.
		int numlights = static_cast<int> (width / horizontalSpacing) *
				static_cast<int> (height / verticalSpacing);

		// Loop over the rows of the lights.
		for(vec_T u = -height / 2; u <= height / 2; u += verticalSpacing) {

			for(vec_T v = -width / 2; v <= width / 2; v += horizontalSpacing) {

				// Compute world coordinates from the local uv coordinates.
				mvector<vec_T, dim> worldpos = uhat * u + vhat * v +
						this->getPos();

				// Construct a point light at the world coordinates with a color
				// scaled so that the combination of all the lights in the area
				// light look like the color passed to the constructor.
				boost::shared_ptr<light<vec_T, color_T, time_T, dim> >
					currLight_sp(
							new light<vec_T, color_T, time_T, dim>(
									this->getColor() / numlights, worldpos));
				lights.push_back(currLight_sp);
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdx
movq %rdx, -0x128(%rbp)
movq -0x10(%rbp), %rsi
addq $0x38, %rdx
leaq -0x28(%rbp), %rdi
callq 0x9cf0
movq -0x128(%rbp), %rsi
movq -0x28(%rbp), %rax
movq %rax, 0x88(%rsi)
movq -0x20(%rbp), %rax
movq %rax, 0x90(%rsi)
movq -0x18(%rbp), %rax
movq %rax, 0x98(%rsi)
addq $0x88, %rsi
leaq -0x40(%rbp), %rdi
callq 0x5420
movq -0x128(%rbp), %rdx
movq -0x40(%rbp), %rax
movq %rax, 0x88(%rdx)
movq -0x38(%rbp), %rax
movq %rax, 0x90(%rdx)
movq -0x30(%rbp), %rax
movq %rax, 0x98(%rdx)
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x88, %rdx
leaq -0x58(%rbp), %rdi
callq 0x9cf0
movq -0x128(%rbp), %rsi
movq -0x58(%rbp), %rax
movq %rax, 0x70(%rsi)
movq -0x50(%rbp), %rax
movq %rax, 0x78(%rsi)
movq -0x48(%rbp), %rax
movq %rax, 0x80(%rsi)
addq $0x70, %rsi
leaq -0x70(%rbp), %rdi
callq 0x5420
movq -0x128(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, 0x70(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x78(%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x80(%rax)
movsd 0x60(%rax), %xmm0
divsd 0x50(%rax), %xmm0
cvttsd2si %xmm0, %ecx
movsd 0x68(%rax), %xmm0
divsd 0x58(%rax), %xmm0
cvttsd2si %xmm0, %edx
imull %edx, %ecx
movl %ecx, -0x74(%rbp)
movsd 0x68(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x6893(%rip), %xmm1     # 0x10020
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x128(%rbp), %rax
movsd -0x80(%rbp), %xmm1
movsd 0x68(%rax), %xmm0
movsd 0x6871(%rip), %xmm2     # 0x10020
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x99c1
movq -0x128(%rbp), %rax
movsd 0x60(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x6838(%rip), %xmm1     # 0x10020
divsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x128(%rbp), %rax
movsd -0x88(%rbp), %xmm1
movsd 0x60(%rax), %xmm0
movsd 0x6810(%rip), %xmm2     # 0x10020
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x99a4
movq -0x128(%rbp), %rsi
addq $0x88, %rsi
movsd -0x80(%rbp), %xmm0
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x8990
movq -0x128(%rbp), %rsi
addq $0x70, %rsi
movsd -0x88(%rbp), %xmm0
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x8990
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x8910
movq -0x128(%rbp), %rdi
callq 0x9f20
movq -0x138(%rbp), %rsi
movq %rax, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x8910
movl $0x38, %edi
callq 0x3250
movq -0x128(%rbp), %rdi
movq %rax, -0x130(%rbp)
callq 0x8830
movq %rax, %rsi
cvtsi2sdl -0x74(%rbp), %xmm0
leaq -0x110(%rbp), %rdi
callq 0x9f40
jmp 0x98e0
movq -0x130(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x5200
jmp 0x98fc
movq -0x130(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x5290
movq -0x128(%rbp), %rdi
movq -0x150(%rbp), %rsi
addq $0xa0, %rdi
callq 0x9ff0
jmp 0x9932
leaq -0xf8(%rbp), %rdi
callq 0x5300
movq -0x128(%rbp), %rax
movsd 0x50(%rax), %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
jmp 0x97f4
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x118(%rbp)
movl %eax, -0x11c(%rbp)
movl $0x38, %esi
callq 0x3260
jmp 0x99ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x118(%rbp)
movl %eax, -0x11c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5300
jmp 0x99ca
jmp 0x99a6
movq -0x128(%rbp), %rax
movsd 0x58(%rax), %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x9796
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x118(%rbp), %rdi
callq 0x3380
nopw %cs:(%rax,%rax)