// File: dmarto[P]crrs-xlib/main.cpp
// Function: Reflection(std::vector<Sphere*, std::allocator<Sphere*>> const&, Vec3 const&, Vec3 const&, Vec3&)
void Reflection(const std::vector<Sphere *> &objects, const Vec3 &pointOfIntersection, const Vec3 &normal, Vec3 &pixclr)
{
	Colors color;
	double reflectionIntensity = 2.5;

	for (auto &sphereB : objects)
	{
		const Ray ray2(pointOfIntersection, normal * 40);
		double t2;
		if (sphereB->Intersects(ray2, t2))
		{
			const Vec3 pointOfIntersection2 = ray2.origin + ray2.destination * t2;
			const Vec3 len2 = pointOfIntersection - pointOfIntersection2;
			const Vec3 normal2 = sphereB->GetNormal(pointOfIntersection2);
			const double dotP2 = dot(len2.Normalize(), normal2.Normalize());

			Vec3 pixclrBounce = sphereB->clr * dotP2 * reflectionIntensity;
			if (sphereB->name == "world")
				pixclrBounce = pixclrBounce - color.white / 1.5;

			ColorBoundary(pixclrBounce);
			pixclr = pixclrBounce + pixclr;
		}
	}
}

// Assembly:
subq $0x248, %rsp            # imm = 0x248
movq %rdi, 0x240(%rsp)
movq %rsi, 0x238(%rsp)
movq %rdx, 0x230(%rsp)
movq %rcx, 0x228(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x3bd0
movsd 0x3aa4(%rip), %xmm0     # 0x6010
movsd %xmm0, 0x190(%rsp)
movq 0x240(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rdi
callq 0x3ca0
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rdi
callq 0x3cd0
movq %rax, 0x178(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x3d00
testb $0x1, %al
jne 0x25cd
jmp 0x281c
leaq 0x180(%rsp), %rdi
callq 0x3d40
movq %rax, 0x170(%rsp)
movq 0x238(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x230(%rsp), %rsi
leaq 0x128(%rsp), %rdi
movsd 0x3a11(%rip), %xmm0     # 0x6018
callq 0x3d50
movq 0x8(%rsp), %rsi
leaq 0x140(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x3da0
movq 0x170(%rsp), %rax
movq (%rax), %rdi
leaq 0x140(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x3df0
testb $0x1, %al
jne 0x264f
jmp 0x2808
leaq 0x140(%rsp), %rax
movq %rax, (%rsp)
leaq 0x140(%rsp), %rsi
addq $0x18, %rsi
movsd 0x120(%rsp), %xmm0
leaq 0xf0(%rsp), %rdi
callq 0x3d50
movq (%rsp), %rsi
leaq 0x108(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x3fc0
movq 0x238(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x4020
movq 0x170(%rsp), %rax
movq (%rax), %rsi
leaq 0xc0(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x4080
leaq 0xa0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x4130
leaq 0x88(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x4130
leaq 0xa0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x40e0
movsd %xmm0, 0xb8(%rsp)
movq 0x170(%rsp), %rax
movq (%rax), %rsi
addq $0x20, %rsi
movsd 0xb8(%rsp), %xmm0
leaq 0x58(%rsp), %rdi
callq 0x3d50
movsd 0x190(%rsp), %xmm0
leaq 0x70(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3d50
movq 0x170(%rsp), %rax
movq (%rax), %rdi
addq $0x38, %rdi
leaq 0x39bd(%rip), %rsi      # 0x6128
callq 0x41b0
testb $0x1, %al
jne 0x2776
jmp 0x27c5
leaq 0x198(%rsp), %rsi
leaq 0x28(%rsp), %rdi
movsd 0x3895(%rip), %xmm0     # 0x6020
callq 0x41e0
leaq 0x40(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x4020
movq 0x40(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x23e0
movq 0x228(%rsp), %rdx
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3fc0
movq 0x228(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x280a
leaq 0x180(%rsp), %rdi
callq 0x4230
jmp 0x25af
addq $0x248, %rsp            # imm = 0x248
retq
nopw %cs:(%rax,%rax)