// File: iannisdezwart[P]forcefield-visualiser/./motion.hpp
// Function: motion::three_body()
void three_body()
	{
		// The center of the image

		Vector<2> image_centre({ WIDTH / 2, HEIGHT / 2 });

		// Set the planets and their rotation vectors

		// Planet 1

		Mass planet_1(200, 0, 3);
		masses.push_back(planet_1);

		double rotation_1 = 0.003333 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_1({
			{ cos(rotation_1), -sin(rotation_1) },
			{ sin(rotation_1), cos(rotation_1) },
		});

		// Planet 2

		Mass planet_2(-150, 261, 2);
		masses.push_back(planet_2);

		double rotation_2 = 0.006666 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_2({
			{ cos(rotation_2), -sin(rotation_2) },
			{ sin(rotation_2), cos(rotation_2) },
		});

		// Planet 3

		Mass planet_3(-200, 348, 1);
		masses.push_back(planet_3);

		double rotation_3 = 0.01 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_3({
			{ cos(rotation_3), -sin(rotation_3) },
			{ sin(rotation_3), cos(rotation_3) },
		});

		// Render 300 frames

		for (int i = 0; i < 300; i++) {
			string frame_number = to_string(i);

			if (frame_number.length() != 4) {
				frame_number = string(4 - frame_number.length(), '0') + frame_number;
			}

			// Move the planets

			// Planet 1

			planet_1.position = rotation_matrix_1 * planet_1.position;
			masses[0].position = planet_1.position + image_centre;

			// Planet 2

			planet_2.position = rotation_matrix_2 * planet_2.position;
			masses[1].position = planet_2.position + image_centre;

			// Planet 3

			planet_3.position = rotation_matrix_3 * planet_3.position;
			masses[2].position = planet_3.position + image_centre;

			// Render the frame

			render_image("output/" + frame_number + ".png", MULTI_THREADED);

			cout << "Rendered frame " << i << "/" << "300\n";
		}
	}

