// File: /workspace/github_c_makefile_star2_O2/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 $0x4b8, %rsp            # imm = 0x4B8
movq %rdi, %r13
movzbl 0x50c(%rsp), %edi
movl %edi, 0x10(%rsp)
shll $0x4, %edi
orl $0x20, %edi
callq 0x2200
testl %eax, %eax
jne 0x433e
leaq 0x4f0(%rsp), %rbx
movl (%rbx), %edi
movl 0x4(%rbx), %esi
callq 0x2855
testq %rax, %rax
je 0x436f
movq %rax, %r15
movq 0x8(%rbx), %r12
movl 0x10(%rbx), %ebp
movb 0x14(%rbx), %r14b
movb 0x15(%rbx), %al
movb %al, 0x3(%rsp)
movb 0x16(%rbx), %al
movb %al, 0x18(%rsp)
movzbl 0x18(%rbx), %ebx
leaq 0xb0(%rsp), %rsi
xorl %edi, %edi
callq 0x2360
testl %eax, %eax
movq %r15, 0x8(%rsp)
jne 0x439f
movl (%r15), %eax
movl 0x4(%r15), %edx
movq %rax, 0x30(%rsp)
movl %eax, %ecx
imull %ebp, %ecx
movl %ecx, 0x58(%rsp)
movq %rdx, 0x28(%rsp)
imull %edx, %ebp
movl %ebp, 0x14(%rsp)
movq %r12, %rdi
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl %ebp, %r8d
movl $0x2004, %r9d           # imm = 0x2004
callq 0x2050
testq %rax, %rax
je 0x43c3
movq %rax, %rbp
testb %r14b, %r14b
je 0x3eb9
movq %rbp, %rdi
movl $0x1001, %esi           # imm = 0x1001
callq 0x2280
leaq 0x58(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %rbp, %rdi
callq 0x20b0
xorl $0x1, %ebx
movl %ebx, %edi
callq 0x23c0
cmpb $0x0, 0x3(%rsp)
je 0x3ee1
leaq 0x27ef(%rip), %rdi      # 0x66c0
leaq 0x27f9(%rip), %rsi      # 0x66d1
callq 0x2370
pushq $0x6
jmp 0x3ee3
pushq $0x2
popq %rbx
movq %r12, 0x50(%rsp)
leaq 0x27e3(%rip), %rdi      # 0x66d3
leaq 0x27f5(%rip), %rsi      # 0x66ec
callq 0x2370
pushq $-0x1
popq %rsi
movq %rbp, %rdi
movl %ebx, %edx
callq 0x2040
testq %rax, %rax
je 0x43f4
movq %rax, %rbx
movq %rax, %rdi
movq 0x30(%rsp), %r14
movl %r14d, %esi
movq 0x28(%rsp), %r12
movl %r12d, %edx
callq 0x2080
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl $0x16362004, %esi       # imm = 0x16362004
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x23a0
testq %rax, %rax
je 0x4422
movq %rax, %r12
movq %rbx, 0x20(%rsp)
movq %r13, 0x48(%rsp)
pushq $0x68
popq %rdi
callq 0x22f0
testq %rax, %rax
je 0x4453
movq %rax, %r14
movl 0x58(%rsp), %r13d
movl %r13d, (%rax)
movl 0x14(%rsp), %ebx
movl %ebx, 0x4(%rax)
movl 0xbc(%rsp), %eax
testl %eax, %eax
pushq $0x3c
popq %r15
cmovnel %eax, %r15d
cvtsi2sd %r15d, %xmm0
movl %r15d, 0x8(%r14)
movsd 0x20f2(%rip), %xmm1     # 0x6090
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%r14)
callq 0x2300
movq %rax, 0x18(%r14)
movq %rbp, 0x50(%r14)
movq 0x20(%rsp), %rax
movq %rax, 0x58(%r14)
movq %r12, 0x60(%r14)
movb 0x3(%rsp), %al
movb %al, 0x48(%r14)
movb 0x18(%rsp), %al
movb %al, 0x49(%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x30(%r14)
andl $0x0, 0x40(%r14)
callq 0x2300
movq %rax, %xmm0
punpckldq 0x204d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2055(%rip), %xmm0     # 0x6050
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r14)
movl %r15d, 0x28(%r14)
pushq $0x1
popq %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x2150
testq %rax, %rax
je 0x44c8
movq %rax, %r12
pushq $0x14
popq %rdi
callq 0x22f0
testq %rax, %rax
je 0x451e
movq %rax, %rbp
movq %rax, %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl %r13d, %ecx
movl %ebx, %r8d
callq 0x46d2
cmpb $0x0, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %rbp, 0x40(%rsp)
je 0x414b
xorpd %xmm0, %xmm0
leaq 0xb0(%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
leaq 0x58(%rsp), %rcx
pushq $0x2
popq %r8
xorl %edi, %edi
xorl %esi, %esi
callq 0x22b0
testl %eax, %eax
je 0x4599
movl %eax, 0x4(%rsp)
movzwl 0x5c(%rsp), %eax
cmpw 0xb4(%rsp), %ax
jne 0x45ca
movl 0x58(%rsp), %ebx
pushq $0xf
popq %rcx
movl %ebx, %eax
cltd
idivl %ecx
movl %eax, %r13d
leal (,%r13,4), %r12d
movq %r12, %rdi
callq 0x22f0
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x45f7
movl $0xa8, %edi
callq 0x22f0
testq %rax, %rax
je 0x4620
movq %rax, %rbp
movl 0x4(%rsp), %edi
movl %edi, (%rax)
movl %ebx, 0x4(%rax)
movb 0x5e(%rsp), %al
movb %al, 0x8(%rbp)
movzwl 0x60(%rsp), %eax
movw %ax, 0xa(%rbp)
movl $0x4, 0xc(%rbp)
movl %r13d, 0x10(%rbp)
movl %r12d, 0x14(%rbp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rbp)
andl $0x0, 0xa0(%rbp)
xorl %esi, %esi
callq 0x22d0
jmp 0x414d
xorl %ebp, %ebp
movq 0x8(%rsp), %r13
movzbl 0x3(%rsp), %ebx
leaq 0x60c2(%rip), %rdi      # 0xa220
leaq 0x276f(%rip), %rdx      # 0x68d4
movl $0x400, %esi            # imm = 0x400
callq 0x4762
leaq 0x64aa(%rip), %rdi      # 0xa620
leaq 0x2cb0(%rip), %rdx      # 0x6e2d
movl $0x300, %esi            # imm = 0x300
callq 0x4762
leaq 0x22cb(%rip), %rsi      # 0x6459
leaq 0x2233(%rip), %rdx      # 0x63c8
leaq 0x1f3a(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x5be, %r8d            # imm = 0x5BE
movq 0x50(%rsp), %r9
xorl %eax, %eax
pushq %rbx
pushq %r15
pushq 0x38(%rsp)
pushq 0x48(%rsp)
callq 0x2380
addq $0x20, %rsp
cmpb $0x0, 0x10(%rsp)
je 0x4209
movzbl 0x8(%rbp), %r10d
movl (%rbp), %r9d
movl 0x4(%rbp), %r11d
movl 0x10(%rbp), %ebx
movl 0xc(%rbp), %r15d
leaq 0x22e8(%rip), %rsi      # 0x64c9
leaq 0x21e0(%rip), %rdx      # 0x63c8
leaq 0x1ee7(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x5c5, %r8d            # imm = 0x5C5
xorl %eax, %eax
pushq %r15
pushq %rbx
pushq %r11
pushq %r10
callq 0x2380
addq $0x20, %rsp
leaq 0x58(%rsp), %r12
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2320
movq (%r12), %r9
leaq 0x2329(%rip), %rsi      # 0x654f
leaq 0x219b(%rip), %rdx      # 0x63c8
leaq 0x1ea2(%rip), %rcx      # 0x60d6
xorl %r15d, %r15d
xorl %edi, %edi
movl $0x5ca, %r8d            # imm = 0x5CA
xorl %eax, %eax
callq 0x2380
leaq 0xb0(%rsp), %rbx
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2100
movl 0xc(%r12), %r12d
movl %r12d, %eax
cmpq %rax, %r15
jae 0x42ad
movl 0x68(%rsp,%r15,4), %edi
callq 0x20a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2390
movl 0x64(%rsp), %r12d
leal -0x1(%r12), %eax
cmpq %rax, %r15
je 0x42a8
movq %rbx, %rdi
callq 0x20f0
movw $0x202c, 0xb0(%rsp,%rax) # imm = 0x202C
movb $0x0, 0xb2(%rsp,%rax)
incq %r15
jmp 0x4262
leaq 0x22c5(%rip), %rsi      # 0x6579
leaq 0x210d(%rip), %rdx      # 0x63c8
leaq 0x1e14(%rip), %rcx      # 0x60d6
leaq 0xb0(%rsp), %r9
xorl %edi, %edi
movl $0x5d3, %r8d            # imm = 0x5D3
xorl %eax, %eax
callq 0x2380
movq 0x48(%rsp), %rbx
movb $0x1, (%rbx)
leaq 0x4f0(%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 %r13, 0x38(%rbx)
movq %r14, 0x60(%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rbx)
movq 0x40(%rsp), %rax
movq %rax, 0x48(%rbx)
movq %rbp, 0x50(%rbx)
andq $0x0, 0x4(%rbx)
callq 0x2300
movq %rax, 0x58(%rbx)
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2190
leaq 0x204c(%rip), %rsi      # 0x6396
leaq 0x2077(%rip), %rdx      # 0x63c8
leaq 0x1d7e(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x574, %r8d            # imm = 0x574
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4591
leaq 0x1d3a(%rip), %rsi      # 0x60b0
leaq 0x204b(%rip), %rdx      # 0x63c8
leaq 0x1d52(%rip), %rcx      # 0x60d6
leaq 0x204a(%rip), %r9       # 0x63d5
xorl %edi, %edi
movl $0x57d, %r8d            # imm = 0x57D
xorl %eax, %eax
callq 0x22e0
jmp 0x458c
callq 0x2190
leaq 0x2290(%rip), %rsi      # 0x663b
leaq 0x22c9(%rip), %rdx      # 0x667b
leaq 0x1d1d(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x745, %r8d            # imm = 0x745
jmp 0x43e5
callq 0x2190
leaq 0x22bc(%rip), %rsi      # 0x668b
leaq 0x22a5(%rip), %rdx      # 0x667b
leaq 0x1cf9(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x759, %r8d            # imm = 0x759
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4498
callq 0x2190
leaq 0x22f4(%rip), %rsi      # 0x66f4
leaq 0x2274(%rip), %rdx      # 0x667b
leaq 0x1cc8(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x776, %r8d            # imm = 0x776
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4490
callq 0x2190
leaq 0x22fd(%rip), %rsi      # 0x672b
leaq 0x2246(%rip), %rdx      # 0x667b
leaq 0x1c9a(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x784, %r8d            # imm = 0x784
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
movq %rbx, %rdi
jmp 0x448b
leaq 0x1c56(%rip), %rsi      # 0x60b0
leaq 0x221a(%rip), %rdx      # 0x667b
leaq 0x1c6e(%rip), %rcx      # 0x60d6
leaq 0x22f2(%rip), %r9       # 0x6761
xorl %edi, %edi
movl $0x78e, %r8d            # imm = 0x78E
xorl %eax, %eax
callq 0x22e0
movq %r12, %rdi
callq 0x2160
movq 0x20(%rsp), %rdi
callq 0x20c0
movq %rbp, %rdi
callq 0x2030
leaq 0x1c11(%rip), %rsi      # 0x60b0
leaq 0x1f22(%rip), %rdx      # 0x63c8
leaq 0x1c29(%rip), %rcx      # 0x60d6
leaq 0x1f3e(%rip), %r9       # 0x63f2
xorl %edi, %edi
movl $0x588, %r8d            # imm = 0x588
xorl %eax, %eax
callq 0x22e0
jmp 0x4582
leaq 0x1be1(%rip), %rbx      # 0x60b0
leaq 0x22b0(%rip), %rdx      # 0x6786
leaq 0x1bf9(%rip), %r15      # 0x60d6
leaq 0x22b4(%rip), %r9       # 0x6798
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x7f1, %r8d            # imm = 0x7F1
xorl %eax, %eax
callq 0x22e0
leaq 0x1ec8(%rip), %rdx      # 0x63c8
leaq 0x1f03(%rip), %r9       # 0x640a
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x591, %r8d            # imm = 0x591
xorl %eax, %eax
callq 0x22e0
jmp 0x457a
leaq 0x1b8b(%rip), %rbx      # 0x60b0
leaq 0x2293(%rip), %rdx      # 0x67bf
leaq 0x1ba3(%rip), %r15      # 0x60d6
leaq 0x2294(%rip), %r9       # 0x67ce
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x805, %r8d            # imm = 0x805
xorl %eax, %eax
callq 0x22e0
leaq 0x1e72(%rip), %rdx      # 0x63c8
leaq 0x1ec7(%rip), %r9       # 0x6424
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x59b, %r8d            # imm = 0x59B
xorl %eax, %eax
callq 0x22e0
movq %r12, %rdi
callq 0x2290
movq %r14, %rdi
callq 0x46aa
movq 0x8(%rsp), %rdi
callq 0x3bb8
callq 0x2060
pushq $0x1
popq %rdi
callq 0x22a0
callq 0x2190
leaq 0x224d(%rip), %rsi      # 0x67f2
leaq 0x227f(%rip), %rdx      # 0x682b
leaq 0x1b23(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x82a, %r8d            # imm = 0x82A
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x465e
leaq 0x1adf(%rip), %rsi      # 0x60b0
leaq 0x2253(%rip), %rdx      # 0x682b
leaq 0x1af7(%rip), %rcx      # 0x60d6
leaq 0x2254(%rip), %r9       # 0x683a
xorl %edi, %edi
movl $0x830, %r8d            # imm = 0x830
xorl %eax, %eax
callq 0x22e0
jmp 0x4655
leaq 0x2268(%rip), %rsi      # 0x6866
leaq 0x2226(%rip), %rdx      # 0x682b
leaq 0x1aca(%rip), %rcx      # 0x60d6
xorl %edi, %edi
movl $0x83c, %r8d            # imm = 0x83C
movl %r12d, %r9d
xorl %eax, %eax
callq 0x22e0
jmp 0x4655
leaq 0x1a89(%rip), %rsi      # 0x60b0
leaq 0x21fd(%rip), %rdx      # 0x682b
leaq 0x1aa1(%rip), %rcx      # 0x60d6
leaq 0x2274(%rip), %r9       # 0x68b0
xorl %edi, %edi
movl $0x844, %r8d            # imm = 0x844
xorl %eax, %eax
callq 0x22e0
movq 0x38(%rsp), %rdi
callq 0x2290
movl 0x4(%rsp), %edi
callq 0x20d0
leaq 0x1a4b(%rip), %rsi      # 0x60b0
leaq 0x1d5c(%rip), %rdx      # 0x63c8
leaq 0x1a63(%rip), %rcx      # 0x60d6
leaq 0x1dc1(%rip), %r9       # 0x643b
xorl %edi, %edi
movl $0x5aa, %r8d            # imm = 0x5AA
xorl %eax, %eax
callq 0x22e0
movq 0x18(%rsp), %rdi
callq 0x2290
movq %r14, %rdi
callq 0x46aa
movq 0x8(%rsp), %rdi
callq 0x3bb8
jmp 0x4591