// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%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, %rbp
xorl %ebx, %ebx
movq %r15, %rdi
movss 0x3956(%rip), %xmm0     # 0x77cc
movss 0x3952(%rip), %xmm1     # 0x77d0
callq 0x5a84
movss %xmm0, (%r13,%rbx,4)
incq %rbx
cmpq $0x4, %rbx
jne 0x3e6b
movl $0x3, %r9d
movq %r9, %rax
movq %rbp, %rdi
leaq -0x1(,%r9,2), %r9
movq %rax, %rbx
shlq $0x4, %rbx
addq $-0x8, %rbx
leaq (,%rax,4), %r12
movq %r13, %rcx
movq %rbp, %rdx
xorl %esi, %esi
xorl %r8d, %r8d
movss (%rcx,%r8,4), %xmm0
movss %xmm0, (%rdx,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x3ec5
incq %rsi
addq %rbx, %rdx
addq %r12, %rcx
cmpq %rax, %rsi
jne 0x3ec2
movq %r13, 0x40(%rsp)
cmpq $0x1, %r9
movq %rdi, 0x28(%rsp)
je 0x4147
testq %r9, %r9
js 0x3f0a
xorps %xmm0, %xmm0
cvtsi2ss %r9, %xmm0
jmp 0x3f25
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, 0x14(%rsp)
movq %r9, %r13
imulq %r9, %r13
addq $-0x2, %r12
movl $0x1, %eax
xorl %ecx, %ecx
movq %rdi, %r14
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, 0x8(%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 0x3fa2
addss (%rcx,%rsi,4), %xmm0
incl %r15d
leaq 0x2(%rsi), %rdi
decq %rsi
movq %rdi, %rsi
js 0x3f80
leaq 0x2(%rdx), %rsi
addq %rbx, %rcx
addq %r12, %rax
testq %rdx, %rdx
movq %rsi, %rdx
js 0x3f7e
leaq 0x30(%rsp), %rdi
movss %xmm0, 0x18(%rsp)
movss 0x37f9(%rip), %xmm0     # 0x77cc
movss 0x37f5(%rip), %xmm1     # 0x77d0
callq 0x5a84
xorps %xmm1, %xmm1
cvtsi2ss %r15d, %xmm1
movss 0x18(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0x14(%rsp), %xmm0
mulss 0x37d4(%rip), %xmm0     # 0x77d4
addss %xmm2, %xmm0
movq 0x60(%rsp), %rax
movss %xmm0, (%rax,%rbp,4)
addq $0x2, %rbp
addq $0x8, %r14
movq 0x8(%rsp), %rax
addq $0x2, %rax
movq 0x38(%rsp), %r9
cmpq %r9, %rbp
jb 0x3f69
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 0x28(%rsp), %rdi
jb 0x3f45
cmpq $0x3, %r9
movl $0x2, %eax
cmovaeq %r9, %rax
movq %rax, 0x18(%rsp)
movl $0x1, %r14d
leaq 0x380d(%rip), %r8       # 0x7880
movq %r14, %r15
incq %r14
movl %r14d, %r12d
andl $0x1, %r12d
cmpq %r9, %r12
je 0x413c
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 0x40cb
addss (%rdi,%rcx,4), %xmm0
incl %ebx
incq %rax
cmpq $0x4, %rax
jne 0x409b
leaq 0x30(%rsp), %rdi
movss %xmm0, 0x8(%rsp)
movss 0x36e5(%rip), %xmm0     # 0x77cc
movss 0x36e1(%rip), %xmm1     # 0x77d0
callq 0x5a84
leaq 0x3785(%rip), %r8       # 0x7880
movq 0x38(%rsp), %r9
movq 0x28(%rsp), %rdi
xorps %xmm1, %xmm1
cvtsi2ss %ebx, %xmm1
movss 0x8(%rsp), %xmm2
divss %xmm1, %xmm2
divss 0x14(%rsp), %xmm0
mulss 0x36b0(%rip), %xmm0     # 0x77d4
addss %xmm2, %xmm0
movss %xmm0, (%rbp,%r12,4)
addq $0x2, %r12
cmpq %r9, %r12
jb 0x4094
cmpq 0x18(%rsp), %r14
jne 0x4073
movq %rdi, %r13
cmpq $0x1001, %r9            # imm = 0x1001
movq 0x40(%rsp), %rbp
jb 0x3e99
movq 0x20(%rsp), %rax
leaq 0x5a00(%rax), %rbx
xorl %r14d, %r14d
movss 0x366d(%rip), %xmm1     # 0x77e0
xorps %xmm2, %xmm2
movsd 0x367a(%rip), %xmm3     # 0x77f8
movsd 0x367a(%rip), %xmm4     # 0x7800
movq %rdi, %r15
xorps %xmm5, %xmm5
cvtsi2ss %r14, %xmm5
divss 0x363f(%rip), %xmm5     # 0x77d8
addss 0x363b(%rip), %xmm5     # 0x77dc
mulss %xmm5, %xmm5
movq %rbx, %r12
xorl %r13d, %r13d
movss %xmm5, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %r13, %xmm0
movss (%r15,%r13,4), %xmm6
divss %xmm1, %xmm0
addss 0x3611(%rip), %xmm0     # 0x77dc
mulss %xmm0, %xmm0
addss %xmm5, %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jb 0x41e3
sqrtsd %xmm0, %xmm0
jmp 0x421a
movss %xmm6, 0x8(%rsp)
callq 0x1260
movss 0x8(%rsp), %xmm6
movss 0x18(%rsp), %xmm5
movsd 0x35fe(%rip), %xmm4     # 0x7800
movsd 0x35ee(%rip), %xmm3     # 0x77f8
xorps %xmm2, %xmm2
movss 0x35cb(%rip), %xmm1     # 0x77e0
movq 0x28(%rsp), %rdi
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvtsd2ss %xmm0, %xmm0
subss %xmm0, %xmm6
movss %xmm6, (%r12)
incq %r13
addq $0x900, %r12            # imm = 0x900
cmpq $0xe10, %r13            # imm = 0xE10
jne 0x41b1
incq %r14
addq $0x4004, %r15           # imm = 0x4004
addq $0x4, %rbx
cmpq $0x240, %r14            # imm = 0x240
jne 0x4189
callq 0x1030
movq %rbp, %rdi
callq 0x1030
xorl %ebx, %ebx
movss 0x356b(%rip), %xmm2     # 0x77e4
leaq 0x30(%rsp), %r14
movl $0x2e, %ebp
movq 0x20(%rsp), %r15
movq %r15, %r12
xorl %r13d, %r13d
xorpd %xmm4, %xmm4
movq %r12, %rax
xorl %ecx, %ecx
movl $0x5a00, %edx           # imm = 0x5A00
addss (%rax,%rdx), %xmm4
addq $0x900, %rdx            # imm = 0x900
cmpq $0x27600, %rdx          # imm = 0x27600
jne 0x429c
incq %rcx
addq $0x4, %rax
cmpq $0x18, %rcx
jne 0x4297
divss %xmm2, %xmm4
xorps %xmm0, %xmm0
movq %r12, %rax
xorl %ecx, %ecx
movl $0x5a00, %edx           # imm = 0x5A00
movaps %xmm4, %xmm1
subss (%rax,%rdx), %xmm1
mulss %xmm1, %xmm1
addss %xmm1, %xmm0
addq $0x900, %rdx            # imm = 0x900
cmpq $0x27600, %rdx          # imm = 0x27600
jne 0x42cf
incq %rcx
addq $0x4, %rax
cmpq $0x18, %rcx
jne 0x42ca
divss %xmm2, %xmm0
ucomiss 0x34e1(%rip), %xmm0     # 0x77e8
jb 0x430f
sqrtss %xmm0, %xmm0
jmp 0x4328
movss %xmm4, 0x8(%rsp)
callq 0x11a0
movss 0x8(%rsp), %xmm4
movss 0x34bc(%rip), %xmm2     # 0x77e4
xorps %xmm1, %xmm1
cvtss2sd %xmm4, %xmm1
movw $0x20, %ax
movsd 0x34cd(%rip), %xmm3     # 0x7808
ucomisd %xmm1, %xmm3
ja 0x43b8
movw $0x2248, %ax            # imm = 0x2248
movsd 0x34c3(%rip), %xmm3     # 0x7810
ucomisd %xmm1, %xmm3
ja 0x43b8
movw $0x3a, %ax
movss 0x347d(%rip), %xmm1     # 0x77dc
ucomiss %xmm4, %xmm1
ja 0x43b8
cvtss2sd %xmm0, %xmm0
movw $0x25b2, %ax            # imm = 0x25B2
ucomisd 0x34a4(%rip), %xmm0     # 0x7818
ja 0x43b8
movw $0x2229, %ax            # imm = 0x2229
ucomisd 0x349e(%rip), %xmm0     # 0x7820
ja 0x43b8
movq %r14, %rdi
movss 0x343d(%rip), %xmm0     # 0x77cc
movss 0x3439(%rip), %xmm1     # 0x77d0
callq 0x5a84
movss 0x3440(%rip), %xmm2     # 0x77e4
cvtss2sd %xmm0, %xmm0
ucomisd 0x3478(%rip), %xmm0     # 0x7828
movl $0x2663, %eax           # imm = 0x2663
cmoval %ebp, %eax
leaq (,%r13,2), %rcx
addq %r13, %rcx
shlq $0x7, %rcx
addq 0x20(%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 0x428e
incq %rbx
addq $0x60, %r15
cmpq $0x18, %rbx
jne 0x4288
movq 0x20(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq