// File: eiskalteschatten[P]developersnotebook/src/models/AbstractSqliteModel.cpp
// Function: AbstractSqliteModel::insert_new_row()
void AbstractSqliteModel::insert_new_row() {
    try {
        SqliteConnectionManager connection_manager;
        char *error_message = 0;
        int connection;

        std::string insert_sql_columns;
        std::string insert_sql_values;
        std::vector<SqliteSchema::ColumnSchema> table_columns = table_schema->columns;

        for (unsigned int c = 0; c < table_columns.size(); c++) {
            insert_sql_columns += table_columns[c].column_name;
            insert_sql_values  += table_columns[c].default_value.empty() ? "\"\"" : "\"" + table_columns[c].default_value + "\"";

            if ((c + 1) < table_columns.size()) {
                insert_sql_columns += ",";
                insert_sql_values  += ",";
            }
        }

        std::string insert_sql = "INSERT INTO " + table_schema->table_name +
                                 " (" + insert_sql_columns + ")" +
                                 " VALUES (" + insert_sql_values + ");";

        connection = sqlite3_exec(connection_manager.get_db(), insert_sql.c_str(), NULL, 0, &error_message);

        if(connection != SQLITE_OK) {
            fprintf(stderr, "SQL error: %s\n", error_message);
            sqlite3_free(error_message);
        }

        id = sqlite3_last_insert_rowid(connection_manager.get_db());
    }
    catch(const std::exception& e) {
        fprintf(stderr, "An exception occured while trying to save to the database: %s\n", e.what());
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x1cc70
jmp 0x21525
movq $0x0, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xa5c0
leaq -0x70(%rbp), %rdi
callq 0xa5c0
movq -0x1d0(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x20, %rsi
leaq -0x88(%rbp), %rdi
callq 0x1d810
jmp 0x2155c
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq %rax, -0x1d8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1d900
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
cmpq %rcx, %rax
jae 0x217cd
movl -0x8c(%rbp), %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x1d920
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0xa140
jmp 0x215b4
movl -0x8c(%rbp), %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x1d920
movq %rax, %rdi
addq $0x60, %rdi
callq 0xa500
movb $0x0, -0xb2(%rbp)
movb $0x0, -0xd9(%rbp)
testb $0x1, %al
jne 0x215e8
jmp 0x21620
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0xaf80
movq -0x1e0(%rbp), %rdx
movb $0x1, -0xb2(%rbp)
leaq 0x333cf(%rip), %rsi     # 0x549df
leaq -0xb0(%rbp), %rdi
callq 0x10f00
jmp 0x2161e
jmp 0x21675
movl -0x8c(%rbp), %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x1d920
movq %rax, %rdx
addq $0x60, %rdx
leaq 0x324b3(%rip), %rsi     # 0x53af5
leaq -0xd8(%rbp), %rdi
callq 0x110c0
jmp 0x21650
movb $0x1, -0xd9(%rbp)
leaq 0x32497(%rip), %rdx     # 0x53af5
leaq -0xb0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x10eb0
jmp 0x21673
jmp 0x21675
leaq -0x70(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xa140
jmp 0x21687
leaq -0xb0(%rbp), %rdi
callq 0xb430
testb $0x1, -0xd9(%rbp)
jne 0x2169e
jmp 0x216aa
leaq -0xd8(%rbp), %rdi
callq 0xb430
testb $0x1, -0xb2(%rbp)
jne 0x216b5
jmp 0x216c1
leaq -0xb1(%rbp), %rdi
callq 0xb410
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x1e8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1d900
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x217b7
leaq 0x324ab(%rip), %rsi     # 0x53ba4
leaq -0x50(%rbp), %rdi
callq 0xa240
jmp 0x21704
leaq 0x32499(%rip), %rsi     # 0x53ba4
leaq -0x70(%rbp), %rdi
callq 0xa240
jmp 0x21716
jmp 0x217b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x21aa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x21a8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x21a7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2179b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x21782
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xb430
testb $0x1, -0xd9(%rbp)
jne 0x2178d
jmp 0x21799
leaq -0xd8(%rbp), %rdi
callq 0xb430
jmp 0x2179b
testb $0x1, -0xb2(%rbp)
jne 0x217a6
jmp 0x217b2
leaq -0xb1(%rbp), %rdi
callq 0xb410
jmp 0x21a7f
jmp 0x217b9
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x21566
movq -0x1d0(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x322b9(%rip), %rsi     # 0x53a98
leaq -0x1c0(%rbp), %rdi
callq 0x110c0
jmp 0x217ed
leaq 0x31fef(%rip), %rdx     # 0x537e3
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x10eb0
jmp 0x21809
leaq -0x180(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x14a70
jmp 0x21822
leaq 0x32c0d(%rip), %rdx     # 0x54436
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x10eb0
jmp 0x2183e
leaq 0x31f97(%rip), %rdx     # 0x537dc
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x10eb0
jmp 0x2185a
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x14a70
jmp 0x21873
leaq 0x31f39(%rip), %rdx     # 0x537b3
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x10eb0
jmp 0x2188f
leaq -0x120(%rbp), %rdi
callq 0xb430
leaq -0x140(%rbp), %rdi
callq 0xb430
leaq -0x160(%rbp), %rdi
callq 0xb430
leaq -0x180(%rbp), %rdi
callq 0xb430
leaq -0x1a0(%rbp), %rdi
callq 0xb430
leaq -0x1c0(%rbp), %rdi
callq 0xb430
leaq -0x10(%rbp), %rdi
callq 0x1d940
movq %rax, -0x1f0(%rbp)
jmp 0x218e9
leaq -0x100(%rbp), %rdi
callq 0xa1d0
movq -0x1f0(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x28(%rbp), %r8
movq %rcx, %rdx
callq 0xa0e0
movl %eax, -0x1f4(%rbp)
jmp 0x21917
movl -0x1f4(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x21a12
movq 0x5364f(%rip), %rax     # 0x74f80
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x31e77(%rip), %rsi     # 0x537b6
xorl %eax, %eax
callq 0xa320
movq -0x28(%rbp), %rdi
callq 0xb360
jmp 0x21951
jmp 0x21a12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x219e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x219db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x219cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x219c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x219b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xb430
leaq -0x140(%rbp), %rdi
callq 0xb430
leaq -0x160(%rbp), %rdi
callq 0xb430
leaq -0x180(%rbp), %rdi
callq 0xb430
leaq -0x1a0(%rbp), %rdi
callq 0xb430
leaq -0x1c0(%rbp), %rdi
callq 0xb430
jmp 0x21a7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xb430
jmp 0x21a7f
leaq -0x10(%rbp), %rdi
callq 0x1d940
movq %rax, -0x200(%rbp)
jmp 0x21a24
movq -0x200(%rbp), %rdi
callq 0xa960
movq %rax, -0x208(%rbp)
jmp 0x21a39
movq -0x1d0(%rbp), %rax
movq -0x208(%rbp), %rcx
movl %ecx, 0x58(%rax)
leaq -0x100(%rbp), %rdi
callq 0xb430
leaq -0x88(%rbp), %rdi
callq 0x1d960
leaq -0x70(%rbp), %rdi
callq 0xb430
leaq -0x50(%rbp), %rdi
callq 0xb430
leaq -0x10(%rbp), %rdi
callq 0x1ccf0
jmp 0x21afd
leaq -0x88(%rbp), %rdi
callq 0x1d960
leaq -0x70(%rbp), %rdi
callq 0xb430
leaq -0x50(%rbp), %rdi
callq 0xb430
leaq -0x10(%rbp), %rdi
callq 0x1ccf0
movl -0x1c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x21b06
movq -0x18(%rbp), %rdi
callq 0xa0b0
movq %rax, -0x1c8(%rbp)
movq 0x534b7(%rip), %rax     # 0x74f80
movq (%rax), %rax
movq %rax, -0x210(%rbp)
movq -0x1c8(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x210(%rbp), %rdi
movq %rax, %rdx
leaq 0x31fb4(%rip), %rsi     # 0x53aa5
movb $0x0, %al
callq 0xa320
callq 0xac00
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0xaa00
nop