// File: /workspace/github_c_makefile_star2_O0/skeeto[P]goblin-com/src/map.c
// Function: grow
static size_t
grow(const float *map, size_t size, float *out, uint64_t *seed)
{
    size_t osize = (size - 1) * 2 + 1;
    /* Copy */
    for (size_t y = 0; y < size; y++) {
        for (size_t x = 0; x < size; x++) {
            out[y * 2 * osize + x * 2] = map[y * size + x];
        }
    }
    /* Diamond */
    for (size_t y = 1; y < osize; y += 2) {
        for (size_t x = 1; x < osize; x += 2) {
            int count = 0;
            float sum = 0;
            for (int dy = -1; dy <= 1; dy += 2) {
                for (int dx = -1; dx <= 1; dx += 2) {
                    long i = (y + dy) * osize + (x + dx);
                    if (i >= 0 && (size_t)i < osize * osize) {
                        sum += out[i];
                        count++;
                    }
                }
            }
            float u = rand_uniform_s(seed, -1, 1);
            out[y * osize + x] = sum / count + u / osize * NOISE_SCALE;
        }
    }
    /* Square */
    struct {
        int x, y;
    } pos[] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    for (size_t y = 1; y < osize; y++) {
        for (size_t x = (y + 1) % 2; x < osize; x += 2) {
            int count = 0;
            float sum = 0;
            for (int p = 0; p < 4; p++) {
                long i = (y + pos[p].y) * osize + (x + pos[p].x);
                if (i >= 0 && (size_t)i < osize * osize) {
                    sum += out[i];
                    count++;
                }
            }
            float u = rand_uniform_s(seed, -1, 1);
            out[y * osize + x] = sum / count + u / osize  * NOISE_SCALE;
        }
    }
    return osize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
shlq %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x5735
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x5725
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
imulq -0x10(%rbp), %rcx
addq -0x38(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
imulq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq %rdx
addq %rdx, %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x56d8
jmp 0x5727
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x56c6
movq $0x1, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x58f2
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x58df
movl $0x0, -0x4c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
cmpl $0x1, -0x54(%rbp)
jg 0x5806
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
cmpl $0x1, -0x58(%rbp)
jg 0x57f6
movq -0x40(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
imulq -0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0x58(%rbp), %rdx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jl 0x57e9
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
imulq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jae 0x57e9
movq -0x18(%rbp), %rax
movq -0x60(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x50(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x57eb
movl -0x58(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x58(%rbp)
jmp 0x5788
jmp 0x57f8
movl -0x54(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x54(%rbp)
jmp 0x5777
movq -0x20(%rbp), %rdi
movss 0x413e(%rip), %xmm0     # 0x9950
movss 0x413a(%rip), %xmm1     # 0x9954
callq 0x8490
movss %xmm0, -0x64(%rbp)
movss -0x50(%rbp), %xmm0
cvtsi2ssl -0x4c(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xcc(%rbp)
movss -0x64(%rbp), %xmm0
movss %xmm0, -0xc8(%rbp)
movq -0x28(%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, -0xc4(%rbp)
testq %rax, %rax
movss %xmm0, -0xc0(%rbp)
js 0x588c
movss -0xc4(%rbp), %xmm0
movss %xmm0, -0xc0(%rbp)
movss -0xcc(%rbp), %xmm1
movss -0xc8(%rbp), %xmm0
movss -0xc0(%rbp), %xmm2
divss %xmm2, %xmm0
movss 0x40a8(%rip), %xmm2     # 0x9958
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
imulq -0x28(%rbp), %rcx
addq -0x48(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
jmp 0x5753
jmp 0x58e1
movq -0x40(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
jmp 0x573d
movq 0x4097(%rip), %rax      # 0x9990
movq %rax, -0x90(%rbp)
movq 0x4091(%rip), %rax      # 0x9998
movq %rax, -0x88(%rbp)
movq 0x408b(%rip), %rax      # 0x99a0
movq %rax, -0x80(%rbp)
movq 0x4088(%rip), %rax      # 0x99a8
movq %rax, -0x78(%rbp)
movq $0x1, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x5b42
movq -0x98(%rbp), %rax
addq $0x1, %rax
andq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x5b29
movl $0x0, -0xa4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
cmpl $0x4, -0xac(%rbp)
jge 0x5a38
movq -0x98(%rbp), %rax
movslq -0xac(%rbp), %rcx
movslq -0x8c(%rbp,%rcx,8), %rcx
addq %rcx, %rax
imulq -0x28(%rbp), %rax
movq -0xa0(%rbp), %rcx
movslq -0xac(%rbp), %rdx
movslq -0x90(%rbp,%rdx,8), %rdx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
jl 0x5a22
movq -0xb8(%rbp), %rax
movq -0x28(%rbp), %rcx
imulq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jae 0x5a22
movq -0x18(%rbp), %rax
movq -0xb8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0xa8(%rbp), %xmm0
movss %xmm0, -0xa8(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x5a24
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x5986
movq -0x20(%rbp), %rdi
movss 0x3f0c(%rip), %xmm0     # 0x9950
movss 0x3f08(%rip), %xmm1     # 0x9954
callq 0x8490
movss %xmm0, -0xbc(%rbp)
movss -0xa8(%rbp), %xmm0
cvtsi2ssl -0xa4(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xdc(%rbp)
movss -0xbc(%rbp), %xmm0
movss %xmm0, -0xd8(%rbp)
movq -0x28(%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, -0xd4(%rbp)
testq %rax, %rax
movss %xmm0, -0xd0(%rbp)
js 0x5aca
movss -0xd4(%rbp), %xmm0
movss %xmm0, -0xd0(%rbp)
movss -0xdc(%rbp), %xmm1
movss -0xd8(%rbp), %xmm0
movss -0xd0(%rbp), %xmm2
divss %xmm2, %xmm0
movss 0x3e6a(%rip), %xmm2     # 0x9958
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x18(%rbp), %rax
movq -0x98(%rbp), %rcx
imulq -0x28(%rbp), %rcx
addq -0xa0(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0xa0(%rbp), %rax
addq $0x2, %rax
movq %rax, -0xa0(%rbp)
jmp 0x5956
jmp 0x5b2b
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x592f
movq -0x28(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nop