// File: /workspace/github_cpp_makefile_star2_O2/eiskalteschatten[P]developersnotebook/src/views/ProjectsView.cpp
// Function: save_project(_GtkWidget*, ProjectsView*)
void save_project(GtkWidget *widget, ProjectsView *pv) {
    GtkTreeModel *model = nullptr;
    GtkTreeIter tree_iter;

    // Now datetime object
    auto now               = std::time(nullptr);
    struct std::tm *now_tm = std::localtime(&now);
    std::string now_str    = pv->format_date_time(now_tm);

    // Form values
    int id                     = -1;
    gchar *id_char             = nullptr;
    const gchar *name          = gtk_entry_get_text(GTK_ENTRY(pv->project_name_input));
    bool is_complete           = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pv->is_complete_checkbox));
    std::string date_completed = is_complete ? now_str : "";

    GtkTextIter start;
    GtkTextIter end;
    GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pv->notes_input));

    gtk_text_buffer_get_bounds(buffer, &start, &end);

    const gchar *notes = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);

    if (name && !name[0]) {
        Modal modal("No Project Name", "You must enter a project name to create a new project.", pv->main_window);
        modal.show_error_modal();
        return;
    }

    // Start date calendar values
    guint start_year;
    guint start_month;
    guint start_day;

    gtk_calendar_get_date(GTK_CALENDAR(pv->start_date_input), &start_year, &start_month, &start_day);

    std::string start_date_str = start_day == 0 ? "" : pv->format_date(&start_year, &start_month, &start_day);

    // End date calendar values
    guint end_year;
    guint end_month;
    guint end_day;

    gtk_calendar_get_date(GTK_CALENDAR(pv->end_date_input), &end_year, &end_month, &end_day);

    std::string end_date_str = end_day == 0 ? "" : pv->format_date(&end_year, &end_month, &end_day);

    // Start saving
    if (gtk_tree_selection_get_selected(pv->select, &model, &tree_iter)) {
        gtk_tree_model_get(model, &tree_iter, ID_COLUMN, &id_char, -1);
        id = std::stoi(id_char);
        g_free(id_char);
    }

    ProjectsModel *projects_model = id != -1 ? new ProjectsModel(id) : new ProjectsModel();

    if (id == -1) {
        projects_model->set_date_created(now_str, FALSE);
        pv->prepend_to_list_store(&tree_iter);
    }

    projects_model->set_name(name, FALSE);
    projects_model->set_start_date(start_date_str, FALSE);
    projects_model->set_end_date(end_date_str, FALSE);
    projects_model->set_url(std::string(gtk_entry_get_text(GTK_ENTRY(pv->url_input))), FALSE);
    projects_model->set_notes(notes, FALSE);
    projects_model->set_is_complete(is_complete, FALSE);
    projects_model->set_date_completed(date_completed, FALSE);

    projects_model->save_all();

    projects_model->truncate_notes();

    pv->set_list_store(projects_model, &tree_iter);
    pv->select_row_in_list_view(&tree_iter);

    delete projects_model;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rsi, %rbx
