// File: /workspace/github_c_makefile_star2_O2/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 0x1477(%rip), %rax      # 0x65bc
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 0x3de3
leaq 0x1449(%rip), %rdi      # 0x65d0
callq 0x2931
testq %rax, %rax
je 0x552b
movq %rax, %rbx
movq 0xf8(%rsp), %rax
movslq (%rax), %rbp
movl 0x4(%rax), %r14d
movl %r14d, %eax
imull %ebp, %eax
movslq %eax, %r12
shlq $0x2, %r12
movq %r12, %rdi
callq 0x2300
movq %rax, 0x48(%rsp)
movq %r12, %rdi
callq 0x2300
movq %rax, %r15
movq %r12, %rdi
callq 0x2300
movq %rax, %rsi
movl (%rbx), %r13d
movq %rbx, 0x68(%rsp)
movl 0x4(%rbx), %eax
pushq $-0x2
popq %rcx
movl %eax, 0x44(%rsp)
cvtsi2ss %eax, %xmm0
movl %ebp, %eax
cltd
idivl %ecx
movq %rax, 0x90(%rsp)
movl %r14d, %eax
cltd
idivl %ecx
movq %rax, 0x70(%rsp)
movss 0xe2b(%rip), %xmm1      # 0x6038
movss %xmm0, 0x54(%rsp)
mulss %xmm0, %xmm1
movss %xmm1, 0x5c(%rsp)
cvtsi2ss %r13d, %xmm0
movss 0xdda(%rip), %xmm1      # 0x6004
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
movq %rax, 0x30(%rsp)
movss %xmm0, 0x50(%rsp)
mulss %xmm0, %xmm1
movss %xmm1, 0x58(%rsp)
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
movq %r14, 0x80(%rsp)
shlq $0x2, %rbp
movq %rbp, 0x78(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rbp
movq %rsi, %r12
movq %rsi, %rbx
xorl %eax, %eax
cmpq 0x80(%rsp), %rax
je 0x536c
movq %rax, 0x88(%rsp)
movq 0x70(%rsp), %rcx
addl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x64(%rsp)
mulss %xmm0, %xmm0
movss %xmm0, 0x60(%rsp)
xorl %r14d, %r14d
cmpq %r14, 0x30(%rsp)
je 0x534c
movq 0x90(%rsp), %rax
addl %r14d, %eax
cvtsi2ss %eax, %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
addss 0x60(%rsp), %xmm0
sqrtss %xmm0, %xmm2
movss %xmm2, 0x38(%rsp)
movss 0x5c(%rsp), %xmm0
divss %xmm2, %xmm0
cvttss2si %xmm0, %rax
xorl %edx, %edx
divl 0x44(%rsp)
movq 0x28(%rsp), %rax
movl %edx, (%rax,%r14,4)
movss 0x64(%rsp), %xmm0
callq 0x2320
mulss 0x58(%rsp), %xmm0
divss 0xd19(%rip), %xmm0      # 0x6030
cvttss2si %xmm0, %rax
movl %eax, (%r15,%r14,4)
movss 0x38(%rsp), %xmm1
addss 0xd0e(%rip), %xmm1      # 0x603c
movss 0xcd6(%rip), %xmm0      # 0x600c
minss %xmm0, %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rbx,%r14,4)
incq %r14
jmp 0x52af
movq 0x88(%rsp), %rax
incq %rax
movq 0x78(%rsp), %rcx
addq %rcx, %rbx
addq %rcx, %r15
addq %rcx, 0x28(%rsp)
jmp 0x527b
leaq 0xc0(%rsp), %r14
movl $0xff, %ebx
movq %r14, %rdi
callq 0x4878
testb %al, %al
je 0x54f6
movq 0xf8(%rsp), %r14
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x28(%rsp)
movslq (%r14), %rax
movq %rax, 0x30(%rsp)
movl 0x4(%r14), %eax
movq %rax, 0x38(%rsp)
mulss 0x50(%rsp), %xmm0
mulss 0xc45(%rip), %xmm0      # 0x6004
callq 0x20a0
cvttss2si %xmm0, %r15d
movss 0x28(%rsp), %xmm0
mulss 0x54(%rsp), %xmm0
mulss 0xc63(%rip), %xmm0      # 0x6040
callq 0x20a0
cvttss2si %xmm0, %esi
movq 0x30(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rdx
testl %edx, %edx
movl $0x0, %eax
cmovlel %eax, %edx
movq %rdx, 0x38(%rsp)
shlq $0x2, %rcx
movq %rcx, 0x30(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq 0x38(%rsp), %r9
je 0x54e1
movq 0x28(%rsp), %r10
movq %r8, %r11
subq $0x1, %r10
jb 0x54d4
movq 0x48(%rsp), %rax
movl (%rax,%r11), %eax
addl %r15d, %eax
xorl %edx, %edx
divl %r13d
movl %edx, %ecx
movl (%rbp,%r11), %eax
addl %esi, %eax
xorl %edx, %edx
divl 0x44(%rsp)
imull %r13d, %edx
addl %ecx, %edx
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %ecx
shrl $0x8, %ecx
movl %eax, %edx
shrl $0x10, %edx
andl %ebx, %edx
cvtsi2ss %edx, %xmm0
movss (%r12,%r11), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
andl %ebx, %ecx
cvtsi2ss %ecx, %xmm0
movl %eax, %ecx
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
andl %ebx, %eax
cvtsi2ss %eax, %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
andl $0xff000000, %ecx       # imm = 0xFF000000
andl %ebx, %edx
shll $0x10, %edx
orl %ecx, %edx
andl %ebx, %edi
shll $0x8, %edi
orl %edx, %edi
andl %ebx, %eax
orl %edi, %eax
movq 0x10(%r14), %rcx
movl %eax, (%rcx,%r11)
addq $0x4, %r11
jmp 0x5430
incq %r9
addq 0x30(%rsp), %r8
jmp 0x541d
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0x493f
jmp 0x5379
movq %r12, %rdi
callq 0x22a0
movq %rbp, %rdi
callq 0x22a0
movq 0x48(%rsp), %rdi
callq 0x22a0
movq 0x68(%rsp), %rdi
callq 0x3bd8
leaq 0xc0(%rsp), %rdi
callq 0x4c17
xorl %eax, %eax
jmp 0x552e
pushq $-0x1
popq %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq