// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
leaq 0x10(%rbp), %rax
movq %rax, -0x4b0(%rbp)
movq %rdi, -0x10(%rbp)
movl $0x20, -0x14(%rbp)
testb $0x1, 0x1c(%rax)
je 0x4a61
movl -0x14(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edi
callq 0x2200
cmpl $0x0, %eax
je 0x4aa4
callq 0x2190
movq %rax, %r9
xorl %edi, %edi
leaq 0x28f7(%rip), %rsi      # 0x7376
leaq 0x2922(%rip), %rdx      # 0x73a8
leaq 0x2629(%rip), %rcx      # 0x70b6
movl $0x574, %r8d            # imm = 0x574
movb $0x0, %al
callq 0x22e0
movl $0x1, %edi
callq 0x22a0
movq -0x4b0(%rbp), %rax
movl (%rax), %edi
movl 0x4(%rax), %esi
callq 0x2b00
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4afa
xorl %edi, %edi
leaq 0x25c7(%rip), %rsi      # 0x7090
leaq 0x28d8(%rip), %rdx      # 0x73a8
leaq 0x25df(%rip), %rcx      # 0x70b6
movl $0x57d, %r8d            # imm = 0x57D
leaq 0x28d1(%rip), %r9       # 0x73b5
movb $0x0, %al
callq 0x22e0
callq 0x2060
movl $0x1, %edi
callq 0x22a0
movq -0x4b0(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
movb 0x14(%rax), %cl
movb 0x15(%rax), %r8b
movb 0x16(%rax), %r9b
movb 0x18(%rax), %al
andb $0x1, %cl
andb $0x1, %r8b
andb $0x1, %r9b
andb $0x1, %al
movzbl %cl, %ecx
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movzbl %al, %eax
movl %eax, (%rsp)
callq 0x4f70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4b8b
xorl %edi, %edi
leaq 0x253f(%rip), %rsi      # 0x7090
leaq 0x2850(%rip), %rdx      # 0x73a8
leaq 0x2557(%rip), %rcx      # 0x70b6
movl $0x588, %r8d            # imm = 0x588
leaq 0x2866(%rip), %r9       # 0x73d2
movb $0x0, %al
callq 0x22e0
movq -0x20(%rbp), %rdi
callq 0x4670
callq 0x2060
movl $0x1, %edi
callq 0x22a0
callq 0x5390
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4be7
xorl %edi, %edi
leaq 0x24ec(%rip), %rsi      # 0x7090
leaq 0x27fd(%rip), %rdx      # 0x73a8
leaq 0x2504(%rip), %rcx      # 0x70b6
movl $0x591, %r8d            # imm = 0x591
leaq 0x282b(%rip), %r9       # 0x73ea
movb $0x0, %al
callq 0x22e0
movq -0x28(%rbp), %rdi
callq 0x5420
movq -0x20(%rbp), %rdi
callq 0x4670
callq 0x2060
movl $0x1, %edi
callq 0x22a0
callq 0x5470
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4c4c
xorl %edi, %edi
leaq 0x2490(%rip), %rsi      # 0x7090
leaq 0x27a1(%rip), %rdx      # 0x73a8
leaq 0x24a8(%rip), %rcx      # 0x70b6
movl $0x59b, %r8d            # imm = 0x59B
leaq 0x27e9(%rip), %r9       # 0x7404
movb $0x0, %al
callq 0x22e0
movq -0x30(%rbp), %rdi
callq 0x2290
movq -0x28(%rbp), %rdi
callq 0x5420
movq -0x20(%rbp), %rdi
callq 0x4670
callq 0x2060
movl $0x1, %edi
callq 0x22a0
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl 0x4(%rax), %r8d
callq 0x54e0
movq -0x4b0(%rbp), %rax
movq $0x0, -0x40(%rbp)
testb $0x1, 0x1c(%rax)
je 0x4ce7
callq 0x6a00
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4ce5
xorl %edi, %edi
leaq 0x23f2(%rip), %rsi      # 0x7090
leaq 0x2703(%rip), %rdx      # 0x73a8
leaq 0x240a(%rip), %rcx      # 0x70b6
movl $0x5aa, %r8d            # imm = 0x5AA
leaq 0x2762(%rip), %r9       # 0x741b
movb $0x0, %al
callq 0x22e0
movq -0x30(%rbp), %rdi
callq 0x2290
movq -0x28(%rbp), %rdi
callq 0x5420
movq -0x20(%rbp), %rdi
callq 0x4670
movl $0x1, %edi
callq 0x22a0
jmp 0x4ce7
movq 0x651a(%rip), %rdx      # 0xb208
leaq 0x653b(%rip), %rdi      # 0xb230
movl $0x400, %esi            # imm = 0x400
callq 0x5570
movq 0x650a(%rip), %rdx      # 0xb210
leaq 0x6923(%rip), %rdi      # 0xb630
movl $0x300, %esi            # imm = 0x300
callq 0x5570
movq -0x4b0(%rbp), %rax
movq 0x8(%rax), %r9
movq -0x20(%rbp), %rax
movl (%rax), %ebx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r11d
movq -0x28(%rbp), %rax
movl 0x8(%rax), %r10d
movq -0x28(%rbp), %rax
movb 0x48(%rax), %al
andb $0x1, %al
movzbl %al, %eax
xorl %edi, %edi
leaq 0x26ec(%rip), %rsi      # 0x7439
leaq 0x2654(%rip), %rdx      # 0x73a8
leaq 0x235b(%rip), %rcx      # 0x70b6
movl $0x5be, %r8d            # imm = 0x5BE
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x2390
movq -0x4b0(%rbp), %rax
testb $0x1, 0x1c(%rax)
je 0x4de1
movq -0x40(%rbp), %rax
movl (%rax), %r9d
movq -0x40(%rbp), %rax
movzbl 0x8(%rax), %ebx
movq -0x40(%rbp), %rax
movl 0x4(%rax), %r11d
movq -0x40(%rbp), %rax
movl 0x10(%rax), %r10d
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
xorl %edi, %edi
leaq 0x26f4(%rip), %rsi      # 0x74a9
leaq 0x25ec(%rip), %rdx      # 0x73a8
leaq 0x22f3(%rip), %rcx      # 0x70b6
movl $0x5c5, %r8d            # imm = 0x5C5
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x2390
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2320
movq -0x98(%rbp), %r9
xorl %edi, %edi
leaq 0x272a(%rip), %rsi      # 0x752f
leaq 0x259c(%rip), %rdx      # 0x73a8
leaq 0x22a3(%rip), %rcx      # 0x70b6
movl $0x5ca, %r8d            # imm = 0x5CA
movb $0x0, %al
callq 0x2390
leaq -0x4a0(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2100
movl $0x0, -0x4a4(%rbp)
movl -0x4a4(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jae 0x4eb3
leaq -0x4a0(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movl -0x4a4(%rbp), %eax
movl -0x88(%rbp,%rax,4), %edi
callq 0x20a0
movq -0x4b8(%rbp), %rdi
movq %rax, %rsi
callq 0x23a0
movl -0x4a4(%rbp), %eax
movl -0x8c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x4ea0
leaq -0x4a0(%rbp), %rdi
leaq 0x26bb(%rip), %rsi      # 0x7556
callq 0x23a0
jmp 0x4ea2
movl -0x4a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4a4(%rbp)
jmp 0x4e3d
leaq -0x4a0(%rbp), %r9
xorl %edi, %edi
leaq 0x2696(%rip), %rsi      # 0x7559
leaq 0x24de(%rip), %rdx      # 0x73a8
leaq 0x21e5(%rip), %rcx      # 0x70b6
movl $0x5d3, %r8d            # imm = 0x5D3
movb $0x0, %al
callq 0x2390
movq -0x4b0(%rbp), %rsi
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movl $0x28, %edx
callq 0x21c0
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
callq 0x2660
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %rbp
retq
nopl (%rax)