// File: /workspace/github_c_makefile_star2_O1/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 0x104c(%rip), %rax      # 0x65ac
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 0x3eb1
leaq 0x101e(%rip), %rdi      # 0x65c0
callq 0x2955
testq %rax, %rax
je 0x59ba
movq %rax, %rbx
movq 0xf8(%rsp), %rax
movl (%rax), %ecx
movslq 0x4(%rax), %r14
movl %r14d, %eax
movq %rcx, 0x28(%rsp)
imull %ecx, %eax
movslq %eax, %r12
shlq $0x2, %r12
movq %r12, %rdi
callq 0x2300
movq %rax, 0x68(%rsp)
movq %r12, %rdi
callq 0x2300
movq %rax, 0x60(%rsp)
movq %r12, %rdi
callq 0x2300
movq %rax, 0x58(%rsp)
movq %rbx, 0x48(%rsp)
movl 0x4(%rbx), %ebp
movq %r14, 0x88(%rsp)
testq %r14, %r14
jle 0x5799
movq 0x28(%rsp), %rcx
movl %ecx, %r12d
shrl $0x1f, %r12d
addl %ecx, %r12d
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
sarl %r12d
negl %r12d
mulss 0xa01(%rip), %xmm0      # 0x6038
movss %xmm0, 0x50(%rsp)
movq 0x88(%rsp), %rax
movl %eax, %edx
movq 0x48(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2ssl (%rax), %xmm0
shrl %edx
movl %edx, 0x84(%rsp)
mulss 0x9a0(%rip), %xmm0      # 0x6004
movss %xmm0, 0x3c(%rsp)
leaq (,%rcx,4), %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x68(%rsp), %r15
movq 0x60(%rsp), %r13
movq 0x58(%rsp), %rbx
cmpl $0x0, 0x28(%rsp)
jle 0x576d
movq 0x40(%rsp), %rax
subl 0x84(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x78(%rsp)
mulss %xmm0, %xmm0
movss %xmm0, 0x70(%rsp)
xorl %r14d, %r14d
leal (%r12,%r14), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
addss 0x70(%rsp), %xmm0
ucomiss 0x962(%rip), %xmm0      # 0x6044
jb 0x56ea
sqrtss %xmm0, %xmm0
jmp 0x56fb
movss %xmm1, 0x30(%rsp)
callq 0x23c0
movss 0x30(%rsp), %xmm1
movss %xmm0, 0x30(%rsp)
movss 0x50(%rsp), %xmm2
divss %xmm0, %xmm2
cvttss2si %xmm2, %rax
xorl %edx, %edx
divl %ebp
movl %edx, (%r15,%r14,4)
movss 0x78(%rsp), %xmm0
callq 0x2320
mulss 0x3c(%rsp), %xmm0
divss 0x8ff(%rip), %xmm0      # 0x6030
cvttss2si %xmm0, %rax
movl %eax, (%r13,%r14,4)
movss 0x30(%rsp), %xmm1
addss 0x8f3(%rip), %xmm1      # 0x603c
movss 0x8bb(%rip), %xmm0      # 0x600c
minss %xmm0, %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rbx,%r14,4)
incq %r14
cmpq %r14, 0x28(%rsp)
jne 0x56c3
movq 0x40(%rsp), %rcx
incq %rcx
movq 0x90(%rsp), %rax
addq %rax, %rbx
addq %rax, %r13
addq %rax, %r15
movq %rcx, 0x40(%rsp)
cmpq 0x88(%rsp), %rcx
jne 0x5692
leaq 0xc0(%rsp), %rdi
callq 0x4a0c
testb %al, %al
je 0x5975
movq 0x48(%rsp), %rax
movl (%rax), %r14d
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x3c(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss %xmm0, 0x40(%rsp)
movl $0xff, %r15d
movq 0xf8(%rsp), %rax
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x30(%rsp)
movq %rax, 0x50(%rsp)
movslq 0x4(%rax), %rbx
mulss 0x3c(%rsp), %xmm0
mulss 0x7ff(%rip), %xmm0      # 0x6004
callq 0x20a0
movss %xmm0, 0x28(%rsp)
movss 0x30(%rsp), %xmm0
mulss 0x40(%rsp), %xmm0
mulss 0x81c(%rip), %xmm0      # 0x6040
callq 0x20a0
movq %rbx, 0x78(%rsp)
testq %rbx, %rbx
jle 0x5955
cvttss2si 0x28(%rsp), %esi
cvttss2si %xmm0, %edi
movq 0x50(%rsp), %rax
movl (%rax), %r8d
leaq (,%r8,4), %rax
movq %rax, 0x70(%rsp)
movq 0x68(%rsp), %r10
movq 0x60(%rsp), %r11
movq 0x58(%rsp), %rbx
movq $0x0, 0x28(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
testl %r8d, %r8d
jle 0x592f
movq 0x48(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x50(%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 0x5898
movq 0x30(%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 0x5870
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x4b58
movq %rbx, %rdi
callq 0x4a0c
testb %al, %al
jne 0x57d7
movq 0x58(%rsp), %rdi
callq 0x22a0
movq 0x60(%rsp), %rdi
callq 0x22a0
movq 0x68(%rsp), %rdi
callq 0x22a0
movq 0x48(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x22a0
leaq 0xc0(%rsp), %rdi
callq 0x5027
xorl %eax, %eax
jmp 0x59bf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq