// File: /workspace/github_c_makefile_star2_O3/adelciotto[P]scg/examples/tunnel.c
// Function: main
int main(int arcg, char *argv[]) {
    scg_config_t config = scg_config_new_default();
    config.video.title = "SCG Example: Tunnel";

    scg_app_t app;
    scg_app_init(&app, config);

    scg_image_t *image = scg_image_new_from_bmp("assets/space.bmp");
    if (image == NULL) {
        return -1;
    }

    tunnel_t tunnel;
    init(&app, &tunnel, image);

    while (scg_app_process_events(&app)) {
        draw(app.draw_target, &tunnel, app.elapsed_time);

        scg_app_present(&app);
    }

    free(tunnel.shade_buffer);
    free(tunnel.angle_buffer);
    free(tunnel.distance_buffer);

    scg_image_free(image);
    scg_app_free(&app);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movabsq $0x1e000000280, %rax    # imm = 0x1E000000280
movq %rax, 0x98(%rsp)
movl $0x1, 0xa8(%rsp)
xorl %eax, %eax
movb %al, 0xac(%rsp)
movl $0x1010101, 0xad(%rsp) # imm = 0x1010101
movb %al, 0xb4(%rsp)
movl $0x40, 0xb8(%rsp)
leaq 0x1045(%rip), %rax      # 0x65ec
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0x98(%rsp), %xmm0
movups 0xa8(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x3f8d
leaq 0x1017(%rip), %rdi      # 0x6600
callq 0x2945
testq %rax, %rax
je 0x59ff
movq %rax, %rbx
movq 0xf8(%rsp), %rax
movl (%rax), %r14d
movslq 0x4(%rax), %r15
movl %r15d, %eax
imull %r14d, %eax
movslq %eax, %r12
shlq $0x2, %r12
movq %r12, %rdi
callq 0x2300
movq %rax, 0x60(%rsp)
movq %r12, %rdi
callq 0x2300
movq %rax, 0x58(%rsp)
movq %r12, %rdi
callq 0x2300
movq %rax, 0x50(%rsp)
movq %rbx, 0x40(%rsp)
movl 0x4(%rbx), %ebp
movq %r15, 0x88(%rsp)
testq %r15, %r15
jle 0x57de
movq %r14, %rcx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
negl %edx
movq 0x88(%rsp), %rax
cvtsi2ss %ebp, %xmm2
shrl %eax
movl %eax, 0x84(%rsp)
movq 0x40(%rsp), %rax
xorps %xmm1, %xmm1
cvtsi2ssl (%rax), %xmm1
mulss 0x9aa(%rip), %xmm2      # 0x6038
mulss 0x96e(%rip), %xmm1      # 0x6004
leaq (,%r14,4), %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x60(%rsp), %r13
movq 0x58(%rsp), %r12
movq 0x50(%rsp), %r9
movss %xmm2, 0x70(%rsp)
movss %xmm1, 0x48(%rsp)
movq %rdx, 0x68(%rsp)
testl %ecx, %ecx
jle 0x57b2
movq 0x30(%rsp), %rax
subl 0x84(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x28(%rsp)
mulss %xmm0, %xmm0
movss %xmm0, 0x78(%rsp)
xorl %r14d, %r14d
leal (%rdx,%r14), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
addss 0x78(%rsp), %xmm0
xorps %xmm3, %xmm3
sqrtss %xmm0, %xmm3
movss %xmm3, 0x38(%rsp)
movaps %xmm2, %xmm0
divss %xmm3, %xmm0
cvttss2si %xmm0, %rax
xorl %edx, %edx
divl %ebp
movl %edx, (%r13,%r14,4)
movss 0x28(%rsp), %xmm0
movq %rcx, %rbx
movl %ebp, %r15d
movq %r9, %rbp
callq 0x2320
movq %rbp, %r9
movl %r15d, %ebp
movss 0x8d7(%rip), %xmm3      # 0x6030
movss 0x48(%rsp), %xmm1
movss 0x70(%rsp), %xmm2
movq 0x68(%rsp), %rdx
movq %rbx, %rcx
mulss %xmm1, %xmm0
divss %xmm3, %xmm0
cvttss2si %xmm0, %rax
movss 0x8ba(%rip), %xmm0      # 0x603c
movl %eax, (%r12,%r14,4)
movss 0x38(%rsp), %xmm3
addss %xmm0, %xmm3
movss 0x874(%rip), %xmm0      # 0x600c
minss %xmm0, %xmm3
divss %xmm0, %xmm3
movss %xmm3, (%r9,%r14,4)
incq %r14
cmpq %r14, %rbx
jne 0x56fd
movq 0x30(%rsp), %rsi
incq %rsi
movq 0x90(%rsp), %rax
addq %rax, %r9
addq %rax, %r12
addq %rax, %r13
movq %rsi, 0x30(%rsp)
cmpq 0x88(%rsp), %rsi
jne 0x56cf
leaq 0xc0(%rsp), %rdi
callq 0x4a66
testb %al, %al
je 0x59ba
movq 0x40(%rsp), %rax
movl (%rax), %r14d
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x68(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss %xmm0, 0x30(%rsp)
movl $0xff, %r15d
movq 0xf8(%rsp), %rax
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x38(%rsp)
movq %rax, 0x48(%rsp)
movslq 0x4(%rax), %rbx
mulss 0x68(%rsp), %xmm0
mulss 0x7ba(%rip), %xmm0      # 0x6004
callq 0x20a0
movss %xmm0, 0x28(%rsp)
movss 0x38(%rsp), %xmm0
mulss 0x30(%rsp), %xmm0
mulss 0x7d7(%rip), %xmm0      # 0x6040
callq 0x20a0
movq %rbx, 0x78(%rsp)
testq %rbx, %rbx
jle 0x599a
cvttss2si 0x28(%rsp), %esi
cvttss2si %xmm0, %edi
movq 0x48(%rsp), %rax
movl (%rax), %r8d
leaq (,%r8,4), %rax
movq %rax, 0x70(%rsp)
movq 0x60(%rsp), %r10
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %rbx
movq $0x0, 0x28(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x38(%rsp)
testl %r8d, %r8d
jle 0x5974
movq 0x40(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x48(%rsp), %rax
movq 0x10(%rax), %r12
addq 0x28(%rsp), %r12
xorl %r13d, %r13d
movl (%r10,%r13,4), %eax
addl %esi, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %ecx
movl (%r11,%r13,4), %eax
addl %edi, %eax
xorl %edx, %edx
divl %ebp
imull %r14d, %edx
addl %ecx, %edx
movslq %edx, %rax
movl (%r9,%rax,4), %eax
movl %eax, %ecx
shrl $0x8, %ecx
movl %eax, %edx
shrl $0x10, %edx
andl %r15d, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movl %eax, %edx
andl %r15d, %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
movss (%rbx,%r13,4), %xmm2
mulss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
andl %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss %xmm2, %xmm1
cvttss2si %xmm1, %eax
andl $0xff000000, %edx       # imm = 0xFF000000
andl %r15d, %ecx
shll $0x10, %ecx
orl %edx, %ecx
mulss %xmm2, %xmm0
andl %r15d, %eax
shll $0x8, %eax
orl %ecx, %eax
cvttss2si %xmm0, %ecx
andl %r15d, %ecx
orl %eax, %ecx
movl %ecx, (%r12,%r13,4)
incq %r13
cmpq %r13, %r8
jne 0x58dd
movq 0x38(%rsp), %rcx
incq %rcx
movq 0x70(%rsp), %rax
addq %rax, 0x28(%rsp)
addq %rax, %rbx
addq %rax, %r11
addq %rax, %r10
cmpq 0x78(%rsp), %rcx
jne 0x58b5
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x4b8f
movq %rbx, %rdi
callq 0x4a66
testb %al, %al
jne 0x581c
movq 0x50(%rsp), %rdi
callq 0x22a0
movq 0x58(%rsp), %rdi
callq 0x22a0
movq 0x60(%rsp), %rdi
callq 0x22a0
movq 0x40(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x22a0
leaq 0xc0(%rsp), %rdi
callq 0x5062
xorl %eax, %eax
jmp 0x5a04
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq