// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/map.c
// Function: diamond_square
void diamond_square(float *heightmap, int dim, float sigma, int level) {
    if (level < 1) return;

    // diamonds
    for (int i = level; i < dim; i += level) {
        for (int j = level; j < dim; j += level) {
            float a = heightmap[(i-level)*dim + j-level];
            float b = heightmap[i*dim + j-level];
            float c = heightmap[(i-level)*dim + j];
            float d = heightmap[i*dim+j];
            heightmap[(i-level/2)*dim + j-level/2] = (a + b + c + d) / 4 + (float)gaussrand() * sigma;
        }
    }
    // squares
    for (int i = 2 * level; i < dim; i += level) {
        for (int j = 2 * level; j < dim; j += level) {
            float a = heightmap[(i-level)*dim + j-level];
            float b = heightmap[i*dim + j-level];
            float c = heightmap[(i-level)*dim + j];
            float e = heightmap[(i-level/2)*dim + j-level/2];

            heightmap[(i-level)*dim + (j-level/2)] = (a + c + e + heightmap[(i-3*level/2)*dim + (j-level/2)]) / 4 + (float)gaussrand() * sigma;
            heightmap[(i-level/2)*dim + j-level] = (a + b + e + heightmap[(i-level/2)*dim + (j-3*level/2)]) / 4 + (float)gaussrand() * sigma;
        }
    }
    diamond_square(heightmap, dim, sigma / 2, level / 2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movss %xmm0, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jge 0xdbc5
jmp 0xdf87
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdcf9
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdce9
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
subl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
subl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x20(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
addss -0x28(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss 0x103d3(%rip), %xmm1    # 0x1e050
divss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
callq 0x181e0
movss -0x54(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
movss -0x10(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x18(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
imull -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0x50(%rbp), %rax
subl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0xdbdd
jmp 0xdceb
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0xdbcb
movl -0x14(%rbp), %eax
shll %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdf5d
movl -0x14(%rbp), %eax
shll %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdf4d
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
subl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
subl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x30(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
imull -0xc(%rbp), %ecx
addl -0x34(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0xa0(%rbp), %rax
subl %edx, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x38(%rbp), %xmm0
addss -0x40(%rbp), %xmm0
addss -0x44(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x30(%rbp), %ecx
imull $0x3, -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
imull -0xc(%rbp), %ecx
movl -0x34(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl -0x94(%rbp), %edx
movl %eax, %esi
movq -0x90(%rbp), %rax
subl %esi, %edx
addl %edx, %ecx
movslq %ecx, %rcx
addss (%rax,%rcx,4), %xmm0
movss 0x10227(%rip), %xmm1    # 0x1e050
divss %xmm1, %xmm0
movss %xmm0, -0x88(%rbp)
callq 0x181e0
movss -0x88(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
movss -0x10(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x30(%rbp), %ecx
subl -0x14(%rbp), %ecx
imull -0xc(%rbp), %ecx
movl -0x34(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl -0x84(%rbp), %edx
movl %eax, %esi
movq -0x80(%rbp), %rax
subl %esi, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movss -0x38(%rbp), %xmm0
addss -0x3c(%rbp), %xmm0
addss -0x44(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x30(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
imull -0xc(%rbp), %ecx
movl -0x34(%rbp), %eax
movl %eax, -0x74(%rbp)
imull $0x3, -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl -0x74(%rbp), %edx
movl %eax, %esi
movq -0x70(%rbp), %rax
subl %esi, %edx
addl %edx, %ecx
movslq %ecx, %rcx
addss (%rax,%rcx,4), %xmm0
movss 0x10165(%rip), %xmm1    # 0x1e050
divss %xmm1, %xmm0
movss %xmm0, -0x64(%rbp)
callq 0x181e0
movss -0x64(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
movss -0x10(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x30(%rbp), %ecx
movl -0x14(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0x60(%rbp), %rax
subl %edx, %ecx
imull -0xc(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0xdd15
jmp 0xdf4f
movl -0x14(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xdd01
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movss -0x10(%rbp), %xmm0
movss 0x100db(%rip), %xmm1    # 0x1e04c
divss %xmm1, %xmm0
movl -0x14(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
callq 0xdba0
addq $0xa0, %rsp
popq %rbp
retq