// File: /workspace/github_cpp_makefile_star2_O3/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 0x1201c
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 0xe727
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0xd4f2
jmp 0xe73b
leaq 0x1b227(%rip), %rdx     # 0x29955
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0xd588
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 0xe79f
cmpb $0x0, (%r12)
je 0xecae
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 0xe807
leaq 0x1e8(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x11f34
jmp 0xe82a
leaq 0x1f8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1b13b(%rip), %rdx     # 0x29955
leaq 0x1e8(%rsp), %rdi
movq %rdx, %rsi
callq 0xd588
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 0xe86f
leaq 0x78(%rsp), %rdi
leaq 0x24(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x11f34
jmp 0xe88f
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1b0d3(%rip), %rdx     # 0x29955
leaq 0x78(%rsp), %rdi
movq %rdx, %rsi
callq 0xd588
movq 0x40(%rbx), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x238(%rsp), %rdx
callq 0x8d90
testl %eax, %eax
je 0xe968
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 0xd42c
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 0xedba
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0xedc6
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0xedc6
testl %ecx, %ecx
leaq 0x48(%rsp), %rbp
jne 0xe940
movl %r14d, (%r13)
movl %eax, (%rsp)
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xe95e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x10(%rsp), %rdi
callq 0x90c8
cmpl $-0x1, (%rsp)
je 0xe988
movl $0x148, %edi            # imm = 0x148
callq 0x81a0
movq %rax, %r13
movq %rsp, %rsi
movq %rax, %rdi
callq 0x2681c
jmp 0xe99d
movl $0x148, %edi            # imm = 0x148
callq 0x81a0
movq %rax, %r13
movq %rax, %rdi
callq 0x2673c
cmpl $-0x1, (%rsp)
jne 0xea0e
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %rdi
callq 0xd4f2
leaq 0x128(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x272b8
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xe9fe
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x238(%rsp), %rsi
movq %rbx, %rdi
callq 0xf01c
leaq 0x1c8(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %r12, %rsi
callq 0xd42c
leaq 0x1c8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26e8e
leaq 0x1d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xea56
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 0xd4f2
leaq 0x108(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26f24
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0xeab1
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 0xd4f2
leaq 0xe8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x26fbe
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xeb09
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 0xd42c
leaq 0x1a8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x27058
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xeb6d
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x188(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq 0xb8(%rsp), %rsi
callq 0xd42c
leaq 0x188(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x270f2
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xebba
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x8170
xorl %esi, %esi
cmpl $0x0, 0x1c(%rsp)
setne %sil
movq %r13, %rdi
xorl %edx, %edx
callq 0x2718c
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0xd4f2
leaq 0xc8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x2721e
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0xec24
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq (%r13), %rax
movq %r13, %rdi
callq *0x18(%rax)
movq %r13, %rdi
callq 0x27904
leaq 0x238(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf04a
leaq 0x238(%rsp), %rsi
movq %rbx, %rdi
callq 0xf51e
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xec84
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1f8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xed70
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xed70
leaq 0x178(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a493(%rip), %rsi     # 0x29154
leaq 0x1a49b(%rip), %rdx     # 0x29163
leaq 0x168(%rsp), %rdi
callq 0xd588
leaq 0x158(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1a47c(%rip), %rsi     # 0x29164
leaq 0x1a4ab(%rip), %rdx     # 0x2919a
leaq 0x148(%rsp), %rdi
callq 0xd588
movq (%rbx), %rcx
leaq 0x1e8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x288c8
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0xed39
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0xed56
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1e8(%rsp), %rdi
callq 0x28b44
leaq 0x1e8(%rsp), %rdi
callq 0x28b0c
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0xed87
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xeda8
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 0x1a56d(%rip), %rdi     # 0x2932e
callq 0x81d0
leaq 0x1a561(%rip), %rdi     # 0x2932e
callq 0x8770
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x28b0c
jmp 0xefd6
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r15, %rdi
je 0xee0c
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xee0c
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0xefd6
movq 0x178(%rsp), %rsi
jmp 0xefce
jmp 0xef8c
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xef94
movq 0x138(%rsp), %rsi
jmp 0xef70
jmp 0xee61
jmp 0xef7c
jmp 0xef8c
jmp 0xef87
movq %rax, %rbx
movl $0x148, %esi            # imm = 0x148
movq %r13, %rdi
jmp 0xef73
jmp 0xef91
jmp 0xef7c
jmp 0xef8c
jmp 0xef87
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0xef94
movq 0xd8(%rsp), %rsi
jmp 0xef70
movq %rax, %rbx
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef94
movq 0x198(%rsp), %rsi
jmp 0xef70
jmp 0xef91
movq %rax, %rbx
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef94
movq 0x1b8(%rsp), %rsi
jmp 0xef70
jmp 0xef91
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0xef94
movq 0xf8(%rsp), %rsi
jmp 0xef70
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0xef94
movq 0x118(%rsp), %rsi
jmp 0xef70
movq %rax, %rbx
leaq 0x1d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef94
movq 0x1d8(%rsp), %rsi
jmp 0xef70
jmp 0xef91
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0xef5d
movl %r14d, (%r13)
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xef94
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0xef94
jmp 0xef8c
movq %rax, %rbx
jmp 0xefb5
jmp 0xef8c
jmp 0xef91
jmp 0xef87
movq %rax, %rbx
jmp 0xeff2
movq %rax, %rbx
jmp 0xefd6
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xefb5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x1f8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xefd6
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xeff2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf013
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x8170
movq %rbx, %rdi
callq 0x87b0
nop