// File: /workspace/github_c_makefile_star2_O2/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 0x30(%rsp), %r15
movq %rdi, (%r15)
movl $0x7eea00, %edi         # imm = 0x7EEA00
callq 0x11c0
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rbx
movl $0x4008004, %edi        # imm = 0x4008004
movq %rbx, %rsi
callq 0x1160
movq %rax, %r12
movl $0x4008004, %edi        # imm = 0x4008004
movq %rbx, %rsi
callq 0x1160
movq %rax, %r14
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x37d7
movq %r15, %rdi
movss 0x2fe9(%rip), %xmm0     # 0x67a8
movss 0x2fe5(%rip), %xmm1     # 0x67ac
callq 0x519e
movss %xmm0, (%r12,%rbx,4)
incq %rbx
jmp 0x37ae
pushq $0x3
popq %rax
leaq 0x306f(%rip), %rbp      # 0x6850
movq %r14, %r9
cmpq $0x1001, %rax           # imm = 0x1001
jae 0x3a95
leaq -0x1(,%rax,2), %rbx
movq %rax, %r14
shlq $0x4, %r14
addq $-0x8, %r14
leaq (,%rax,4), %r13
movq %r12, %rcx
movq %r9, %rdx
xorl %esi, %esi
cmpq %rax, %rsi
je 0x3839
xorl %edi, %edi
cmpq %rdi, %rax
je 0x382e
movss (%rcx,%rdi,4), %xmm0
movss %xmm0, (%rdx,%rdi,8)
incq %rdi
jmp 0x381a
incq %rsi
addq %r14, %rdx
addq %r13, %rcx
jmp 0x3813
testq %rbx, %rbx
movq %r12, 0x50(%rsp)
js 0x384a
cvtsi2ss %rbx, %xmm0
jmp 0x3861
movq %rbx, %rax
shrq %rax
movl %ebx, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
movq %rbx, %r12
imulq %rbx, %r12
addq $-0x2, %r13
movq $0x0, 0x48(%rsp)
movq %r9, 0x40(%rsp)
pushq $0x1
popq %rax
movq %r9, 0x8(%rsp)
cmpq %rbx, %rax
jae 0x39a8
movq %rax, 0x58(%rsp)
imulq %rbx, %rax
leaq (%r9,%rax,4), %rax
movq %rax, 0x60(%rsp)
movq 0x48(%rsp), %rcx
movq 0x40(%rsp), %rdx
pushq $0x1
popq %rax
cmpq %rbx, %rax
jae 0x3990
movq %rax, 0x18(%rsp)
xorps %xmm0, %xmm0
xorl %r15d, %r15d
movq %rcx, 0x28(%rsp)
movq %rcx, %rax
movq %rdx, 0x20(%rsp)
movq %rdx, %rcx
pushq $-0x1
popq %rdx
cmpq $0x1, %rdx
jg 0x391d
xorl %esi, %esi
leaq -0x1(%rsi), %rdi
cmpq $0x2, %rdi
jge 0x3911
movq %rax, %rdi
addq %rsi, %rdi
setns %r8b
cmpq %r12, %rdi
setb %dil
andb %r8b, %dil
cmpb $0x1, %dil
jne 0x390b
addss (%rcx,%rsi,4), %xmm0
incl %r15d
addq $0x2, %rsi
jmp 0x38df
addq $0x2, %rdx
addq %r14, %rcx
addq %r13, %rax
jmp 0x38d7
leaq 0x30(%rsp), %rdi
movss %xmm0, 0x3c(%rsp)
movss 0x2e78(%rip), %xmm0     # 0x67a8
movss 0x2e74(%rip), %xmm1     # 0x67ac
callq 0x519e
movq 0x8(%rsp), %r9
cvtsi2ss %r15d, %xmm1
movss 0x3c(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0x4(%rsp), %xmm0
mulss 0x2e61(%rip), %xmm0     # 0x67c0
addss %xmm2, %xmm0
movq 0x60(%rsp), %rax
movq 0x18(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq %rcx, %rax
addq $0x2, %rax
movq 0x20(%rsp), %rdx
addq $0x8, %rdx
movq 0x28(%rsp), %rcx
addq $0x2, %rcx
jmp 0x38b0
movq 0x58(%rsp), %rax
addq $0x2, %rax
addq %r14, 0x40(%rsp)
addq %r13, 0x48(%rsp)
jmp 0x3888
pushq $0x1
popq %r14
cmpq %rbx, %r14
je 0x3a85
leaq 0x1(%r14), %r13
movq %r13, 0x18(%rsp)
andl $0x1, %r13d
movq %r14, %rax
imulq %rbx, %rax
leaq (%r9,%rax,4), %rax
movq %rax, 0x20(%rsp)
cmpq %rbx, %r13
jae 0x3a7b
xorps %xmm0, %xmm0
xorl %eax, %eax
xorl %r15d, %r15d
cmpq $0x4, %rax
je 0x3a21
movslq 0x4(%rbp,%rax,8), %rdx
addq %r14, %rdx
imulq %rbx, %rdx
movslq (%rbp,%rax,8), %rcx
addq %r13, %rcx
addq %rdx, %rcx
setns %dl
cmpq %r12, %rcx
setb %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x3a1c
addss (%r9,%rcx,4), %xmm0
incl %r15d
incq %rax
jmp 0x39e3
leaq 0x30(%rsp), %rdi
movss %xmm0, 0x28(%rsp)
movss 0x2d74(%rip), %xmm0     # 0x67a8
movss 0x2d70(%rip), %xmm1     # 0x67ac
callq 0x519e
movq 0x8(%rsp), %r9
cvtsi2ss %r15d, %xmm1
movss 0x28(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0x4(%rsp), %xmm0
mulss 0x2d5d(%rip), %xmm0     # 0x67c0
addss %xmm2, %xmm0
movq 0x20(%rsp), %rax
movss %xmm0, (%rax,%r13,4)
addq $0x2, %r13
jmp 0x39d2
movq 0x18(%rsp), %r14
jmp 0x39ac
movq %rbx, %rax
movq 0x50(%rsp), %r14
movq %r9, %r12
jmp 0x37e1
movq 0x10(%rsp), %rax
movq %r12, %rcx
leaq 0x5a00(%rax), %r12
xorl %eax, %eax
movss 0x2d02(%rip), %xmm0     # 0x67b0
movss 0x2cfe(%rip), %xmm7     # 0x67b4
movss 0x2cfa(%rip), %xmm1     # 0x67b8
movsd 0x2d0a(%rip), %xmm2     # 0x67d0
movsd 0x2d0a(%rip), %xmm3     # 0x67d8
movq %rcx, %rdi
movq %r12, %rdx
cmpq $0x240, %rax            # imm = 0x240
je 0x3b4f
cvtsi2ss %rax, %xmm4
divss %xmm0, %xmm4
addss %xmm7, %xmm4
mulss %xmm4, %xmm4
movq %rdx, %rsi
xorl %r8d, %r8d
cmpq $0xe10, %r8             # imm = 0xE10
je 0x3b3f
cvtsi2ss %r8, %xmm5
movss (%rcx,%r8,4), %xmm6
divss %xmm1, %xmm5
addss %xmm7, %xmm5
mulss %xmm5, %xmm5
addss %xmm4, %xmm5
cvtss2sd %xmm5, %xmm5
sqrtsd %xmm5, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
cvtsd2ss %xmm5, %xmm5
subss %xmm5, %xmm6
movss %xmm6, (%rsi)
incq %r8
addq $0x900, %rsi            # imm = 0x900
jmp 0x3af3
incq %rax
addq $0x4, %rdx
addq $0x4004, %rcx           # imm = 0x4004
jmp 0x3ad4
movq %r9, %rbx
callq 0x1030
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movss 0x2c53(%rip), %xmm3     # 0x67bc
pushq $0x2e
popq %rbp
cmpq $0x18, %rbx
je 0x3cfa
movq %rbx, %r15
shlq $0x4, %r15
movq %r12, %r13
xorl %r14d, %r14d
movss 0x2c29(%rip), %xmm2     # 0x67b4
cmpq $0x3c, %r14
je 0x3cee
xorps %xmm5, %xmm5
movq %r13, %rax
xorl %ecx, %ecx
cmpq $0x18, %rcx
je 0x3bc5
xorl %edx, %edx
cmpq $0x21c00, %rdx          # imm = 0x21C00
je 0x3bbc
addss (%rax,%rdx), %xmm5
addq $0x900, %rdx            # imm = 0x900
jmp 0x3ba5
incq %rcx
addq $0x4, %rax
jmp 0x3b9d
divss %xmm3, %xmm5
xorps %xmm0, %xmm0
movq %r13, %rax
xorl %ecx, %ecx
cmpq $0x18, %rcx
je 0x3c04
xorl %edx, %edx
cmpq $0x21c00, %rdx          # imm = 0x21C00
je 0x3bfb
movaps %xmm5, %xmm1
subss (%rax,%rdx), %xmm1
mulss %xmm1, %xmm1
addss %xmm1, %xmm0
addq $0x900, %rdx            # imm = 0x900
jmp 0x3bd9
incq %rcx
addq $0x4, %rax
jmp 0x3bd1
divss %xmm3, %xmm0
ucomiss 0x2bb5(%rip), %xmm0     # 0x67c4
jb 0x3c17
sqrtss %xmm0, %xmm0
jmp 0x3c38
movss %xmm5, 0x8(%rsp)
callq 0x11a0
movss 0x8(%rsp), %xmm5
movss 0x2b8c(%rip), %xmm3     # 0x67bc
movss 0x2b7c(%rip), %xmm2     # 0x67b4
cvtss2sd %xmm5, %xmm1
movw $0x20, %ax
movsd 0x2b98(%rip), %xmm4     # 0x67e0
ucomisd %xmm1, %xmm4
ja 0x3cc7
movw $0x2248, %ax            # imm = 0x2248
movsd 0x2b8e(%rip), %xmm4     # 0x67e8
ucomisd %xmm1, %xmm4
ja 0x3cc7
movw $0x3a, %ax
ucomiss %xmm5, %xmm2
ja 0x3cc7
cvtss2sd %xmm0, %xmm0
movw $0x25b2, %ax            # imm = 0x25B2
ucomisd 0x2b77(%rip), %xmm0     # 0x67f0
ja 0x3cc7
movw $0x2229, %ax            # imm = 0x2229
ucomisd 0x2b71(%rip), %xmm0     # 0x67f8
ja 0x3cc7
leaq 0x30(%rsp), %rdi
movss 0x2b12(%rip), %xmm0     # 0x67a8
movss 0x2b0e(%rip), %xmm1     # 0x67ac
callq 0x519e
movss 0x2b11(%rip), %xmm3     # 0x67bc
movss 0x2b01(%rip), %xmm2     # 0x67b4
cvtss2sd %xmm0, %xmm0
ucomisd 0x2b41(%rip), %xmm0     # 0x6800
movl $0x2663, %eax           # imm = 0x2663
cmoval %ebp, %eax
imulq $0x180, %r14, %rcx      # imm = 0x180
addq 0x10(%rsp), %rcx
movw %ax, (%r15,%rcx)
andw $0x0, 0x2(%r15,%rcx)
incq %r14
addq $0x21c00, %r13          # imm = 0x21C00
jmp 0x3b8b
incq %rbx
addq $0x60, %r12
jmp 0x3b6c
movq 0x10(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq