// File: /workspace/github_c_makefile_star2_O1/adelciotto[P]scg/examples/../scg.h
// Function: scg_app_init
void scg_app_init(scg_app_t *app, scg_config_t config) {
    // Initialise the SDL library.
    {
        uint32_t flags = SDL_INIT_VIDEO;
        if (config.audio.enabled) {
            flags |= SDL_INIT_AUDIO;
        }

        if (SDL_Init(flags) != 0) {
            scg_log_errorf("Failed to initialise SDL. %s", SDL_GetError());

            exit(EXIT_FAILURE);
        }
    }

    scg_image_t *draw_target =
        scg_image_new(config.video.width, config.video.height);
    if (draw_target == NULL) {
        scg_log_error("Failed to create draw target");

        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    scg__screen_t *screen =
        scg__screen_new(draw_target, config.video.title, config.video.scale,
                        config.video.fullscreen, config.video.vsync,
                        config.video.lock_fps, config.input.hide_mouse_cursor);
    if (screen == NULL) {
        scg_log_error("Failed to create screen");

        scg_image_free(draw_target);
        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    scg_keyboard_t *keyboard = scg__keyboard_new();
    if (keyboard == NULL) {
        scg_log_error("Failed to create keyboard");

        scg__screen_free(screen);
        scg_image_free(draw_target);
        SDL_Quit();
        exit(EXIT_FAILURE);
    }

    scg_mouse_t *mouse = scg__mouse_new();
    if (mouse == NULL) {
        scg_log_error("Failed to create mouse");

        free(keyboard);
        scg__screen_free(screen);
        scg_image_free(draw_target);
        SDL_Quit();
        exit(EXIT_FAILURE);
    }
    scg__mouse_update(mouse, draw_target->width, draw_target->height,
                      screen->window_width, screen->window_height);

    scg_audio_t *audio = NULL;
    if (config.audio.enabled) {
        audio = scg__audio_new();
        if (audio == NULL) {
            scg_log_error("Failed to create sound device");

            free(keyboard);
            scg__screen_free(screen);
            scg_image_free(draw_target);
            exit(EXIT_FAILURE);
        }
    }

    scg__decode_font_data(scg__font8x8, SCG__FONT_NUM_CHARS * SCG_FONT_SIZE,
                          scg__font8x8_data);
    scg__decode_font_data(scg__font8x8_hiragana,
                          SCG__FONT_HIRAGANA_NUM_CHARS * SCG_FONT_SIZE,
                          scg__font8x8_hiragana_data);

    // Log some information to stdout.
    {
        scg_log_infof("Application '%s' successfuly initialised. "
                      "Width: %d, Height: %d, Target FPS: %d, VSync: %d",
                      config.video.title, draw_target->width,
                      draw_target->height, screen->target_fps, screen->vsync);
        if (config.audio.enabled) {
            scg_log_infof("Audio successfuly initialised. "
                          "Device ID: %d, Channels: %d, Samples/sec: %d, "
                          "Samples/frame: %d, Bytes/sample: %d",
                          audio->device_id, audio->num_channels,
                          audio->frequency, audio->latency_sample_count,
                          audio->bytes_per_sample);
        }

        SDL_RendererInfo info;
        SDL_GetRendererInfo(screen->sdl_renderer, &info);
        scg_log_infof("Renderer name: %s", info.name);

        char buffer[1024] = "";
        for (unsigned int i = 0; i < info.num_texture_formats; i++) {
            strcat(buffer, SDL_GetPixelFormatName(info.texture_formats[i]));
            if (i != info.num_texture_formats - 1) {
                strcat(buffer, ", ");
            }
        }
        scg_log_infof("Supported texture formats: %s", buffer);
    }

    app->running = true;
    app->config = config;
    app->draw_target = draw_target;
    app->screen = screen;
    app->keyboard = keyboard;
    app->mouse = mouse;
    app->audio = audio;
    app->delta_time = 0.0f;
    app->elapsed_time = 0.0f;
    app->delta_time_counter = scg_get_performance_counter();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x498, %rsp            # imm = 0x498
movq %rdi, %rbx
movzbl 0x4ec(%rsp), %ebp
movl %ebp, %edi
shll $0x4, %edi
orl $0x20, %edi
callq 0x2200
testl %eax, %eax
jne 0x46b8
movq %rbx, 0x30(%rsp)
leaq 0x4d0(%rsp), %rbx
movl (%rbx), %edi
movl 0x4(%rbx), %esi
callq 0x2862
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x46e9
movl %ebp, 0x18(%rsp)
movq 0x8(%rbx), %r13
movl 0x10(%rbx), %r12d
movb 0x14(%rbx), %bpl
movb 0x15(%rbx), %r14b
movb 0x16(%rbx), %r15b
movzbl 0x18(%rbx), %ebx
leaq 0x90(%rsp), %rsi
xorl %edi, %edi
callq 0x2360
testl %eax, %eax
je 0x3f68
callq 0x2190
leaq 0x2719(%rip), %rsi      # 0x662b
leaq 0x2752(%rip), %rdx      # 0x666b
leaq 0x21a6(%rip), %rcx      # 0x60c6
xorl %r12d, %r12d
xorl %edi, %edi
movl $0x745, %r8d            # imm = 0x745
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
testq %r12, %r12
je 0x4719
movl $0x400, %edi            # imm = 0x400
callq 0x22f0
testq %rax, %rax
je 0x4048
movq %rax, %rbx
movl $0x400, %edx            # imm = 0x400
movq %rax, %rdi
xorl %esi, %esi
callq 0x2100
jmp 0x4075
movb %r15b, 0x28(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %r15d
movl %ecx, 0x10(%rsp)
imull %r12d, %ecx
movl %ecx, 0x38(%rsp)
imull %r15d, %r12d
movl %r12d, 0x24(%rsp)
movq %r13, %rdi
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl %r12d, %r8d
movl $0x2004, %r9d           # imm = 0x2004
callq 0x2050
testq %rax, %rax
je 0x426d
movq %rax, %r12
testb %bpl, %bpl
je 0x3fd8
movq %r12, %rdi
movl $0x1001, %esi           # imm = 0x1001
callq 0x2280
leaq 0x38(%rsp), %rsi
leaq 0x24(%rsp), %rdx
movq %r12, %rdi
callq 0x20b0
xorl $0x1, %ebx
movl %ebx, %edi
callq 0x23c0
movl $0x2, %ebx
testb %r14b, %r14b
je 0x4004
leaq 0x26bd(%rip), %rdi      # 0x66b0
leaq 0x26c7(%rip), %rsi      # 0x66c1
callq 0x2370
movl $0x6, %ebx
leaq 0x26b8(%rip), %rdi      # 0x66c3
leaq 0x26ca(%rip), %rsi      # 0x66dc
callq 0x2370
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %ebx, %edx
callq 0x2040
movq %rax, %r13
testq %rax, %rax
je 0x4297
movq %r13, %rdi
movl 0x10(%rsp), %ebx
movl %ebx, %esi
movl %r15d, %edx
callq 0x2080
jmp 0x42cf
leaq 0x2051(%rip), %rsi      # 0x60a0
leaq 0x2720(%rip), %rdx      # 0x6776
leaq 0x2069(%rip), %rcx      # 0x60c6
leaq 0x2724(%rip), %r9       # 0x6788
xorl %ebx, %ebx
xorl %edi, %edi
movl $0x7f1, %r8d            # imm = 0x7F1
xorl %eax, %eax
callq 0x22e0
testq %rbx, %rbx
je 0x4746
movl $0x14, %edi
callq 0x22f0
movq %rax, %r13
testq %rax, %rax
jne 0x40be
leaq 0x2009(%rip), %rsi      # 0x60a0
leaq 0x2711(%rip), %rdx      # 0x67af
leaq 0x2021(%rip), %rcx      # 0x60c6
leaq 0x2712(%rip), %r9       # 0x67be
xorl %r13d, %r13d
xorl %edi, %edi
movl $0x805, %r8d            # imm = 0x805
xorl %eax, %eax
callq 0x22e0
testq %r13, %r13
je 0x4773
movq 0x8(%rsp), %rax
movl (%rax), %esi
movl 0x4(%rax), %edx
movl (%r12), %ecx
movl 0x4(%r12), %r8d
movq %r13, %rdi
callq 0x4838
cmpb $0x0, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
je 0x41f7
xorpd %xmm0, %xmm0
leaq 0x90(%rsp), %rdx
movapd %xmm0, (%rdx)
movapd %xmm0, 0x10(%rdx)
movl $0xbb80, (%rdx)         # imm = 0xBB80
movw $0x8010, 0x4(%rdx)      # imm = 0x8010
movb $0x2, 0x6(%rdx)
movw $0x800, 0x8(%rdx)       # imm = 0x800
movq $0x0, 0x10(%rdx)
leaq 0x38(%rsp), %rcx
xorl %edi, %edi
xorl %esi, %esi
movl $0x2, %r8d
callq 0x22b0
testl %eax, %eax
je 0x4201
movl %eax, %ebx
movzwl 0x3c(%rsp), %eax
cmpw 0x94(%rsp), %ax
jne 0x4234
movq %r12, 0x18(%rsp)
movslq 0x38(%rsp), %rbp
imulq $-0x77777777, %rbp, %r12 # imm = 0x88888889
shrq $0x20, %r12
addl %ebp, %r12d
movl %r12d, %eax
shrl $0x1f, %eax
sarl $0x3, %r12d
addl %eax, %r12d
leal (,%r12,4), %r14d
movq %r14, %rdi
callq 0x22f0
testq %rax, %rax
je 0x43be
movq %rax, %r15
movq %rbp, 0x28(%rsp)
movl $0xa8, %edi
callq 0x22f0
testq %rax, %rax
je 0x441a
movq %rax, %rbp
movl %ebx, (%rax)
movq 0x28(%rsp), %rax
movl %eax, 0x4(%rbp)
movb 0x3e(%rsp), %al
movb %al, 0x8(%rbp)
movzwl 0x40(%rsp), %eax
movw %ax, 0xa(%rbp)
movl $0x4, 0xc(%rbp)
movl %r12d, 0x10(%rbp)
movl %r14d, 0x14(%rbp)
movq %r15, 0x18(%rbp)
movl $0x0, 0xa0(%rbp)
movl %ebx, %edi
xorl %esi, %esi
callq 0x22d0
jmp 0x4456
movq %r13, %r15
xorl %ebp, %ebp
jmp 0x4467
callq 0x2190
leaq 0x25d5(%rip), %rsi      # 0x67e2
leaq 0x2607(%rip), %rdx      # 0x681b
leaq 0x1eab(%rip), %rcx      # 0x60c6
xorl %ebp, %ebp
xorl %edi, %edi
movl $0x82a, %r8d            # imm = 0x82A
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x445b
leaq 0x1e65(%rip), %rsi      # 0x60a0
leaq 0x25d9(%rip), %rdx      # 0x681b
leaq 0x1e7d(%rip), %rcx      # 0x60c6
leaq 0x25da(%rip), %r9       # 0x682a
xorl %ebp, %ebp
xorl %edi, %edi
movl $0x830, %r8d            # imm = 0x830
xorl %eax, %eax
callq 0x22e0
movl %ebx, %edi
callq 0x20d0
jmp 0x445b
callq 0x2190
leaq 0x2402(%rip), %rsi      # 0x667b
leaq 0x23eb(%rip), %rdx      # 0x666b
leaq 0x1e3f(%rip), %rcx      # 0x60c6
xorl %r12d, %r12d
xorl %edi, %edi
movl $0x759, %r8d            # imm = 0x759
jmp 0x3f2b
callq 0x2190
leaq 0x2441(%rip), %rsi      # 0x66e4
leaq 0x23c1(%rip), %rdx      # 0x666b
leaq 0x1e15(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x776, %r8d            # imm = 0x776
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
movq %r12, %rdi
callq 0x2030
movl 0x10(%rsp), %ebx
testq %r13, %r13
je 0x43b6
movq %r13, %rdi
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
movl %ebx, %ecx
movl %r15d, %r8d
callq 0x23a0
testq %rax, %rax
je 0x43e9
movq %rax, %rbx
movl $0x68, %edi
callq 0x22f0
testq %rax, %rax
je 0x466d
movq %rax, %r15
movl 0x38(%rsp), %eax
movl %eax, (%r15)
movl 0x24(%rsp), %eax
movl %eax, 0x4(%r15)
movl 0x9c(%rsp), %eax
testl %eax, %eax
movl $0x3c, %ebp
cmovnel %eax, %ebp
cvtsi2sd %ebp, %xmm0
movl %ebp, 0x8(%r15)
movsd 0x1d3f(%rip), %xmm1     # 0x6080
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%r15)
callq 0x2300
movq %rax, 0x18(%r15)
movq %r12, 0x50(%r15)
movq %r13, 0x58(%r15)
movq %rbx, 0x60(%r15)
movb %r14b, 0x48(%r15)
movb 0x28(%rsp), %al
movb %al, 0x49(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x30(%r15)
movl $0x0, 0x40(%r15)
callq 0x2300
movq %rax, %xmm0
punpckldq 0x1cb0(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1cb8(%rip), %xmm0     # 0x6050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r15)
movl %ebp, 0x28(%r15)
movq %r15, %r12
jmp 0x3f35
xorl %r12d, %r12d
jmp 0x3f35
leaq 0x2491(%rip), %rsi      # 0x6856
leaq 0x244f(%rip), %rdx      # 0x681b
leaq 0x1cf3(%rip), %rcx      # 0x60c6
xorl %ebp, %ebp
xorl %edi, %edi
movl $0x83c, %r8d            # imm = 0x83C
movl %r14d, %r9d
xorl %eax, %eax
callq 0x22e0
jmp 0x444f
callq 0x2190
leaq 0x2326(%rip), %rsi      # 0x671b
leaq 0x226f(%rip), %rdx      # 0x666b
leaq 0x1cc3(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x784, %r8d            # imm = 0x784
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x46a0
leaq 0x1c7f(%rip), %rsi      # 0x60a0
leaq 0x23f3(%rip), %rdx      # 0x681b
leaq 0x1c97(%rip), %rcx      # 0x60c6
leaq 0x246a(%rip), %r9       # 0x68a0
xorl %ebp, %ebp
xorl %edi, %edi
movl $0x844, %r8d            # imm = 0x844
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2290
movl %ebx, %edi
callq 0x20d0
movq 0x18(%rsp), %r12
movq %r13, %r15
testq %rbp, %rbp
je 0x47c7
leaq 0x5db2(%rip), %rdi      # 0xa220
leaq 0x244f(%rip), %rdx      # 0x68c4
movl $0x400, %esi            # imm = 0x400
callq 0x48cf
leaq 0x619a(%rip), %rdi      # 0xa620
leaq 0x2990(%rip), %rdx      # 0x6e1d
movl $0x300, %esi            # imm = 0x300
callq 0x48cf
leaq 0x4d0(%rsp), %r13
movq 0x8(%r13), %r9
movq 0x8(%rsp), %rax
movl (%rax), %r10d
movl 0x4(%rax), %r11d
movl 0x8(%r12), %ebx
movq %r12, %r14
movzbl 0x48(%r12), %r12d
leaq 0x1f85(%rip), %rsi      # 0x6449
leaq 0x1eed(%rip), %rdx      # 0x63b8
leaq 0x1bf4(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x5be, %r8d            # imm = 0x5BE
xorl %eax, %eax
pushq %r12
pushq %rbx
pushq %r11
pushq %r10
callq 0x2380
addq $0x20, %rsp
cmpb $0x1, 0x1c(%r13)
jne 0x4536
movzbl 0x8(%rbp), %r10d
movl (%rbp), %r9d
movl 0x4(%rbp), %r11d
movl 0x10(%rbp), %ebx
movl 0xc(%rbp), %r12d
leaq 0x1fab(%rip), %rsi      # 0x64b9
leaq 0x1ea3(%rip), %rdx      # 0x63b8
leaq 0x1baa(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x5c5, %r8d            # imm = 0x5C5
xorl %eax, %eax
pushq %r12
pushq %rbx
pushq %r11
pushq %r10
callq 0x2380
addq $0x20, %rsp
movq 0x58(%r14), %rdi
leaq 0x38(%rsp), %rbx
movq %rbx, %rsi
callq 0x2320
movq (%rbx), %r9
leaq 0x1fee(%rip), %rsi      # 0x653f
leaq 0x1e60(%rip), %rdx      # 0x63b8
leaq 0x1b67(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x5ca, %r8d            # imm = 0x5CA
xorl %eax, %eax
callq 0x2380
leaq 0x90(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x2100
cmpl $0x0, 0xc(%rbx)
je 0x45d9
xorl %r12d, %r12d
leaq 0x90(%rsp), %rbx
movl 0x48(%rsp,%r12,4), %edi
callq 0x20a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2390
movl 0x44(%rsp), %eax
decl %eax
cmpq %rax, %r12
je 0x45cd
movq %rbx, %rdi
callq 0x20f0
movw $0x202c, 0x90(%rsp,%rax) # imm = 0x202C
movb $0x0, 0x92(%rsp,%rax)
incq %r12
movl 0x44(%rsp), %eax
cmpq %rax, %r12
jb 0x4593
leaq 0x1f89(%rip), %rsi      # 0x6569
leaq 0x1dd1(%rip), %rdx      # 0x63b8
leaq 0x1ad8(%rip), %rcx      # 0x60c6
leaq 0x90(%rsp), %r9
xorl %edi, %edi
movl $0x5d3, %r8d            # imm = 0x5D3
xorl %eax, %eax
callq 0x2380
movq 0x30(%rsp), %rbx
movb $0x1, (%rbx)
leaq 0x4d0(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm0, 0x10(%rbx)
movups %xmm1, 0x20(%rbx)
movq 0x20(%rax), %rax
movq %rax, 0x30(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rbx)
movq %r14, 0x60(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rbx)
movq %r15, 0x48(%rbx)
movq %rbp, 0x50(%rbx)
movq $0x0, 0x4(%rbx)
callq 0x2300
movq %rax, 0x58(%rbx)
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a2c(%rip), %rsi      # 0x60a0
leaq 0x1ff0(%rip), %rdx      # 0x666b
leaq 0x1a44(%rip), %rcx      # 0x60c6
leaq 0x20c8(%rip), %r9       # 0x6751
xorl %edi, %edi
movl $0x78e, %r8d            # imm = 0x78E
xorl %eax, %eax
callq 0x22e0
movq %rbx, %rdi
callq 0x2160
movq %r13, %rdi
callq 0x20c0
movq %r12, %rdi
xorl %r12d, %r12d
callq 0x2030
jmp 0x3f35
callq 0x2190
leaq 0x1cc2(%rip), %rsi      # 0x6386
leaq 0x1ced(%rip), %rdx      # 0x63b8
leaq 0x19f4(%rip), %rcx      # 0x60c6
xorl %edi, %edi
movl $0x574, %r8d            # imm = 0x574
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x47bd
leaq 0x19b0(%rip), %rsi      # 0x60a0
leaq 0x1cc1(%rip), %rdx      # 0x63b8
leaq 0x19c8(%rip), %rcx      # 0x60c6
leaq 0x1cc0(%rip), %r9       # 0x63c5
xorl %edi, %edi
movl $0x57d, %r8d            # imm = 0x57D
xorl %eax, %eax
callq 0x22e0
jmp 0x47b8
leaq 0x1980(%rip), %rsi      # 0x60a0
leaq 0x1c91(%rip), %rdx      # 0x63b8
leaq 0x1998(%rip), %rcx      # 0x60c6
leaq 0x1cad(%rip), %r9       # 0x63e2
xorl %edi, %edi
movl $0x588, %r8d            # imm = 0x588
xorl %eax, %eax
callq 0x22e0
jmp 0x47ae
leaq 0x1953(%rip), %rsi      # 0x60a0
leaq 0x1c64(%rip), %rdx      # 0x63b8
leaq 0x196b(%rip), %rcx      # 0x60c6
leaq 0x1c98(%rip), %r9       # 0x63fa
xorl %edi, %edi
movl $0x591, %r8d            # imm = 0x591
xorl %eax, %eax
callq 0x22e0
jmp 0x47a6
leaq 0x1926(%rip), %rsi      # 0x60a0
leaq 0x1c37(%rip), %rdx      # 0x63b8
leaq 0x193e(%rip), %rcx      # 0x60c6
leaq 0x1c85(%rip), %r9       # 0x6414
xorl %edi, %edi
movl $0x59b, %r8d            # imm = 0x59B
xorl %eax, %eax
callq 0x22e0
movq %rbx, %rdi
callq 0x2290
movq %r12, %rdi
callq 0x4810
movq 0x8(%rsp), %rdi
callq 0x3c6c
callq 0x2060
movl $0x1, %edi
callq 0x22a0
leaq 0x18d2(%rip), %rsi      # 0x60a0
leaq 0x1be3(%rip), %rdx      # 0x63b8
leaq 0x18ea(%rip), %rcx      # 0x60c6
leaq 0x1c48(%rip), %r9       # 0x642b
xorl %edi, %edi
movl $0x5aa, %r8d            # imm = 0x5AA
xorl %eax, %eax
callq 0x22e0
movq 0x10(%rsp), %rdi
callq 0x2290
movq %r12, %rdi
callq 0x4810
movq 0x8(%rsp), %rdi
callq 0x3c6c
jmp 0x47bd