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

    scg_app_t app;
    scg_app_init(&app, config);

    const float32_t start_x = 10.0f;
    const float32_t end_x = app.draw_target->width - 64.0f;
    const float32_t duration = 3.0f;
    const bool loop = true;
    const bool yoyo = true;

    tween_example_t tween_examples[NUM_TWEENS] = {
        (tween_example_t){scg_tween_new(scg_tween_definition_new(
                              (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                              scg_tween_linear, duration, loop, yoyo)),
                          "Linear", SCG_COLOR_BLACK},
        (tween_example_t){
            scg_tween_new(scg_tween_definition_new(
                (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                scg_tween_exponential_ease_in, duration, loop, yoyo)),
            "Exponential Ease-In", SCG_COLOR_RED},
        (tween_example_t){
            scg_tween_new(scg_tween_definition_new(
                (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                scg_tween_exponential_ease_out, duration, loop, yoyo)),
            "Exponential Ease-Out", SCG_COLOR_GREEN},
        (tween_example_t){
            scg_tween_new(scg_tween_definition_new(
                (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                scg_tween_exponential_ease_in_out, duration, loop, yoyo)),
            "Exponential Ease-In-Out", SCG_COLOR_BLUE},
        (tween_example_t){scg_tween_new(scg_tween_definition_new(
                              (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                              scg_tween_elastic_ease_in, duration, loop, yoyo)),
                          "Elastic Ease-In", SCG_COLOR_BROWN},
        (tween_example_t){
            scg_tween_new(scg_tween_definition_new(
                (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                scg_tween_elastic_ease_out, duration, loop, yoyo)),
            "Elastic Ease-Out", SCG_COLOR_MAGENTA},
        (tween_example_t){
            scg_tween_new(scg_tween_definition_new(
                (scg_vec2f_t[]){scg_vec2f_new(start_x, end_x)}, 1,
                scg_tween_elastic_ease_in_out, duration, loop, yoyo)),
            "Elastic Ease-In-Out", SCG_COLOR_95_GREEN}};

    for (int i = 0; i < NUM_TWEENS; i++) {
        scg_tween_start(&tween_examples[i].tween, app.elapsed_time);
    }
    bool paused = false;

    while (scg_app_process_events(&app)) {
        if (scg_keyboard_is_key_triggered(app.keyboard, SCG_KEY_P)) {
            for (int i = 0; i < NUM_TWEENS; i++) {
                if (paused) {
                    scg_tween_resume(&tween_examples[i].tween,
                                     app.elapsed_time);
                } else {
                    for (int i = 0; i < NUM_TWEENS; i++) {
                        scg_tween_pause(&tween_examples[i].tween,
                                        app.elapsed_time);
                    }
                }
            }
            paused = !paused;
        }

        scg_image_clear(app.draw_target, SCG_COLOR_WHITE);

        const int window_size = (app.draw_target->height - 16) / NUM_TWEENS;
        int current_y = 16;
        float32_t values[1];

        for (int i = 0; i < NUM_TWEENS; i++) {
            tween_example_t *example = &tween_examples[i];

            scg_tween_update(&example->tween, values, app.elapsed_time);

            scg_image_fill_rect(app.draw_target, values[0],
                                current_y - 14 + window_size / 2, 32, 32,
                                example->color);
            scg_image_draw_string(app.draw_target, example->name, 10, current_y,
                                  false, example->color);
            scg_image_draw_line(app.draw_target, 0, current_y + 12,
                                app.draw_target->width, current_y + 12,
                                example->color);
            current_y += window_size;
        }

        const char *str = paused ? "Press P to resume" : "Press P to pause";
        int w = strlen(str) * SCG_FONT_SIZE;
        scg_image_draw_string(app.draw_target, str,
                              app.draw_target->width - w - 10, 10, false,
                              SCG_COLOR_BLACK);

        scg_app_present(&app);
    }

    scg_app_free(&app);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movabsq $0x1e000000280, %rax    # imm = 0x1E000000280
movq %rax, 0x68(%rsp)
movl $0x1, 0x78(%rsp)
xorl %ebp, %ebp
movb %bpl, 0x7c(%rsp)
movl $0x1000101, 0x7d(%rsp)  # imm = 0x1000101
movb %bpl, 0x84(%rsp)
movl $0x40, 0x88(%rsp)
leaq 0x105f(%rip), %rax      # 0x65dc
movq %rax, 0x70(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0x68(%rsp), %xmm0
movups 0x78(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x2c0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3f6d
movq 0x38(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2ssl (%rax), %xmm0
addss 0xa73(%rip), %xmm0      # 0x6038
movl $0x41200000, %eax       # imm = 0x41200000
leaq 0x2b8(%rsp), %rcx
movl %eax, (%rcx)
movss %xmm0, 0x4(%rcx)
movl %ebp, 0x90(%rsp)
movq %rcx, 0x98(%rsp)
movabsq $0x140400000, %rcx      # imm = 0x140400000
movq %rcx, 0xa0(%rsp)
movw $0x101, %dx             # imm = 0x101
movw %dx, 0xa8(%rsp)
leaq -0x528(%rip), %rsi      # 0x50e5
movq %rsi, 0xb0(%rsp)
movl %ebp, 0xc0(%rsp)
movl %ebp, 0xb8(%rsp)
movl %ebp, 0xbb(%rsp)
leaq 0xfbe(%rip), %rsi       # 0x65ef
movq %rsi, 0xc8(%rsp)
movl $0xff000000, 0xd0(%rsp) # imm = 0xFF000000
leaq 0x2b0(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0xd8(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rcx, 0xe8(%rsp)
movw %dx, 0xf0(%rsp)
leaq -0x593(%rip), %rsi      # 0x50e6
movq %rsi, 0xf8(%rsp)
movl %ebp, 0x108(%rsp)
movl %ebp, 0x103(%rsp)
movl %ebp, 0x100(%rsp)
leaq 0xf59(%rip), %rsi       # 0x65f6
movq %rsi, 0x110(%rsp)
movl $0xffff0000, 0x118(%rsp) # imm = 0xFFFF0000
leaq 0x2a8(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0x120(%rsp)
movq %rsi, 0x128(%rsp)
movq %rcx, 0x130(%rsp)
movw %dx, 0x138(%rsp)
leaq -0x5df(%rip), %rsi      # 0x5106
movq %rsi, 0x140(%rsp)
movl %ebp, 0x150(%rsp)
movl %ebp, 0x148(%rsp)
movl %ebp, 0x14b(%rsp)
leaq 0xf01(%rip), %rsi       # 0x660a
movq %rsi, 0x158(%rsp)
movl $0xff00ff00, 0x160(%rsp) # imm = 0xFF00FF00
leaq 0x2a0(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0x168(%rsp)
movq %rsi, 0x170(%rsp)
movq %rcx, 0x178(%rsp)
movw %dx, 0x180(%rsp)
leaq -0x613(%rip), %rsi      # 0x513e
movq %rsi, 0x188(%rsp)
movl %ebp, 0x198(%rsp)
movl %ebp, 0x190(%rsp)
movl %ebp, 0x193(%rsp)
leaq 0xeaa(%rip), %rsi       # 0x661f
movq %rsi, 0x1a0(%rsp)
movl $0xff0000ff, 0x1a8(%rsp) # imm = 0xFF0000FF
leaq 0x298(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0x1b0(%rsp)
movq %rsi, 0x1b8(%rsp)
movq %rcx, 0x1c0(%rsp)
movw %dx, 0x1c8(%rsp)
leaq -0x616(%rip), %rsi      # 0x51a7
movq %rsi, 0x1d0(%rsp)
movl %ebp, 0x1e0(%rsp)
movl %ebp, 0x1db(%rsp)
movl %ebp, 0x1d8(%rsp)
leaq 0xe56(%rip), %rsi       # 0x6637
movq %rsi, 0x1e8(%rsp)
movl $0xff964b00, 0x1f0(%rsp) # imm = 0xFF964B00
leaq 0x290(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0x1f8(%rsp)
movq %rsi, 0x200(%rsp)
movq %rcx, 0x208(%rsp)
movw %dx, 0x210(%rsp)
leaq -0x608(%rip), %rsi      # 0x5221
movq %rsi, 0x218(%rsp)
movl %ebp, 0x228(%rsp)
movl %ebp, 0x223(%rsp)
movl %ebp, 0x220(%rsp)
leaq 0xdfa(%rip), %rsi       # 0x6647
movq %rsi, 0x230(%rsp)
movl $0xffff00ff, 0x238(%rsp) # imm = 0xFFFF00FF
leaq 0x288(%rsp), %rsi
movl %eax, (%rsi)
movss %xmm0, 0x4(%rsi)
movl %ebp, 0x240(%rsp)
movq %rsi, 0x248(%rsp)
movq %rcx, 0x250(%rsp)
movw %dx, 0x258(%rsp)
leaq -0x608(%rip), %rax      # 0x528d
movq %rax, 0x260(%rsp)
movl %ebp, 0x270(%rsp)
movl %ebp, 0x26b(%rsp)
movl %ebp, 0x268(%rsp)
leaq 0xd9f(%rip), %rax       # 0x6658
movq %rax, 0x278(%rsp)
movl $0xff008080, 0x280(%rsp) # imm = 0xFF008080
movl $0x30, %eax
movss 0x8(%rbx), %xmm0
cmpb $0x0, 0x8c(%rsp,%rax)
jne 0x5906
movw $0x1, 0x8c(%rsp,%rax)
movss %xmm0, 0x88(%rsp,%rax)
movl $0x0, 0x90(%rsp,%rax)
movb $0x0, 0x8e(%rsp,%rax)
addq $0x48, %rax
cmpq $0x228, %rax            # imm = 0x228
jne 0x58d6
leaq 0x2c0(%rsp), %rdi
callq 0x4a46
testb %al, %al
je 0x5b87
xorl %ebx, %ebx
movq 0x300(%rsp), %rax
cmpb $0x0, 0x213(%rax)
jne 0x59d6
cmpb $0x1, 0x13(%rax)
jne 0x59d6
movss 0x2c8(%rsp), %xmm0
xorl %eax, %eax
testb $0x1, %bl
je 0x5996
leaq (%rax,%rax,8), %rcx
cmpb $0x1, 0xbc(%rsp,%rcx,8)
jne 0x59ca
leaq (%rsp,%rcx,8), %rcx
addq $0x90, %rcx
cmpb $0x1, 0x2d(%rcx)
jne 0x59ca
movb $0x0, 0x2d(%rcx)
movaps %xmm0, %xmm1
subss 0x30(%rcx), %xmm1
addss 0x28(%rcx), %xmm1
movss %xmm1, 0x28(%rcx)
movl $0x0, 0x30(%rcx)
jmp 0x59ca
xorl %ecx, %ecx
cmpb $0x1, 0xbc(%rsp,%rcx)
jne 0x59bd
cmpb $0x0, 0xbd(%rsp,%rcx)
jne 0x59bd
movb $0x1, 0xbd(%rsp,%rcx)
movss %xmm0, 0xc0(%rsp,%rcx)
addq $0x48, %rcx
cmpq $0x1f8, %rcx            # imm = 0x1F8
jne 0x5998
incq %rax
cmpq $0x7, %rax
jne 0x5953
xorb $0x1, %bl
movq %rbx, 0x38(%rsp)
movq 0x2f8(%rsp), %r15
movl 0x4(%r15), %eax
movl (%r15), %ecx
imull %eax, %ecx
testl %ecx, %ecx
jle 0x5a09
movq 0x10(%r15), %rdi
movl %ecx, %edx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x2100
movl 0x4(%r15), %eax
movl %eax, %ecx
addl $-0x10, %ecx
movslq %ecx, %rcx
imulq $-0x6db6db6d, %rcx, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %ecx, %eax
addl $-0x10, %eax
movl %eax, %edx
sarl $0x2, %edx
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %edx
movl %edx, 0x30(%rsp)
movss 0x2c8(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
sarl $0x3, %eax
addl %ecx, %eax
addl $-0xe, %eax
movq %rax, 0x40(%rsp)
movl $0x10, %ebx
xorl %eax, %eax
movq %rax, 0x50(%rsp)
leaq (%rax,%rax,8), %rax
leaq (%rsp,%rax,8), %r14
addq $0x90, %r14
movq %r14, %rdi
leaq 0x34(%rsp), %rsi
movss 0x2c(%rsp), %xmm0
callq 0x538b
cvttss2si 0x34(%rsp), %r13d
movq %r14, 0x48(%rsp)
movl 0x40(%r14), %ebp
movq 0x40(%rsp), %rax
movq %rbx, 0x58(%rsp)
addl %ebx, %eax
movq %rax, 0x60(%rsp)
xorl %r12d, %r12d
movq 0x60(%rsp), %rax
leal (%rax,%r12), %r14d
xorl %ebx, %ebx
leal (%rbx,%r13), %esi
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x2b68
incl %ebx
cmpl $0x21, %ebx
jne 0x5aaa
leal 0x1(%r12), %eax
cmpl $0x20, %r12d
movl %eax, %r12d
jne 0x5a9f
movq 0x48(%rsp), %r14
movq 0x38(%r14), %rsi
movl 0x40(%r14), %r9d
movq %r15, %rdi
movl $0xa, %edx
movq 0x58(%rsp), %rbx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3a63
leal 0xc(%rbx), %edx
movl (%r15), %ecx
movl 0x40(%r14), %r9d
movq %r15, %rdi
xorl %esi, %esi
movl %edx, %r8d
callq 0x3421
addl 0x30(%rsp), %ebx
movq 0x50(%rsp), %rax
incq %rax
cmpq $0x7, %rax
jne 0x5a54
movq 0x38(%rsp), %rbx
testb $0x1, %bl
leaq 0xb4e(%rip), %rsi       # 0x667e
leaq 0xb35(%rip), %rax       # 0x666c
cmovneq %rax, %rsi
movl (%r15), %eax
movl %ebx, %ecx
notb %cl
movzbl %cl, %ecx
andl $0x1, %ecx
leal (%rax,%rcx,8), %edx
addl $0xffffff6e, %edx       # imm = 0xFFFFFF6E
movq %r15, %rdi
movl $0xa, %ecx
xorl %r8d, %r8d
movl $0xff000000, %r9d       # imm = 0xFF000000
callq 0x3a63
leaq 0x2c0(%rsp), %r14
movq %r14, %rdi
callq 0x4b6f
movq %r14, %rdi
callq 0x4a46
testb %al, %al
jne 0x5929
leaq 0x2c0(%rsp), %rdi
callq 0x5042
xorl %eax, %eax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq