// File: /workspace/github_cpp_makefile_star2_O2/soybin[P]idyll/src/fractal.cpp
// Function: fractal::fractal(seed*)
fractal::fractal(seed* s) : s(s) {

	//
	// get number of fractal iterations
	//
	iterations = s->values["iterations"];

	//
	// determine shadow softness of the fractal
	//
	shadowSoftness = s->values["shadowSoftness"];

	//
	// get fractal color
	//
	color.x = s->values["xcolor"];
	color.y = s->values["ycolor"];
	color.z = s->values["zcolor"];

	//
	// get top sky gradient color
	// 
	gradientTop.x = s->values["xgradientTop"];
	gradientTop.y = s->values["ygradientTop"];
	gradientTop.z = s->values["zgradientTop"];

	//
	// get bottom sky gradient color
	//
	gradientBottom.x = s->values["xgradientBottom"];
	gradientBottom.y = s->values["ygradientBottom"];
	gradientBottom.z = s->values["zgradientBottom"];

	//
	// randomly change gradient color positions
	//
	if (s->i(0, 1)) {
		math::vec3 temp = gradientTop;
		gradientTop = gradientBottom;
		gradientBottom = temp;
	}

	//
	// determine fractal shift variation vector per iteration
	//
	xs = s->values["xshift"];
	zs = s->values["zshift"];
	
	//
	// determine fractal rotation per iteration
	//
	xr = s->values["xrotation"];
	zr = s->values["zrotation"];

	//
	// precompute sine and cosine of rotation angles
	//
	xrs = std::sin(xr);
	xrc = std::cos(xr);
	zrs = std::sin(zr);
	zrc = std::cos(zr);
	
	//
	// initialize point iterator
	//
	switch ((int)s->values["pointIterator"]) {
		case 0:
			mainPI = new PI0(xs, zs, xrs, xrc, zrs, zrc);
			break;
		case 1:
			mainPI = new PI1(xs, zs, xrs, xrc, zrs, zrc);
			break;
		case 2:
			mainPI = new PI2(xs, zs, xrs, xrc, zrs, zrc);
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x50(%rdi), %r13
movq %r13, %rdi
callq 0x5c20
movq %r14, 0x68(%rbx)
leaq 0x78(%rbx), %r15
movq %r15, %rdi
callq 0x5c20
leaq 0x90(%rbx), %r12
movq %r12, %rdi
callq 0x5c20
leaq 0x4bc3(%rip), %rsi      # 0xca48
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
movq %r14, -0x58(%rbp)
addq $0x2718, %r14           # imm = 0x2718
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
cvttsd2si (%rax), %eax
movl %eax, (%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4b94(%rip), %rsi      # 0xca53
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4b71(%rip), %rsi      # 0xca62
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, (%r13)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4b45(%rip), %rsi      # 0xca69
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4b1a(%rip), %rsi      # 0xca70
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4aef(%rip), %rsi      # 0xca77
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, (%r15)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4aca(%rip), %rsi      # 0xca84
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4aa2(%rip), %rsi      # 0xca91
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4a7a(%rip), %rsi      # 0xca9e
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, (%r12)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4a57(%rip), %rsi      # 0xcaae
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x98(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4a32(%rip), %rsi      # 0xcabe
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0xa0(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
pushq $0x1
popq %rdx
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x970a
testl %eax, %eax
je 0x80f7
movq 0x10(%r15), %rax
leaq -0x50(%rbp), %r13
movq %rax, 0x10(%r13)
movups (%r15), %xmm0
movaps %xmm0, (%r13)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5d8a
movq %r12, %rdi
movq %r13, %rsi
callq 0x5d8a
leaq 0x49d0(%rip), %rsi      # 0xcace
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x49a5(%rip), %rsi      # 0xcad5
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x497a(%rip), %rsi      # 0xcadc
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
leaq 0x4952(%rip), %rsi      # 0xcae6
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
leaq -0x50(%rbp), %rdi
callq 0x3100
movsd 0x18(%rbx), %xmm0
callq 0x3090
movsd %xmm0, 0x28(%rbx)
movsd 0x18(%rbx), %xmm0
callq 0x34a0
movsd %xmm0, 0x30(%rbx)
movsd 0x20(%rbx), %xmm0
callq 0x3090
movsd %xmm0, 0x38(%rbx)
movsd 0x20(%rbx), %xmm0
callq 0x34a0
movsd %xmm0, 0x40(%rbx)
leaq 0x48ee(%rip), %rsi      # 0xcaf0
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4676
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x7838
cvttsd2si (%rax), %r14d
leaq -0x50(%rbp), %rdi
callq 0x3100
cmpl $0x3, %r14d
jae 0x8264
movl %r14d, %eax
leaq 0x9b07(%rip), %rcx      # 0x11d40
movq (%rcx,%rax,8), %r14
pushq $0x38
popq %rdi
callq 0x32a0
movups 0x8(%rbx), %xmm0
movups 0x28(%rbx), %xmm1
movups 0x38(%rbx), %xmm2
movups %xmm0, 0x8(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm2, 0x28(%rax)
movq %r14, (%rax)
movq %rax, 0x70(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
jmp 0x82af
jmp 0x82bd
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3100
jmp 0x82c0
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3460