// File: lotuskip[P]yuxtapa/server/map.cpp
// Function: (anonymous namespace)::fill2DFractArray(float*, int, float)
void fill2DFractArray(float* const fa, const int size, const float h)
{
    int subSize = size-1;
	float ratio = pow(2.,-h);
	float scale = ratio;
    int stride = subSize/2;

	// Initialize the corner values. This greatly affects the final outcome,
	// so we don't just randomize them (that can lead to maps that are almost
	// completely flooded or contain almost solely rock (which, admittedly,
	// still happens now but less often! I have not been able to find fixed
	// seeds that would (a) yield interesting maps, and (b) never result in
	// stupid maps.))
	vector<float> seeds(4);
	seeds[0] = 0.75f + fractRand(0.25f); // (0.5,1.0)
	seeds[1] = fractRand(0.5f); // (-0.5,0.5)
	seeds[2] = fractRand(0.5f); // (-0.5,0.5)
	seeds[3] = -0.75f + fractRand(0.25f); //(-1.0,-0.5)

	// Assign those randomly to the four corners:
	vector<float>::iterator it = seeds.begin()+random()%4;
	fa[0] = *it;
	seeds.erase(it);
	it = seeds.begin()+random()%3;
    fa[(subSize*size)] = *it;
	seeds.erase(it);
	it = seeds.begin()+random()%2;
    fa[(subSize*size)+subSize] = *it;
	seeds.erase(it);
    fa[subSize] = seeds[0];
    
    int	i, j, oddline;
    while(stride)
	{
		for(i = stride; i < subSize; i += stride)
		{
			for(j = stride; j < subSize; j += stride)
			{
				fa[(i * size) + j] = scale*fractRand(.5f)
					+ avgSquareVals(i, j, stride, size, fa);
				j += stride;
			}
			i += stride;
		}

		oddline = 0;
		for(i = 0; i < subSize; i += stride)
		{
		    oddline = (oddline == 0);
			for(j = 0; j < subSize; j += stride)
			{
				if(oddline && !j)
					j += stride;

				fa[(i * size) + j] = scale*fractRand(.5f)
					+ avgDiamondVals(i, j, stride, size, subSize, fa);

				if(!i)
					fa[(subSize*size) + j] = fa[(i * size) + j];
				if(!j)
					fa[(i*size) + subSize] = fa[(i * size) + j];
				j += stride;
			}
		}

		scale *= ratio;
		stride >>= 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movss %xmm0, -0x10(%rbp)
movl -0xc(%rbp), %eax
decl %eax
movl %eax, -0x14(%rbp)
movaps 0x375aa(%rip), %xmm0    # 0x61b00
movss -0x10(%rbp), %xmm1
pxor %xmm0, %xmm1
movsd 0x37551(%rip), %xmm0    # 0x61ab8
callq 0x2f420
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
movl %eax, -0x20(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x2f450
movq -0xc8(%rbp), %rdx
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x2f470
jmp 0x2a5b5
leaq -0x39(%rbp), %rdi
callq 0x2f4e0
movss 0x37516(%rip), %xmm0    # 0x61adc
movss %xmm0, -0xe8(%rbp)
callq 0x2a4e0
movss 0x37505(%rip), %xmm1    # 0x61ae0
addss %xmm1, %xmm0
movss %xmm0, -0xf8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x2f500
movss -0xf8(%rbp), %xmm0
movss %xmm0, (%rax)
movss 0x374d5(%rip), %xmm0    # 0x61ae4
movss %xmm0, -0xf0(%rbp)
callq 0x2a4e0
movq -0xd8(%rbp), %rdi
movss %xmm0, -0xf4(%rbp)
movl $0x1, %esi
callq 0x2f500
movss -0xf4(%rbp), %xmm1
movss -0xf0(%rbp), %xmm0
movss %xmm1, (%rax)
callq 0x2a4e0
movq -0xd8(%rbp), %rdi
movss %xmm0, -0xec(%rbp)
movl $0x2, %esi
callq 0x2f500
movss -0xec(%rbp), %xmm1
movss -0xe8(%rbp), %xmm0
movss %xmm1, (%rax)
callq 0x2a4e0
movq -0xd8(%rbp), %rdi
movss 0x37459(%rip), %xmm1    # 0x61ae8
addss %xmm1, %xmm0
movss %xmm0, -0xe4(%rbp)
movl $0x3, %esi
callq 0x2f500
movss -0xe4(%rbp), %xmm0
movq -0xd8(%rbp), %rdi
movss %xmm0, (%rax)
callq 0x2f520
movq %rax, -0x60(%rbp)
callq 0x5270
movq %rax, %rsi
movq %rsi, %rcx
addq $0x3, %rcx
testq %rsi, %rsi
movq %rsi, %rax
cmovsq %rcx, %rax
andq $-0x4, %rax
subq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x2f550
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x2f590
movq -0xe0(%rbp), %rsi
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, (%rax)
leaq -0x68(%rbp), %rdi
callq 0x2f620
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x2f5b0
movq %rax, -0xd0(%rbp)
jmp 0x2a733
movq -0xd0(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x2f520
movq %rax, -0x80(%rbp)
callq 0x5270
movq %rax, %rsi
movabsq $0x5555555555555556, %rcx # imm = 0x5555555555555556
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
addq %rax, %rdx
leaq (%rdx,%rdx,2), %rax
subq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x2f550
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2f590
movq -0x110(%rbp), %rsi
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl -0xc(%rbp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
leaq -0x88(%rbp), %rdi
callq 0x2f620
movq -0x108(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x2f5b0
movq %rax, -0x100(%rbp)
jmp 0x2a7e8
movq -0x100(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x2f520
movq %rax, -0xa0(%rbp)
callq 0x5270
movq %rax, %rsi
movq %rsi, %rcx
shrq $0x3f, %rcx
movq %rsi, %rax
addq %rcx, %rax
andq $-0x2, %rax
subq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2f550
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x2f590
movq -0x128(%rbp), %rsi
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
movl -0xc(%rbp), %edi
movl %edx, %ecx
imull %edi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
leaq -0xa8(%rbp), %rdi
callq 0x2f620
movq -0x120(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2f5b0
movq %rax, -0x118(%rbp)
jmp 0x2a8a3
movq -0x118(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f500
movss (%rax), %xmm0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, -0x20(%rbp)
je 0x2abd0
movl -0x20(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2aa06
movl -0x20(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2a9e3
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x134(%rbp)
movss 0x371c6(%rip), %xmm0    # 0x61ae4
callq 0x2a4e0
movss %xmm0, -0x130(%rbp)
movl -0xb4(%rbp), %edi
movl -0xb8(%rbp), %esi
movl -0x20(%rbp), %edx
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %r8
callq 0x2d0d0
movss %xmm0, -0x12c(%rbp)
jmp 0x2a950
movss -0x12c(%rbp), %xmm1
movss -0x130(%rbp), %xmm2
movss -0x134(%rbp), %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movl -0xb4(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0x20(%rbp), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
jmp 0x2a8fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x2f4e0
jmp 0x2abe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2f660
jmp 0x2abe2
movl -0x20(%rbp), %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x20(%rbp), %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x2a8e2
movl $0x0, -0xbc(%rbp)
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2abb4
cmpl $0x0, -0xbc(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xbc(%rbp)
movl $0x0, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2ab9e
cmpl $0x0, -0xbc(%rbp)
je 0x2aa78
cmpl $0x0, -0xb8(%rbp)
jne 0x2aa78
movl -0x20(%rbp), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x140(%rbp)
movss 0x37057(%rip), %xmm0    # 0x61ae4
callq 0x2a4e0
movss %xmm0, -0x13c(%rbp)
movl -0xb4(%rbp), %edi
movl -0xb8(%rbp), %esi
movl -0x20(%rbp), %edx
movl -0xc(%rbp), %ecx
movl -0x14(%rbp), %r8d
movq -0x8(%rbp), %r9
callq 0x2d170
movss %xmm0, -0x138(%rbp)
jmp 0x2aac3
movss -0x138(%rbp), %xmm1
movss -0x13c(%rbp), %xmm2
movss -0x140(%rbp), %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movl -0xb4(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, -0xb4(%rbp)
jne 0x2ab3d
movq -0x8(%rbp), %rax
movl -0xb4(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, -0xb8(%rbp)
jne 0x2ab7b
movq -0x8(%rbp), %rax
movl -0xb4(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0xb8(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x8(%rbp), %rax
movl -0xb4(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0x20(%rbp), %eax
addl -0xb8(%rbp), %eax
movl %eax, -0xb8(%rbp)
jmp 0x2aa48
jmp 0x2aba0
movl -0x20(%rbp), %eax
addl -0xb4(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x2aa1a
movss -0x18(%rbp), %xmm0
mulss -0x1c(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
movl -0x20(%rbp), %eax
sarl %eax
movl %eax, -0x20(%rbp)
jmp 0x2a8cf
leaq -0x38(%rbp), %rdi
callq 0x2f660
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x5920
nopl (%rax,%rax)