// File: /workspace/github_c_makefile_star2_O1/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, 0x38(%rsp)
movl $0x1, 0x48(%rsp)
xorl %ebp, %ebp
movb %bpl, 0x4c(%rsp)
movl $0x1010101, 0x4d(%rsp)  # imm = 0x1010101
movb %bpl, 0x54(%rsp)
movl $0x40, 0x58(%rsp)
leaq 0x107c(%rip), %rax      # 0x659c
movq %rax, 0x40(%rsp)
movb %bpl, 0x4f(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0x38(%rsp), %xmm0
movups 0x48(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x2c0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3e81
movq 0x38(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2ssl (%rax), %xmm0
addss 0xace(%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 -0x518(%rip), %rsi      # 0x509a
movq %rsi, 0xb0(%rsp)
movl %ebp, 0xc0(%rsp)
movl %ebp, 0xb8(%rsp)
movl %ebp, 0xbb(%rsp)
leaq 0xfd9(%rip), %rsi       # 0x65af
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 -0x583(%rip), %rsi      # 0x509b
movq %rsi, 0xf8(%rsp)
movl %ebp, 0x108(%rsp)
movl %ebp, 0x103(%rsp)
movl %ebp, 0x100(%rsp)
leaq 0xf74(%rip), %rsi       # 0x65b6
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 -0x5cf(%rip), %rsi      # 0x50bb
movq %rsi, 0x140(%rsp)
movl %ebp, 0x150(%rsp)
movl %ebp, 0x148(%rsp)
movl %ebp, 0x14b(%rsp)
leaq 0xf1c(%rip), %rsi       # 0x65ca
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 -0x60d(%rip), %rsi      # 0x50e9
movq %rsi, 0x188(%rsp)
movl %ebp, 0x198(%rsp)
movl %ebp, 0x193(%rsp)
movl %ebp, 0x190(%rsp)
leaq 0xec5(%rip), %rsi       # 0x65df
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 -0x610(%rip), %rsi      # 0x5152
movq %rsi, 0x1d0(%rsp)
movl %ebp, 0x1e0(%rsp)
movl %ebp, 0x1db(%rsp)
movl %ebp, 0x1d8(%rsp)
leaq 0xe71(%rip), %rsi       # 0x65f7
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 -0x602(%rip), %rsi      # 0x51cc
movq %rsi, 0x218(%rsp)
movl %ebp, 0x228(%rsp)
movl %ebp, 0x223(%rsp)
movl %ebp, 0x220(%rsp)
leaq 0xe15(%rip), %rsi       # 0x6607
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 -0x602(%rip), %rax      # 0x5238
movq %rax, 0x260(%rsp)
movl %ebp, 0x270(%rsp)
movl %ebp, 0x26b(%rsp)
movl %ebp, 0x268(%rsp)
leaq 0xdba(%rip), %rax       # 0x6618
movq %rax, 0x278(%rsp)
movl $0xff008080, 0x280(%rsp) # imm = 0xFF008080
movl $0x30, %eax
movss 0x8(%rbx), %xmm0
cmpb $0x0, 0x8c(%rsp,%rax)
jne 0x58ab
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 0x587b
leaq 0x2c0(%rsp), %rdi
callq 0x49dc
testb %al, %al
je 0x5b36
xorl %ebx, %ebx
movq 0x300(%rsp), %rax
cmpb $0x0, 0x213(%rax)
jne 0x597b
cmpb $0x1, 0x13(%rax)
jne 0x597b
movss 0x2c8(%rsp), %xmm0
xorl %eax, %eax
testb $0x1, %bl
je 0x593b
leaq (%rax,%rax,8), %rcx
cmpb $0x1, 0xbc(%rsp,%rcx,8)
jne 0x596f
leaq (%rsp,%rcx,8), %rcx
addq $0x90, %rcx
cmpb $0x1, 0x2d(%rcx)
jne 0x596f
movb $0x0, 0x2d(%rcx)
movaps %xmm0, %xmm1
subss 0x30(%rcx), %xmm1
addss 0x28(%rcx), %xmm1
movss %xmm1, 0x28(%rcx)
movl $0x0, 0x30(%rcx)
jmp 0x596f
xorl %ecx, %ecx
cmpb $0x1, 0xbc(%rsp,%rcx)
jne 0x5962
cmpb $0x0, 0xbd(%rsp,%rcx)
jne 0x5962
movb $0x1, 0xbd(%rsp,%rcx)
movss %xmm0, 0xc0(%rsp,%rcx)
addq $0x48, %rcx
cmpq $0x1f8, %rcx            # imm = 0x1F8
jne 0x593d
incq %rax
cmpq $0x7, %rax
jne 0x58f8
xorb $0x1, %bl
movq %rbx, 0x60(%rsp)
movq 0x2f8(%rsp), %r15
movl 0x4(%r15), %eax
imull (%r15), %eax
testl %eax, %eax
jle 0x59a8
movq 0x10(%r15), %rdi
movl %eax, %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, 0x68(%rsp)
movl $0x10, %ebx
xorl %eax, %eax
movq %rax, 0x78(%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 0x5336
cvttss2si 0x34(%rsp), %r13d
movq %r14, 0x70(%rsp)
movl 0x40(%r14), %ebp
movq 0x68(%rsp), %rax
movq %rbx, 0x80(%rsp)
addl %ebx, %eax
movq %rax, 0x88(%rsp)
xorl %r12d, %r12d
movq 0x88(%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 0x5a56
leal 0x1(%r12), %eax
cmpl $0x20, %r12d
movl %eax, %r12d
jne 0x5a48
movq 0x70(%rsp), %r14
movq 0x38(%r14), %rsi
movl 0x40(%r14), %r9d
movq %r15, %rdi
movl $0xa, %edx
movq 0x80(%rsp), %rbx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3977
leal 0xc(%rbx), %edx
movl (%r15), %ecx
movl 0x40(%r14), %r9d
movq %r15, %rdi
xorl %esi, %esi
movl %edx, %r8d
callq 0x3335
addl 0x30(%rsp), %ebx
movq 0x78(%rsp), %rax
incq %rax
cmpq $0x7, %rax
jne 0x59f7
movq 0x60(%rsp), %rbx
testb $0x1, %bl
leaq 0xb5f(%rip), %rsi       # 0x663e
leaq 0xb46(%rip), %rax       # 0x662c
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 0x3977
leaq 0x2c0(%rsp), %r14
movq %r14, %rdi
callq 0x4b28
movq %r14, %rdi
callq 0x49dc
testb %al, %al
jne 0x58ce
leaq 0x2c0(%rsp), %rdi
callq 0x4ff7
xorl %eax, %eax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq