// File: /workspace/github_cpp_makefile_star2_O1/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 $0x308, %rsp            # imm = 0x308
movq %rsi, %rbx
xorl %r14d, %r14d
movq %r14, 0x30(%rsp)
xorl %edi, %edi
callq 0x8910
leaq 0x258(%rsp), %rdi
movq %rax, (%rdi)
callq 0x87e0
leaq 0x98(%rsp), %rdi
movq %rax, %rsi
callq 0x11ff8
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %r14, 0x10(%rsp)
movq 0x60(%rbx), %r15
callq 0x84a0
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x9090
movq %rax, %r12
movq 0x98(%rbx), %r15
callq 0x8f20
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x83d0
movl %eax, %r14d
leaq 0x48(%rsp), %rbp
movq %rbp, -0x10(%rbp)
testl %eax, %eax
je 0xe70b
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0xd524
jmp 0xe71f
leaq 0x1b243(%rip), %rdx     # 0x29955
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0xd5b4
movq 0x90(%rbx), %r15
callq 0x8890
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x8320
movq %rax, %r15
leaq 0x2b8(%rsp), %rsi
leaq 0x268(%rsp), %rdx
movq %rax, %rdi
callq 0x80b0
leaq 0x2b8(%rsp), %rsi
leaq 0x268(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x8e70
testq %r12, %r12
je 0xe783
cmpb $0x0, (%r12)
je 0xec92
movq %rax, 0xb8(%rsp)
movq %r13, 0xc0(%rsp)
movl %r14d, 0x1c(%rsp)
movq 0x68(%rbx), %r15
callq 0x8540
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x8150
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %rax, %rdi
callq 0x8f90
cmpl $0x0, 0xc(%rsp)
je 0xe7eb
leaq 0x1e8(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x11f10
jmp 0xe80e
leaq 0x1f8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1b157(%rip), %rdx     # 0x29955
leaq 0x1e8(%rsp), %rdi
movq %rdx, %rsi
callq 0xd5b4
movq 0x78(%rbx), %rdi
movq %r13, %rsi
callq 0x8150
leaq 0x24(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rax, %rdi
callq 0x8f90
cmpl $0x0, 0x8(%rsp)
je 0xe853
leaq 0x78(%rsp), %rdi
leaq 0x24(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x11f10
jmp 0xe873
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1b0ef(%rip), %rdx     # 0x29955
leaq 0x78(%rsp), %rdi
movq %rdx, %rsi
callq 0xd5b4
movq 0x40(%rbx), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x238(%rsp), %rdx
callq 0x8d90
testl %eax, %eax
je 0xe94c
movq 0x30(%rsp), %rdi
leaq 0x238(%rsp), %rsi
leaq 0x10(%rsp), %rcx
xorl %edx, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x8850
movq 0x10(%rsp), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xd45e
movq 0x58(%rsp), %r15
callq 0x8cf0
movq %rax, %r13
movl (%rax), %r14d
movl $0x0, (%rax)
leaq 0x260(%rsp), %rbp
movq %r15, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x8b70
cmpq %r15, (%rbp)
je 0xed9e
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0xedaa
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0xedaa
testl %ecx, %ecx
leaq 0x48(%rsp), %rbp
jne 0xe924
movl %r14d, (%r13)
movl %eax, (%rsp)
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe942
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x10(%rsp), %rdi
callq 0x90c8
cmpl $-0x1, (%rsp)
je 0xe96c
movl $0x148, %edi            # imm = 0x148
callq 0x81a0
movq %rax, %r13
movq %rsp, %rsi
movq %rax, %rdi
callq 0x26864
jmp 0xe981
movl $0x148, %edi            # imm = 0x148
callq 0x81a0
movq %rax, %r13
movq %rax, %rdi
callq 0x26784
cmpl $-0x1, (%rsp)
jne 0xe9f2
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %rdi
callq 0xd524
leaq 0x128(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x272e0
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xe9e2
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x238(%rsp), %rsi
movq %rbx, %rdi
callq 0xeff2
leaq 0x1c8(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %r12, %rsi
callq 0xd45e
leaq 0x1c8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26eb6
leaq 0x1d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xea3a
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x1e8(%rsp), %rsi
movq 0x1f0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0xd524
leaq 0x108(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26f4c
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0xea95
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe8(%rsp), %rdi
callq 0xd524
leaq 0xe8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26fe6
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xeaed
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x88(%rbx), %rdi
movq 0xc0(%rsp), %rsi
callq 0x8150
movq %rax, %rdi
callq 0x9090
leaq 0x1a8(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %rax, %rsi
callq 0xd45e
leaq 0x1a8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x27080
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xeb51
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x188(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq 0xb8(%rsp), %rsi
callq 0xd45e
leaq 0x188(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x2711a
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xeb9e
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x8170
xorl %esi, %esi
cmpl $0x0, 0x1c(%rsp)
setne %sil
movq %r13, %rdi
xorl %edx, %edx
callq 0x271b4
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0xd524
leaq 0xc8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x27246
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0xec08
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
movq %r13, %rdi
callq 0x2792c
leaq 0x238(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf020
leaq 0x238(%rsp), %rsi
movq %rbx, %rdi
callq 0xf4f4
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xec68
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1f8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xed54
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xed54
leaq 0x178(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a4af(%rip), %rsi     # 0x29154
leaq 0x1a4b7(%rip), %rdx     # 0x29163
leaq 0x168(%rsp), %rdi
callq 0xd5b4
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1a498(%rip), %rsi     # 0x29164
leaq 0x1a4c7(%rip), %rdx     # 0x2919a
leaq 0x148(%rsp), %rdi
callq 0xd5b4
movq (%rbx), %rcx
leaq 0x1e8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x288f0
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0xed1d
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0xed3a
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1e8(%rsp), %rdi
callq 0x28b6c
leaq 0x1e8(%rsp), %rdi
callq 0x28b34
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0xed6b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xed8c
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x8170
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a589(%rip), %rdi     # 0x2932e
callq 0x81d0
leaq 0x1a57d(%rip), %rdi     # 0x2932e
callq 0x8770
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x28b34
jmp 0xefad
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0xedf0
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xedf0
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0xefad
movq 0x178(%rsp), %rsi
jmp 0xefa5
jmp 0xef63
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xef6b
movq 0x138(%rsp), %rsi
jmp 0xef47
jmp 0xee3b
jmp 0xef5e
movq %rax, %rbx
movl $0x148, %esi            # imm = 0x148
movq %r13, %rdi
jmp 0xef4a
jmp 0xef68
jmp 0xef5e
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0xef6b
movq 0xd8(%rsp), %rsi
jmp 0xef47
movq %rax, %rbx
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef6b
movq 0x198(%rsp), %rsi
jmp 0xef47
jmp 0xef68
movq %rax, %rbx
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef6b
movq 0x1b8(%rsp), %rsi
jmp 0xef47
jmp 0xef68
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xef6b
movq 0xf8(%rsp), %rsi
jmp 0xef47
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0xef6b
movq 0x118(%rsp), %rsi
jmp 0xef47
movq %rax, %rbx
leaq 0x1d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef6b
movq 0x1d8(%rsp), %rsi
jmp 0xef47
jmp 0xef68
jmp 0xef53
jmp 0xef63
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0xef34
movl %r14d, (%r13)
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef6b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xef6b
jmp 0xef63
movq %rax, %rbx
jmp 0xef8c
jmp 0xef63
jmp 0xef68
jmp 0xef5e
movq %rax, %rbx
jmp 0xefc9
movq %rax, %rbx
jmp 0xefad
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef8c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1f8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xefad
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xefc9
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xefea
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x8170
movq %rbx, %rdi
callq 0x87b0