// Assembly:
subq $0x3f8, %rsp            # imm = 0x3F8
movsd 0xaa39(%rip), %xmm0     # 0xf068
movsd %xmm0, 0x3c8(%rsp)
movsd 0xaa20(%rip), %xmm0     # 0xf060
movsd %xmm0, 0x3d0(%rsp)
leaq 0x3c8(%rsp), %rax
movq %rax, 0x3d8(%rsp)
movq $0x2, 0x3e0(%rsp)
movq 0x3d8(%rsp), %rsi
movq 0x3e0(%rsp), %rdx
leaq 0x3e8(%rsp), %rdi
callq 0x5e40
leaq 0x3b0(%rsp), %rdi
movl $0xc8, %esi
xorl %edx, %edx
movl $0x3, %ecx
callq 0x5d10
leaq 0x10cbe(%rip), %rdi     # 0x15360
leaq 0x3b0(%rsp), %rsi
callq 0x5db0
movsd 0xa9a1(%rip), %xmm0     # 0xf058
movsd %xmm0, 0x3a8(%rsp)
movsd 0x3a8(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x348(%rsp)
movsd 0x3a8(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x350(%rsp)
leaq 0x348(%rsp), %rax
movq %rax, 0x358(%rsp)
movq $0x2, 0x360(%rsp)
movsd 0x3a8(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x338(%rsp)
movsd 0x3a8(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x340(%rsp)
leaq 0x338(%rsp), %rax
movq %rax, 0x368(%rsp)
movq $0x2, 0x370(%rsp)
leaq 0x358(%rsp), %rax
movq %rax, 0x378(%rsp)
movq $0x2, 0x380(%rsp)
movq 0x378(%rsp), %rsi
movq 0x380(%rsp), %rdx
leaq 0x388(%rsp), %rdi
callq 0x6440
leaq 0x320(%rsp), %rdi
movl $0xffffff6a, %esi       # imm = 0xFFFFFF6A
movl $0x105, %edx            # imm = 0x105
movl $0x2, %ecx
callq 0x5d10
leaq 0x10b99(%rip), %rdi     # 0x15360
leaq 0x320(%rsp), %rsi
callq 0x5db0
movsd 0xa874(%rip), %xmm0     # 0xf050
movsd %xmm0, 0x318(%rsp)
movsd 0x318(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x2b8(%rsp)
movsd 0x318(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x2c0(%rsp)
leaq 0x2b8(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movq $0x2, 0x2d0(%rsp)
movsd 0x318(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x2a8(%rsp)
movsd 0x318(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x2b0(%rsp)
leaq 0x2a8(%rsp), %rax
movq %rax, 0x2d8(%rsp)
movq $0x2, 0x2e0(%rsp)
leaq 0x2c8(%rsp), %rax
movq %rax, 0x2e8(%rsp)
movq $0x2, 0x2f0(%rsp)
movq 0x2e8(%rsp), %rsi
movq 0x2f0(%rsp), %rdx
leaq 0x2f8(%rsp), %rdi
callq 0x6440
leaq 0x290(%rsp), %rdi
movl $0xffffff38, %esi       # imm = 0xFFFFFF38
movl $0x15c, %edx            # imm = 0x15C
movl $0x1, %ecx
callq 0x5d10
leaq 0x10a74(%rip), %rdi     # 0x15360
leaq 0x290(%rsp), %rsi
callq 0x5db0
movsd 0xa747(%rip), %xmm0     # 0xf048
movsd %xmm0, 0x288(%rsp)
movsd 0x288(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x228(%rsp)
movsd 0x288(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x230(%rsp)
leaq 0x228(%rsp), %rax
movq %rax, 0x238(%rsp)
movq $0x2, 0x240(%rsp)
movsd 0x288(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x218(%rsp)
movsd 0x288(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x220(%rsp)
leaq 0x218(%rsp), %rax
movq %rax, 0x248(%rsp)
movq $0x2, 0x250(%rsp)
leaq 0x238(%rsp), %rax
movq %rax, 0x258(%rsp)
movq $0x2, 0x260(%rsp)
movq 0x258(%rsp), %rsi
movq 0x260(%rsp), %rdx
leaq 0x268(%rsp), %rdi
callq 0x6440
movl $0x0, 0x214(%rsp)
cmpl $0x12c, 0x214(%rsp) # imm = 0x12C
jge 0x4f2c
movl 0x214(%rsp), %esi
leaq 0x1f0(%rsp), %rdi
callq 0x65f0
leaq 0x1f0(%rsp), %rdi
callq 0x3480
cmpq $0x4, %rax
je 0x4b34
leaq 0x1f0(%rsp), %rdi
callq 0x3480
movq %rax, %rcx
movl $0x4, %eax
subq %rcx, %rax
movq %rax, 0x80(%rsp)
leaq 0x1af(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x35b0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rcx
leaq 0x1b0(%rsp), %rdi
movl $0x30, %edx
callq 0x6780
jmp 0x4a8e
leaq 0x1d0(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
callq 0x6730
jmp 0x4aad
leaq 0x1f0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x33d0
leaq 0x1d0(%rsp), %rdi
callq 0x3200
leaq 0x1b0(%rsp), %rdi
callq 0x3200
leaq 0x1af(%rsp), %rdi
callq 0x3360
jmp 0x4b34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x4b22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x3200
leaq 0x1af(%rsp), %rdi
callq 0x3360
jmp 0x4f1d
movups 0x3b0(%rsp), %xmm0
movaps %xmm0, 0x170(%rsp)
movsd 0x170(%rsp), %xmm0
movsd 0x178(%rsp), %xmm1
leaq 0x388(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x70(%rsp)
movsd %xmm0, 0x78(%rsp)
jmp 0x4b71
movsd 0x70(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x188(%rsp)
movsd %xmm0, 0x190(%rsp)
movups 0x188(%rsp), %xmm0
movaps %xmm0, 0x3b0(%rsp)
movups 0x3e8(%rsp), %xmm0
movaps %xmm0, 0x150(%rsp)
movsd 0x150(%rsp), %xmm0
movsd 0x158(%rsp), %xmm1
leaq 0x3b0(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x68(%rsp)
jmp 0x4bdc
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd %xmm1, 0x160(%rsp)
movsd %xmm0, 0x168(%rsp)
leaq 0x1075f(%rip), %rdi     # 0x15360
xorl %eax, %eax
movl %eax, %esi
callq 0x5f30
movups 0x160(%rsp), %xmm0
movups %xmm0, (%rax)
movups 0x320(%rsp), %xmm0
movaps %xmm0, 0x130(%rsp)
movsd 0x130(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
leaq 0x2f8(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x58(%rsp)
jmp 0x4c52
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd %xmm1, 0x140(%rsp)
movsd %xmm0, 0x148(%rsp)
movups 0x140(%rsp), %xmm0
movaps %xmm0, 0x320(%rsp)
movups 0x3e8(%rsp), %xmm0
movaps %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
leaq 0x320(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x40(%rsp)
movsd %xmm0, 0x48(%rsp)
jmp 0x4cbd
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd %xmm1, 0x120(%rsp)
movsd %xmm0, 0x128(%rsp)
leaq 0x1067e(%rip), %rdi     # 0x15360
movl $0x1, %esi
callq 0x5f30
movups 0x120(%rsp), %xmm0
movups %xmm0, (%rax)
movups 0x290(%rsp), %xmm0
movaps %xmm0, 0xf0(%rsp)
movsd 0xf0(%rsp), %xmm0
movsd 0xf8(%rsp), %xmm1
leaq 0x268(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
jmp 0x4d34
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0x100(%rsp)
movsd %xmm0, 0x108(%rsp)
movups 0x100(%rsp), %xmm0
movaps %xmm0, 0x290(%rsp)
movups 0x3e8(%rsp), %xmm0
movaps %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
leaq 0x290(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
jmp 0x4d9f
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0xe0(%rsp)
movsd %xmm0, 0xe8(%rsp)
leaq 0x1059c(%rip), %rdi     # 0x15360
movl $0x2, %esi
callq 0x5f30
movups 0xe0(%rsp), %xmm0
movups %xmm0, (%rax)
leaq 0xa2c8(%rip), %rsi      # 0xf0a8
leaq 0x90(%rsp), %rdi
leaq 0x1f0(%rsp), %rdx
callq 0x69d0
jmp 0x4df7
leaq 0xa2da(%rip), %rdx      # 0xf0d8
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x6980
jmp 0x4e15
leaq 0xb0(%rsp), %rdi
movl $0x1, %esi
callq 0x3f40
jmp 0x4e29
leaq 0xb0(%rsp), %rdi
callq 0x3200
leaq 0x90(%rsp), %rdi
callq 0x3200
movq 0x10186(%rip), %rdi     # 0x14fd0
leaq 0xa25f(%rip), %rsi      # 0xf0b0
callq 0x3310
movq %rax, 0x18(%rsp)
jmp 0x4e5d
movq 0x18(%rsp), %rdi
movl 0x214(%rsp), %esi
callq 0x3560
movq %rax, 0x10(%rsp)
jmp 0x4e75
movq 0x10(%rsp), %rdi
leaq 0xa22d(%rip), %rsi      # 0xf0ae
callq 0x3310
movq %rax, 0x8(%rsp)
jmp 0x4e8d
movq 0x8(%rsp), %rdi
leaq 0xa22c(%rip), %rsi      # 0xf0c5
callq 0x3310
jmp 0x4ea0
leaq 0x1f0(%rsp), %rdi
callq 0x3200
movl 0x214(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x214(%rsp)
jmp 0x49f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x4f1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x4f10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x3200
leaq 0x90(%rsp), %rdi
callq 0x3200
leaq 0x1f0(%rsp), %rdi
callq 0x3200
jmp 0x4f34
addq $0x3f8, %rsp            # imm = 0x3F8
retq
movq 0x1a0(%rsp), %rdi
callq 0x3590
nopw %cs:(%rax,%rax)