// File: /workspace/github_cpp_makefile_star2_O1/eiskalteschatten[P]developersnotebook/src/db/SqliteSchema.cpp
// Function: SqliteSchema::setup_db()
void SqliteSchema::setup_db() {
    try {
        SqliteConnectionManager connection_manager;
        char *error_message = 0;
        int connection;

        for (unsigned int i = 0; i < SqliteSchema::all_tables.size(); i++) {
            SqliteSchema::TableSchema table = SqliteSchema::all_tables[i];
            std::vector<SqliteSchema::ColumnSchema> table_columns = table.columns;

            std::string create_sql = "CREATE TABLE IF NOT EXISTS " +
                                     table.table_name +
                                     "(id INTEGER PRIMARY KEY AUTOINCREMENT,";

            std::string insert_sql_columns = "id, ";
            std::string insert_sql_values  = "1, ";

            for (unsigned int c = 0; c < table_columns.size(); c++) {
                create_sql += table_columns[c].column_name + " ";
                create_sql += table_columns[c].type + " ";
                create_sql += table_columns[c].null_status;

                if (table.create_first_row) {
                    insert_sql_columns += table_columns[c].column_name;
                    insert_sql_values  += table_columns[c].default_value;
                }

                if ((c + 1) < table_columns.size()) {
                    create_sql         += ",";

                    if (table.create_first_row) {
                        insert_sql_columns += ",";
                        insert_sql_values  += ",";
                    }
                }
            }

            create_sql += ");";

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

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

            if (table.create_first_row) {
                std::string insert_sql = "INSERT OR IGNORE INTO " + table.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);
                }
            }
        }
    }
    catch(const std::exception& e) {
        fprintf(stderr, "An exception occured while trying to set up the database: %s\n", e.what());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
leaq 0x28(%rsp), %rdi
callq 0x12e2c
movq $0x0, 0x20(%rsp)
movq 0x25789(%rip), %rbx     # 0x38620
cmpq %rbx, 0x2578a(%rip)     # 0x38628
je 0x13658
leaq 0x10(%rsp), %r12
leaq 0xa8(%rsp), %rbp
movq %rsp, %r15
xorl %r13d, %r13d
xorl %r14d, %r14d
shlq $0x6, %r13
leaq 0x158(%rsp), %rax
movq %rax, 0x148(%rsp)
movq (%rbx,%r13), %rsi
movq 0x8(%rbx,%r13), %rdx
addq %rsi, %rdx
leaq 0x148(%rsp), %rdi
callq 0xd524
addq %r13, %rbx
leaq 0x20(%rbx), %rsi
leaq 0x168(%rsp), %r13
movq %r13, %rdi
callq 0x13a3a
movb 0x38(%rbx), %al
movb %al, 0x180(%rsp)
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x13a3a
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0x16609(%rip), %rsi     # 0x2952d
leaq 0x148(%rsp), %rdx
callq 0xd49b
movq %rbx, %rdi
leaq 0x1660e(%rip), %rsi     # 0x29549
callq 0x87f0
leaq 0xb8(%rsp), %rsi
movq %rsi, 0xa8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x12f74
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0x12f7a
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xb0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x12fb1
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x165ab(%rip), %rsi     # 0x29570
leaq 0x165a8(%rip), %rdx     # 0x29574
callq 0xd5b4
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x16585(%rip), %rsi     # 0x29575
leaq 0x16581(%rip), %rdx     # 0x29578
callq 0xd5b4
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x13180
movl $0x1, %r13d
xorl %ebx, %ebx
shlq $0x7, %rbx
movq %r12, (%rsp)
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xd524
movq %r15, %rdi
leaq 0x1653d(%rip), %rsi     # 0x29577
callq 0x87f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x8940
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x13066
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x50(%rsp), %rax
movq %r12, (%rsp)
movq 0x20(%rax,%rbx), %rsi
movq 0x28(%rax,%rbx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xd524
movq %r15, %rdi
leaq 0x164e9(%rip), %rsi     # 0x29577
callq 0x87f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x8940
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x130ba
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x50(%rsp), %rax
movq 0x40(%rax,%rbx), %rsi
movq 0x48(%rax,%rbx), %rdx
movq %rbp, %rdi
callq 0x8940
cmpb $0x1, 0x180(%rsp)
jne 0x1310f
movq 0x50(%rsp), %rax
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
leaq 0x30(%rsp), %rdi
callq 0x8940
movq 0x50(%rsp), %rax
movq 0x60(%rax,%rbx), %rsi
movq 0x68(%rax,%rbx), %rdx
leaq 0x88(%rsp), %rdi
callq 0x8940
movl %r13d, %ebx
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x7, %rax
cmpq %rbx, %rax
jbe 0x13163
movq %rbp, %rdi
leaq 0x167a5(%rip), %rsi     # 0x298d4
callq 0x87f0
cmpb $0x1, 0x180(%rsp)
jne 0x13163
leaq 0x30(%rsp), %rdi
leaq 0x1678a(%rip), %rsi     # 0x298d4
callq 0x87f0
leaq 0x88(%rsp), %rdi
leaq 0x16776(%rip), %rsi     # 0x298d4
callq 0x87f0
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
sarq $0x7, %rcx
incl %r13d
cmpq %rbx, %rcx
ja 0x13014
movq %rbp, %rdi
leaq 0x163ef(%rip), %rsi     # 0x29579
callq 0x87f0
movq 0x28(%rsp), %rdi
movq 0xa8(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x20(%rsp), %r8
callq 0x80c0
testl %eax, %eax
jne 0x13600
cmpb $0x1, 0x180(%rsp)
leaq 0x138(%rsp), %rbx
jne 0x13538
leaq 0x188(%rsp), %r13
movq %r13, %rdi
leaq 0x163b1(%rip), %rsi     # 0x2958b
leaq 0x148(%rsp), %rdx
callq 0xd49b
movq %r13, %rdi
leaq 0x163b8(%rip), %rsi     # 0x295a9
callq 0x87f0
movq %rbx, 0x128(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x13222
movq %rdx, 0x128(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x138(%rsp)
jmp 0x13228
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x130(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x128(%rsp), %rdi
callq 0x8940
leaq 0xd8(%rsp), %rsi
movq %rsi, 0xc8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1328e
movq %rdx, 0xc8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd8(%rsp)
jmp 0x13294
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xd0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc8(%rsp), %rdi
leaq 0x16eaa(%rip), %rsi     # 0x2a168
callq 0x87f0
leaq 0xf8(%rsp), %rsi
movq %rsi, 0xe8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x132f7
movq %rdx, 0xe8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf8(%rsp)
jmp 0x132fd
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xf0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xe8(%rsp), %rdi
leaq 0x1627b(%rip), %rsi     # 0x295a2
callq 0x87f0
leaq 0x118(%rsp), %rsi
movq %rsi, 0x108(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x13360
movq %rdx, 0x108(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x118(%rsp)
jmp 0x13366
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x110(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
leaq 0x108(%rsp), %rdi
callq 0x8940
leaq 0x78(%rsp), %rsi
movq %rsi, 0x68(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x133c6
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x133cc
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x68(%rsp), %rdi
leaq 0x16189(%rip), %rsi     # 0x29579
callq 0x87f0
movq %r12, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x13416
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x1341e
movups (%rcx), %xmm0
movups %xmm0, (%r12)
leaq 0x78(%rsp), %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x68(%rsp), %rdi
cmpq %rsi, %rdi
je 0x13452
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x13477
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x1349c
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x134c1
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x134de
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x13503
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x28(%rsp), %rdi
movq (%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
leaq 0x20(%rsp), %r8
callq 0x80c0
testl %eax, %eax
jne 0x1362c
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x13538
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x1355d
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x13579
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1359e
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x50(%rsp), %rdi
callq 0x13ac4
leaq 0x168(%rsp), %rdi
callq 0x13ac4
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x135da
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
incl %r14d
movq 0x25044(%rip), %rax     # 0x38628
movq 0x25035(%rip), %rbx     # 0x38620
subq %rbx, %rax
sarq $0x6, %rax
movq %r14, %r13
cmpq %r14, %rax
ja 0x12eba
jmp 0x13658
movq 0x23979(%rip), %rax     # 0x36f80
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x15f66(%rip), %rsi     # 0x2957c
xorl %eax, %eax
callq 0x8240
movq 0x20(%rsp), %rdi
callq 0x9010
jmp 0x131b2
movq 0x2394d(%rip), %rax     # 0x36f80
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x15f3a(%rip), %rsi     # 0x2957c
xorl %eax, %eax
callq 0x8240
movq 0x20(%rsp), %rdi
callq 0x9010
jmp 0x13522
leaq 0x28(%rsp), %rdi
callq 0x12e56
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138d2
jmp 0x13845
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13743
movq %rdx, %rbx
movq %rax, %r14
jmp 0x136f9
movq %rdx, %rbx
movq %rax, %r14
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x136d4
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x136d4
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13768
movq %rdx, %rbx
movq %rax, %r14
jmp 0x1371e
movq %rdx, %rbx
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x136f9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x1371e
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x13743
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x13768
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x1384b
movq 0x198(%rsp), %rsi
jmp 0x1383b
jmp 0x13827
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138c8
movq %rdx, %rbx
movq %rax, %r14
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x138c8
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x138c8
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138bb
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138b1
movq %rdx, %rbx
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x138b1
movq 0x40(%rsp), %rsi
jmp 0x138a9
movq %rdx, %rbx
movq %rax, %r14
jmp 0x1388c
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13870
jmp 0x13845
jmp 0x13827
jmp 0x13827
jmp 0x13827
jmp 0x13845
jmp 0x13845
movq %rdx, %rbx
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1384b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x1384b
movq %rdx, %rbx
movq %rax, %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x13870
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1388c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x138b1
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x50(%rsp), %rdi
callq 0x13ac4
leaq 0x148(%rsp), %rdi
callq 0x1399a
leaq 0x28(%rsp), %rdi
callq 0x12e56
movq %r14, %rdi
cmpl $0x1, %ebx
jne 0x138e6
movl %ebx, %esi
callq 0x90f8
jmp 0x13662
callq 0x87b0
nop