// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]scg/examples/starfield_3d.c
// Function: init
static void init(starfield_t *starfield, scg_app_t *app, int num_stars,
                 float32_t max_distance, float32_t world_speed) {
    int w = app->draw_target->width;
    int h = app->draw_target->height;

    float32_t horizontal_fov = 100.0f * SCG_PI / 180.0f;
    float32_t vertical_fov = 80.0f * SCG_PI / 180.0f;

    starfield->num_stars = num_stars;
    starfield->star_size = 1;
    starfield->max_distance = max_distance;
    starfield->world_speed = world_speed;
    starfield->horizontal_view_distance =
        (float32_t)(w / 2.0f) / tanf(horizontal_fov / 2.0f);
    starfield->vertical_view_distance =
        (float32_t)(h / 2.0f) / tanf(vertical_fov / 2.0f);
    starfield->stars = malloc(num_stars * sizeof(star_t));

    for (int i = 0; i < num_stars; i++) {
        star_t *current = &starfield->stars[i];
        bool is_super_fast = i % num_stars == 1;

        current->x = (float32_t)(rand() % w) - (float32_t)w / 2.0f;
        current->y = (float32_t)h / 2.0f - (float32_t)(rand() % h);
        current->z = (float32_t)(rand() % (int)max_distance);
        current->is_super_fast = is_super_fast;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movss %xmm0, -0x18(%rbp)
movss %xmm1, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
movss 0x1804(%rip), %xmm0     # 0x8044
movss %xmm0, -0x28(%rbp)
movss 0x17f3(%rip), %xmm0     # 0x8040
movss %xmm0, -0x2c(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0x10(%rax)
movss -0x18(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x14(%rax)
movss -0x1c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x18(%rax)
cvtsi2ssl -0x20(%rbp), %xmm0
movss 0x1781(%rip), %xmm1     # 0x8010
divss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x28(%rbp), %xmm0
movss 0x176b(%rip), %xmm1     # 0x8010
divss %xmm1, %xmm0
callq 0x2350
movaps %xmm0, %xmm1
movss -0x44(%rbp), %xmm0
divss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x1c(%rax)
cvtsi2ssl -0x24(%rbp), %xmm0
movss 0x1740(%rip), %xmm1     # 0x8010
divss %xmm1, %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x2c(%rbp), %xmm0
movss 0x172a(%rip), %xmm1     # 0x8010
divss %xmm1, %xmm0
callq 0x2350
movaps %xmm0, %xmm1
movss -0x40(%rbp), %xmm0
divss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x20(%rax)
movslq -0x14(%rbp), %rdi
shlq $0x4, %rdi
callq 0x2310
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x69ec
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
cltd
idivl -0x14(%rbp)
cmpl $0x1, %edx
sete %al
andb $0x1, %al
movb %al, -0x39(%rbp)
callq 0x2080
cltd
idivl -0x20(%rbp)
cvtsi2ss %edx, %xmm0
cvtsi2ssl -0x20(%rbp), %xmm1
movss 0x169e(%rip), %xmm2     # 0x8010
divss %xmm2, %xmm1
subss %xmm1, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, (%rax)
cvtsi2ssl -0x24(%rbp), %xmm0
movss 0x1681(%rip), %xmm1     # 0x8010
divss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
callq 0x2080
movss -0x48(%rbp), %xmm0
cltd
idivl -0x24(%rbp)
cvtsi2ss %edx, %xmm1
subss %xmm1, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x4(%rax)
callq 0x2080
cvttss2si -0x18(%rbp), %ecx
cltd
idivl %ecx
cvtsi2ss %edx, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x8(%rax)
movb -0x39(%rbp), %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, 0xc(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6923
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)