// File: /workspace/github_c_makefile_star2_O3/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 0x4513
leaq 0x4f0(%rsp), %rbx
movl (%rbx), %edi
movl 0x4(%rbx), %esi
callq 0x2862
testq %rax, %rax
je 0x4544
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 0x4574
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 0x4598
movq %rax, %rbp
testb %r14b, %r14b
je 0x4063
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
movl $0x2, %ebx
cmpb $0x0, 0x3(%rsp)
je 0x4091
leaq 0x2670(%rip), %rdi      # 0x66f0
leaq 0x267a(%rip), %rsi      # 0x6701
callq 0x2370
movl $0x6, %ebx
movq %r12, 0x50(%rsp)
leaq 0x2666(%rip), %rdi      # 0x6703
leaq 0x2678(%rip), %rsi      # 0x671c
callq 0x2370
movq %rbp, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %ebx, %edx
callq 0x2040
testq %rax, %rax
je 0x45c9
movq %rax, %rbx
movq %rax, %rdi
movq 0x30(%rsp), %r14
movl %r14d, %esi
movq 0x28(%rsp), %r12
movl %r12d, %edx
callq 0x2080
movq %rbx, %rdi
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x23a0
testq %rax, %rax
je 0x45f7
movq %rax, %r12
movq %rbx, 0x20(%rsp)
movq %r13, 0x48(%rsp)
movl $0x68, %edi
callq 0x22f0
testq %rax, %rax
je 0x4628
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
movl $0x3c, %r15d
cmovnel %eax, %r15d
cvtsi2sd %r15d, %xmm0
movl %r15d, 0x8(%r14)
movsd 0x1f6d(%rip), %xmm1     # 0x60c0
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)
movl $0x0, 0x40(%r14)
callq 0x2300
movq %rax, %xmm0
punpckldq 0x1e95(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1e9d(%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)
movl $0x1, %edi
movl $0x400, %esi            # imm = 0x400
callq 0x2150
testq %rax, %rax
je 0x469d
movq %rax, %r12
movl $0x14, %edi
callq 0x22f0
testq %rax, %rax
je 0x46f3
movq %rax, %rbp
movq %rax, %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl %r13d, %ecx
movl %ebx, %r8d
callq 0x48a9
cmpb $0x0, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %rbp, 0x40(%rsp)
je 0x431d
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
xorl %edi, %edi
xorl %esi, %esi
movl $0x2, %r8d
callq 0x22b0
testl %eax, %eax
je 0x4770
movl %eax, 0x4(%rsp)
movzwl 0x5c(%rsp), %eax
cmpw 0xb4(%rsp), %ax
jne 0x47a1
movslq 0x58(%rsp), %rbx
imulq $-0x77777777, %rbx, %r13 # imm = 0x88888889
shrq $0x20, %r13
addl %ebx, %r13d
movl %r13d, %eax
shrl $0x1f, %eax
sarl $0x3, %r13d
addl %eax, %r13d
leal (,%r13,4), %r12d
movq %r12, %rdi
callq 0x22f0
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x47ce
movl $0xa8, %edi
callq 0x22f0
testq %rax, %rax
je 0x47f7
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)
movl $0x0, 0xa0(%rbp)
xorl %esi, %esi
callq 0x22d0
jmp 0x431f
xorl %ebp, %ebp
movq 0x8(%rsp), %r13
movzbl 0x3(%rsp), %ebx
leaq 0x5ef0(%rip), %rdi      # 0xa220
leaq 0x25cd(%rip), %rdx      # 0x6904
movl $0x400, %esi            # imm = 0x400
callq 0x4939
leaq 0x62d8(%rip), %rdi      # 0xa620
leaq 0x2b0e(%rip), %rdx      # 0x6e5d
movl $0x300, %esi            # imm = 0x300
callq 0x4939
leaq 0x2129(%rip), %rsi      # 0x6489
leaq 0x2091(%rip), %rdx      # 0x63f8
leaq 0x1d98(%rip), %rcx      # 0x6106
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 0x43db
movzbl 0x8(%rbp), %r10d
movl (%rbp), %r9d
movl 0x4(%rbp), %r11d
movl 0x10(%rbp), %ebx
movl 0xc(%rbp), %r15d
leaq 0x2146(%rip), %rsi      # 0x64f9
leaq 0x203e(%rip), %rdx      # 0x63f8
leaq 0x1d45(%rip), %rcx      # 0x6106
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), %rbx
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x2320
movq (%rbx), %r9
leaq 0x2188(%rip), %rsi      # 0x657f
leaq 0x1ffa(%rip), %rdx      # 0x63f8
leaq 0x1d01(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x5ca, %r8d            # imm = 0x5CA
xorl %eax, %eax
callq 0x2380
leaq 0xb0(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x2100
cmpl $0x0, 0xc(%rbx)
je 0x447f
xorl %r15d, %r15d
leaq 0xb0(%rsp), %rbx
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 0x4477
movq %rbx, %rdi
callq 0x20f0
movw $0x202c, 0xb0(%rsp,%rax) # imm = 0x202C
movb $0x0, 0xb2(%rsp,%rax)
incq %r15
cmpq %r12, %r15
jb 0x4439
leaq 0x2123(%rip), %rsi      # 0x65a9
leaq 0x1f6b(%rip), %rdx      # 0x63f8
leaq 0x1c72(%rip), %rcx      # 0x6106
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)
movq $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 0x1ea7(%rip), %rsi      # 0x63c6
leaq 0x1ed2(%rip), %rdx      # 0x63f8
leaq 0x1bd9(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x574, %r8d            # imm = 0x574
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4766
leaq 0x1b95(%rip), %rsi      # 0x60e0
leaq 0x1ea6(%rip), %rdx      # 0x63f8
leaq 0x1bad(%rip), %rcx      # 0x6106
leaq 0x1ea5(%rip), %r9       # 0x6405
xorl %edi, %edi
movl $0x57d, %r8d            # imm = 0x57D
xorl %eax, %eax
callq 0x22e0
jmp 0x4761
callq 0x2190
leaq 0x20eb(%rip), %rsi      # 0x666b
leaq 0x2124(%rip), %rdx      # 0x66ab
leaq 0x1b78(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x745, %r8d            # imm = 0x745
jmp 0x45ba
callq 0x2190
leaq 0x2117(%rip), %rsi      # 0x66bb
leaq 0x2100(%rip), %rdx      # 0x66ab
leaq 0x1b54(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x759, %r8d            # imm = 0x759
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x466d
callq 0x2190
leaq 0x214f(%rip), %rsi      # 0x6724
leaq 0x20cf(%rip), %rdx      # 0x66ab
leaq 0x1b23(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x776, %r8d            # imm = 0x776
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4665
callq 0x2190
leaq 0x2158(%rip), %rsi      # 0x675b
leaq 0x20a1(%rip), %rdx      # 0x66ab
leaq 0x1af5(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x784, %r8d            # imm = 0x784
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
movq %rbx, %rdi
jmp 0x4660
leaq 0x1ab1(%rip), %rsi      # 0x60e0
leaq 0x2075(%rip), %rdx      # 0x66ab
leaq 0x1ac9(%rip), %rcx      # 0x6106
leaq 0x214d(%rip), %r9       # 0x6791
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 0x1a6c(%rip), %rsi      # 0x60e0
leaq 0x1d7d(%rip), %rdx      # 0x63f8
leaq 0x1a84(%rip), %rcx      # 0x6106
leaq 0x1d99(%rip), %r9       # 0x6422
xorl %edi, %edi
movl $0x588, %r8d            # imm = 0x588
xorl %eax, %eax
callq 0x22e0
jmp 0x4757
leaq 0x1a3c(%rip), %rbx      # 0x60e0
leaq 0x210b(%rip), %rdx      # 0x67b6
leaq 0x1a54(%rip), %r15      # 0x6106
leaq 0x210f(%rip), %r9       # 0x67c8
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x7f1, %r8d            # imm = 0x7F1
xorl %eax, %eax
callq 0x22e0
leaq 0x1d23(%rip), %rdx      # 0x63f8
leaq 0x1d5e(%rip), %r9       # 0x643a
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x591, %r8d            # imm = 0x591
xorl %eax, %eax
callq 0x22e0
jmp 0x474f
leaq 0x19e6(%rip), %rbx      # 0x60e0
leaq 0x20ee(%rip), %rdx      # 0x67ef
leaq 0x19fe(%rip), %r15      # 0x6106
leaq 0x20ef(%rip), %r9       # 0x67fe
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
movl $0x805, %r8d            # imm = 0x805
xorl %eax, %eax
callq 0x22e0
leaq 0x1ccd(%rip), %rdx      # 0x63f8
leaq 0x1d22(%rip), %r9       # 0x6454
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 0x4881
movq 0x8(%rsp), %rdi
callq 0x3d58
callq 0x2060
movl $0x1, %edi
callq 0x22a0
callq 0x2190
leaq 0x20a6(%rip), %rsi      # 0x6822
leaq 0x20d8(%rip), %rdx      # 0x685b
leaq 0x197c(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x82a, %r8d            # imm = 0x82A
movq %rax, %r9
xorl %eax, %eax
callq 0x22e0
jmp 0x4835
leaq 0x1938(%rip), %rsi      # 0x60e0
leaq 0x20ac(%rip), %rdx      # 0x685b
leaq 0x1950(%rip), %rcx      # 0x6106
leaq 0x20ad(%rip), %r9       # 0x686a
xorl %edi, %edi
movl $0x830, %r8d            # imm = 0x830
xorl %eax, %eax
callq 0x22e0
jmp 0x482c
leaq 0x20c1(%rip), %rsi      # 0x6896
leaq 0x207f(%rip), %rdx      # 0x685b
leaq 0x1923(%rip), %rcx      # 0x6106
xorl %edi, %edi
movl $0x83c, %r8d            # imm = 0x83C
movl %r12d, %r9d
xorl %eax, %eax
callq 0x22e0
jmp 0x482c
leaq 0x18e2(%rip), %rsi      # 0x60e0
leaq 0x2056(%rip), %rdx      # 0x685b
leaq 0x18fa(%rip), %rcx      # 0x6106
leaq 0x20cd(%rip), %r9       # 0x68e0
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 0x18a4(%rip), %rsi      # 0x60e0
leaq 0x1bb5(%rip), %rdx      # 0x63f8
leaq 0x18bc(%rip), %rcx      # 0x6106
leaq 0x1c1a(%rip), %r9       # 0x646b
xorl %edi, %edi
movl $0x5aa, %r8d            # imm = 0x5AA
xorl %eax, %eax
callq 0x22e0
movq 0x18(%rsp), %rdi
callq 0x2290
movq %r14, %rdi
callq 0x4881
movq 0x8(%rsp), %rdi
callq 0x3d58
jmp 0x4766