andq $0x0, 0x30(%rsp)
xorl %edi, %edi
callq 0x8950
leaq 0x200(%rsp), %rdi
movq %rax, (%rdi)
callq 0x8820
leaq 0xa0(%rsp), %rdi
movq %rax, %rsi
callq 0xec34
orl $-0x1, 0x8(%rsp)
andq $0x0, 0x18(%rsp)
movq 0x60(%rbx), %r15
callq 0x84b0
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x90e0
movq %rax, %r12
movq 0x98(%rbx), %r15
callq 0x8f50
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x83e0
movl %eax, %ebp
testl %eax, %eax
je 0xbc72
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x86e0
jmp 0xbc8e
leaq 0x16cec(%rip), %rsi     # 0x22965
leaq 0x80(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0xb078
movq 0x90(%rbx), %r15
callq 0x88d0
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x8330
movq %rax, %r15
leaq 0x258(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
movq %rax, %rdi
callq 0x80b0
leaq 0x258(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x8eb0
testq %r12, %r12
je 0xbcf2
cmpb $0x0, (%r12)
je 0xc074
movq %rax, 0x58(%rsp)
movq 0x68(%rbx), %r15
callq 0x8570
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x14(%rsp), %rcx
movq %rax, %rdi
callq 0x8fe0
cmpl $0x0, 0x14(%rsp)
je 0xbd4a
leaq 0x208(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq 0xeb78
jmp 0xbd63
leaq 0x16c14(%rip), %rsi     # 0x22965
leaq 0x208(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xb078
movq 0x78(%rbx), %rdi
movq %r13, %rsi
callq 0x8150
leaq 0x24(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %rax, %rdi
callq 0x8fe0
cmpl $0x0, 0x10(%rsp)
je 0xbda8
leaq 0x60(%rsp), %rdi
leaq 0x24(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xeb78
jmp 0xbdbe
leaq 0x16bb6(%rip), %rsi     # 0x22965
leaq 0x60(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0xb078
movq 0x40(%rbx), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x8dd0
testl %eax, %eax
je 0xbe32
movq 0x30(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x18(%rsp), %rcx
pushq $-0x1
popq %r8
xorl %edx, %edx
xorl %eax, %eax
callq 0x8890
movq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xb078
leaq 0x38(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0xe20f
movl %eax, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x9120
movq 0x18(%rsp), %rdi
callq 0x9118
cmpl $-0x1, 0x8(%rsp)
je 0xbe55
movl $0x148, %edi            # imm = 0x148
callq 0x81c0
movq %rax, %r13
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x1f966
jmp 0xbe6a
movl $0x148, %edi            # imm = 0x148
callq 0x81c0
movq %rax, %r13
movq %rax, %rdi
callq 0x1f880
cmpl $-0x1, 0x8(%rsp)
jne 0xbeb5
leaq 0x1a0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x86e0
leaq 0x1a0(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x200a8
leaq 0x1a0(%rsp), %rdi
callq 0x9120
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0xc256
leaq 0x180(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %r12, %rsi
callq 0xb078
leaq 0x180(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1fd8a
leaq 0x180(%rsp), %rdi
callq 0x9120
leaq 0x160(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x86e0
leaq 0x160(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1fdfa
leaq 0x160(%rsp), %rdi
callq 0x9120
leaq 0x140(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x86e0
leaq 0x140(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1fe6e
leaq 0x140(%rsp), %rdi
callq 0x9120
movq 0x88(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x90e0
leaq 0x120(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq %rax, %rsi
callq 0xb078
leaq 0x120(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1fee2
leaq 0x120(%rsp), %rdi
callq 0x9120
leaq 0x100(%rsp), %rdi
leaq 0x38(%rsp), %rdx
movq 0x58(%rsp), %rsi
callq 0xb078
leaq 0x100(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x1ff56
xorl %r14d, %r14d
testl %ebp, %ebp
setne %r14b
leaq 0x100(%rsp), %rdi
callq 0x9120
movq %r13, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1ffca
leaq 0xe0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x86e0
leaq 0xe0(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x20034
leaq 0xe0(%rsp), %rdi
callq 0x9120
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
movq %r13, %rdi
callq 0x20598
leaq 0xc0(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc284
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0xc572
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
leaq 0x60(%rsp), %rdi
callq 0x9120
leaq 0x208(%rsp), %rdi
callq 0x9120
jmp 0xc0fa
leaq 0x160d9(%rip), %rsi     # 0x22154
leaq 0x1e0(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xb078
leaq 0x160d0(%rip), %rsi     # 0x22164
leaq 0x1c0(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0xb078
movq (%rbx), %rcx
leaq 0x208(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
callq 0x20f0c
leaq 0x1c0(%rsp), %rdi
callq 0x9120
leaq 0x1e0(%rsp), %rdi
callq 0x9120
leaq 0x208(%rsp), %rdi
callq 0x2111a
leaq 0x208(%rsp), %rdi
callq 0x21100
leaq 0x80(%rsp), %rdi
callq 0x9120
leaq 0xa0(%rsp), %rdi
callq 0x9120
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x21100
jmp 0xc234
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x9120
jmp 0xc150
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
jmp 0xc22f
jmp 0xc215
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
jmp 0xc1fa
jmp 0xc183
jmp 0xc205
jmp 0xc215
jmp 0xc210
movq %rax, %rbx
movl $0x148, %esi            # imm = 0x148
movq %r13, %rdi
callq 0x8190
jmp 0xc21d
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0xc1fa
jmp 0xc21a
jmp 0xc205
jmp 0xc215
jmp 0xc210
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0xc1fa
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0xc1fa
jmp 0xc21a
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0xc1fa
jmp 0xc21a
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0xc1fa
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0xc1fa
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x9120
jmp 0xc21d
jmp 0xc21a
jmp 0xc215
movq %rax, %rbx
jmp 0xc227
jmp 0xc215
jmp 0xc21a
jmp 0xc210
movq %rax, %rbx
jmp 0xc241
movq %rax, %rbx
jmp 0xc234
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x9120
leaq 0x208(%rsp), %rdi
callq 0x9120
leaq 0x80(%rsp), %rdi
callq 0x9120
leaq 0xa0(%rsp), %rdi
callq 0x9120
movq %rbx, %rdi
callq 0x87f0