// File: /workspace/github_c_makefile_star2_O3/skeeto[P]goblin-com/src/map.c
// Function: map_generate
map_t *
map_generate(uint64_t seed)
{
    map_t *map = malloc(sizeof(*map));
    size_t alloc_size = WORK_SIZE * WORK_SIZE * sizeof(float);
    float *buf_a = calloc(alloc_size, 1);
    float *buf_b = calloc(alloc_size, 1);
    float *heightmap = buf_a;
    for (int i = 0; i < 4; i++)
        heightmap[i] = rand_uniform_s(&seed, -1, 1);
    size_t size = 3;
    while (size < WORK_SIZE) {
        size = grow(buf_a, size, buf_b, &seed);
        heightmap = buf_b;
        buf_b = buf_a;
        buf_a = heightmap;
    }
    for (size_t y = 0; y < MAP_HEIGHT * MAP_HEIGHT; y++) {
        for (size_t x = 0; x < MAP_WIDTH * MAP_WIDTH; x++) {
            float height = heightmap[y * WORK_SIZE + x];
            float sx = x / (float)(MAP_WIDTH * MAP_WIDTH) - 0.5;
            float sy = y / (float)(MAP_HEIGHT * MAP_HEIGHT) - 0.5;
            float s = sqrt(sx * sx + sy * sy) * 3 - 0.45f;
            map->low[x][y].height = height - s;
        }
    }
    free(buf_a);
    free(buf_b);
    summarize(map, &seed);
    return map;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x28(%rsp), %r15
movq %rdi, (%r15)
movl $0x7eea00, %edi         # imm = 0x7EEA00
callq 0x11c0
movq %rax, 0x18(%rsp)
movl $0x4008004, %edi        # imm = 0x4008004
movl $0x1, %esi
callq 0x1160
movq %rax, %r13
movl $0x4008004, %edi        # imm = 0x4008004
movl $0x1, %esi
callq 0x1160
movq %rax, %r14
xorl %ebx, %ebx
movq %r15, %rdi
movss 0x3372(%rip), %xmm0     # 0x7844
movss 0x336e(%rip), %xmm1     # 0x7848
callq 0x6004
movss %xmm0, (%r13,%rbx,4)
incq %rbx
cmpq $0x4, %rbx
jne 0x44c7
movl $0x3, %r9d
movq %r9, %rax
movq %r14, %rdi
leaq -0x1(,%r9,2), %r9
movq %rax, %rbx
shlq $0x4, %rbx
addq $-0x8, %rbx
leaq (,%rax,4), %r12
movq %r13, %rcx
movq %r14, %rdx
xorl %esi, %esi
xorl %r8d, %r8d
movss (%rcx,%r8,4), %xmm0
movss %xmm0, (%rdx,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x4521
incq %rsi
addq %rbx, %rdx
addq %r12, %rcx
cmpq %rax, %rsi
jne 0x451e
movq %r13, 0x40(%rsp)
cmpq $0x1, %r9
je 0x47a3
testq %r9, %r9
js 0x4561
xorps %xmm0, %xmm0
cvtsi2ss %r9, %xmm0
jmp 0x457c
movq %r9, %rax
shrq %rax
movl %r9d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq %r9, %r13
imulq %r9, %r13
addq $-0x2, %r12
movl $0x1, %eax
xorl %ecx, %ecx
movq %rdi, %r14
movq %rdi, 0x30(%rsp)
movq %r9, 0x38(%rsp)
movq %rax, 0x58(%rsp)
imulq %r9, %rax
leaq (%rdi,%rax,4), %rax
movq %rax, 0x60(%rsp)
movq %rcx, 0x50(%rsp)
movq %rcx, %rax
movq %r14, 0x48(%rsp)
movl $0x1, %ebp
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movq $-0x1, %rdx
movq %rax, 0x10(%rsp)
movq %r14, %rcx
xorl %esi, %esi
movq %rax, %rdi
addq %rsi, %rdi
setns %r8b
cmpq %r13, %rdi
setb %dil
andb %r8b, %dil
cmpb $0x1, %dil
jne 0x45fe
addss (%rcx,%rsi,4), %xmm0
incl %r15d
leaq 0x2(%rsi), %rdi
decq %rsi
movq %rdi, %rsi
js 0x45dc
leaq 0x2(%rdx), %rsi
addq %rbx, %rcx
addq %r12, %rax
testq %rdx, %rdx
movq %rsi, %rdx
js 0x45da
leaq 0x28(%rsp), %rdi
movss %xmm0, 0x20(%rsp)
movss 0x3215(%rip), %xmm0     # 0x7844
movss 0x3211(%rip), %xmm1     # 0x7848
callq 0x6004
xorps %xmm1, %xmm1
cvtsi2ss %r15d, %xmm1
movss 0x20(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0xc(%rsp), %xmm0
mulss 0x31f0(%rip), %xmm0     # 0x784c
addss %xmm2, %xmm0
movq 0x60(%rsp), %rax
movss %xmm0, (%rax,%rbp,4)
addq $0x2, %rbp
addq $0x8, %r14
movq 0x10(%rsp), %rax
addq $0x2, %rax
movq 0x38(%rsp), %r9
cmpq %r9, %rbp
jb 0x45c5
movq 0x58(%rsp), %rax
addq $0x2, %rax
movq 0x48(%rsp), %r14
addq %rbx, %r14
movq 0x50(%rsp), %rcx
addq %r12, %rcx
cmpq %r9, %rax
movq 0x30(%rsp), %rdi
jb 0x45a1
cmpq $0x3, %r9
movl $0x2, %eax
cmovaeq %r9, %rax
movq %rax, 0x20(%rsp)
movl $0x1, %r14d
leaq 0x3221(%rip), %r8       # 0x78f0
movq %r14, %r15
incq %r14
movl %r14d, %r12d
andl $0x1, %r12d
cmpq %r9, %r12
je 0x4798
movq %r15, %rax
imulq %r9, %rax
leaq (%rdi,%rax,4), %rbp
xorl %eax, %eax
xorps %xmm0, %xmm0
xorl %ebx, %ebx
movslq 0x4(%r8,%rax,8), %rdx
addq %r15, %rdx
imulq %r9, %rdx
movslq (%r8,%rax,8), %rcx
addq %r12, %rcx
addq %rdx, %rcx
setns %dl
cmpq %r13, %rcx
setb %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x4727
addss (%rdi,%rcx,4), %xmm0
incl %ebx
incq %rax
cmpq $0x4, %rax
jne 0x46f7
leaq 0x28(%rsp), %rdi
movss %xmm0, 0x10(%rsp)
movss 0x3101(%rip), %xmm0     # 0x7844
movss 0x30fd(%rip), %xmm1     # 0x7848
callq 0x6004
leaq 0x3199(%rip), %r8       # 0x78f0
movq 0x38(%rsp), %r9
movq 0x30(%rsp), %rdi
xorps %xmm1, %xmm1
cvtsi2ss %ebx, %xmm1
movss 0x10(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0xc(%rsp), %xmm0
mulss 0x30cc(%rip), %xmm0     # 0x784c
addss %xmm2, %xmm0
movss %xmm0, (%rbp,%r12,4)
addq $0x2, %r12
cmpq %r9, %r12
jb 0x46f0
cmpq 0x20(%rsp), %r14
jne 0x46cf
movq %rdi, %r13
cmpq $0x1001, %r9            # imm = 0x1001
movq 0x40(%rsp), %r14
jb 0x44f5
movq 0x18(%rsp), %rax
addq $0x5a00, %rax           # imm = 0x5A00
xorl %ecx, %ecx
movss 0x3083(%rip), %xmm0     # 0x7850
movss 0x307f(%rip), %xmm7     # 0x7854
movss 0x307b(%rip), %xmm1     # 0x7858
movsd 0x308b(%rip), %xmm2     # 0x7870
movsd 0x308b(%rip), %xmm3     # 0x7878
movq %rdi, %rdx
xorps %xmm4, %xmm4
cvtsi2ss %rcx, %xmm4
divss %xmm0, %xmm4
addss %xmm7, %xmm4
mulss %xmm4, %xmm4
movq %rax, %rsi
xorl %r8d, %r8d
xorps %xmm5, %xmm5
cvtsi2ss %r8, %xmm5
divss %xmm1, %xmm5
addss %xmm7, %xmm5
mulss %xmm5, %xmm5
addss %xmm4, %xmm5
cvtss2sd %xmm5, %xmm5
sqrtsd %xmm5, %xmm5
mulsd %xmm2, %xmm5
movss (%rdx,%r8,4), %xmm6
addsd %xmm3, %xmm5
cvtsd2ss %xmm5, %xmm5
subss %xmm5, %xmm6
movss %xmm6, (%rsi)
incq %r8
addq $0x900, %rsi            # imm = 0x900
cmpq $0xe10, %r8             # imm = 0xE10
jne 0x480a
incq %rcx
addq $0x4004, %rdx           # imm = 0x4004
addq $0x4, %rax
cmpq $0x240, %rcx            # imm = 0x240
jne 0x47f0
callq 0x1030
movq %r14, %rdi
callq 0x1030
movss 0x2fd1(%rip), %xmm2     # 0x7854
xorl %ebx, %ebx
movss 0x2fcf(%rip), %xmm3     # 0x785c
leaq 0x28(%rsp), %r14
movl $0x2e, %ebp
movq 0x18(%rsp), %r15
movq %r15, %r12
xorl %r13d, %r13d
xorps %xmm5, %xmm5
movq %r12, %rax
xorl %ecx, %ecx
movl $0x5a00, %edx           # imm = 0x5A00
addss (%rax,%rdx), %xmm5
addq $0x900, %rdx            # imm = 0x900
cmpq $0x27600, %rdx          # imm = 0x27600
jne 0x48af
incq %rcx
addq $0x4, %rax
cmpq $0x18, %rcx
jne 0x48aa
divss %xmm3, %xmm5
xorps %xmm0, %xmm0
movq %r12, %rax
xorl %ecx, %ecx
movl $0x5a00, %edx           # imm = 0x5A00
movaps %xmm5, %xmm1
subss (%rax,%rdx), %xmm1
mulss %xmm1, %xmm1
addss %xmm1, %xmm0
addq $0x900, %rdx            # imm = 0x900
cmpq $0x27600, %rdx          # imm = 0x27600
jne 0x48e2
incq %rcx
addq $0x4, %rax
cmpq $0x18, %rcx
jne 0x48dd
divss %xmm3, %xmm0
ucomiss 0x2f46(%rip), %xmm0     # 0x7860
jb 0x4922
sqrtss %xmm0, %xmm0
jmp 0x4943
movss %xmm5, 0x10(%rsp)
callq 0x11a0
movss 0x10(%rsp), %xmm5
movss 0x2f21(%rip), %xmm3     # 0x785c
movss 0x2f11(%rip), %xmm2     # 0x7854
xorps %xmm1, %xmm1
cvtss2sd %xmm5, %xmm1
movw $0x20, %ax
movsd 0x2f2a(%rip), %xmm4     # 0x7880
ucomisd %xmm1, %xmm4
ja 0x49d3
movw $0x2248, %ax            # imm = 0x2248
movsd 0x2f20(%rip), %xmm4     # 0x7888
ucomisd %xmm1, %xmm4
ja 0x49d3
movw $0x3a, %ax
ucomiss %xmm5, %xmm2
ja 0x49d3
cvtss2sd %xmm0, %xmm0
movw $0x25b2, %ax            # imm = 0x25B2
ucomisd 0x2f09(%rip), %xmm0     # 0x7890
ja 0x49d3
movw $0x2229, %ax            # imm = 0x2229
ucomisd 0x2f03(%rip), %xmm0     # 0x7898
ja 0x49d3
movq %r14, %rdi
movss 0x2ea2(%rip), %xmm0     # 0x7844
movss 0x2e9e(%rip), %xmm1     # 0x7848
callq 0x6004
movss 0x2ea5(%rip), %xmm3     # 0x785c
movss 0x2e95(%rip), %xmm2     # 0x7854
cvtss2sd %xmm0, %xmm0
ucomisd 0x2ed5(%rip), %xmm0     # 0x78a0
movl $0x2663, %eax           # imm = 0x2663
cmoval %ebp, %eax
leaq (,%r13,2), %rcx
addq %r13, %rcx
shlq $0x7, %rcx
addq 0x18(%rsp), %rcx
movq %rbx, %rdx
shlq $0x4, %rdx
movw %ax, (%rdx,%rcx)
movw $0x0, 0x2(%rdx,%rcx)
incq %r13
addq $0x21c00, %r12          # imm = 0x21C00
cmpq $0x3c, %r13
jne 0x48a2
incq %rbx
addq $0x60, %r15
cmpq $0x18, %rbx
jne 0x489c
movq 0x18(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq