// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl $0x7eea00, %edi         # imm = 0x7EEA00
callq 0x11c0
movq %rax, -0x10(%rbp)
movq $0x4008004, -0x18(%rbp) # imm = 0x4008004
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x1170
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x1170
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x546c
leaq -0x8(%rbp), %rdi
movss 0x4509(%rip), %xmm0     # 0x9950
movss 0x4505(%rip), %xmm1     # 0x9954
callq 0x8490
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5435
movq $0x3, -0x40(%rbp)
cmpq $0x1001, -0x40(%rbp)    # imm = 0x1001
jae 0x54b1
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x8(%rbp), %rcx
callq 0x5690
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x5474
movq $0x0, -0x48(%rbp)
cmpq $0x240, -0x48(%rbp)     # imm = 0x240
jae 0x5658
movq $0x0, -0x50(%rbp)
cmpq $0xe10, -0x50(%rbp)     # imm = 0xE10
jae 0x5645
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
shlq $0xc, %rdx
addq %rdx, %rcx
movq -0x50(%rbp), %rdx
addq %rdx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x50(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x68(%rbp)
testq %rax, %rax
movss %xmm0, -0x64(%rbp)
js 0x5539
movss -0x68(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x64(%rbp), %xmm0
movss 0x4406(%rip), %xmm1     # 0x994c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x43a2(%rip), %xmm1     # 0x98f8
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x70(%rbp)
testq %rax, %rax
movss %xmm0, -0x6c(%rbp)
js 0x559c
movss -0x70(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movss -0x6c(%rbp), %xmm0
movss 0x439f(%rip), %xmm1     # 0x9948
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4337(%rip), %xmm1     # 0x98f0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0x58(%rbp), %xmm0
movss -0x58(%rbp), %xmm2
movss -0x5c(%rbp), %xmm1
mulss -0x5c(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1270
movsd 0x42ed(%rip), %xmm1     # 0x98e0
mulsd %xmm1, %xmm0
movsd 0x42e9(%rip), %xmm1     # 0x98e8
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x54(%rbp), %xmm0
subss -0x60(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x5a00, %rax           # imm = 0x5A00
imulq $0x900, -0x50(%rbp), %rcx # imm = 0x900
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x54cf
jmp 0x5647
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x54b9
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x10(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x5b50
movq -0x10(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)