// File: /workspace/github_cpp_makefile_star2_O3/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 0x12e50
movq $0x0, 0x20(%rsp)
movq 0x25765(%rip), %rbx     # 0x38620
cmpq %rbx, 0x25766(%rip)     # 0x38628
je 0x1367c
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 0xd4f2
addq %r13, %rbx
leaq 0x20(%rbx), %rsi
leaq 0x168(%rsp), %r13
movq %r13, %rdi
callq 0x13a5e
movb 0x38(%rbx), %al
movb %al, 0x180(%rsp)
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x13a5e
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0x165e5(%rip), %rsi     # 0x2952d
leaq 0x148(%rsp), %rdx
callq 0xd469
movq %rbx, %rdi
leaq 0x165ea(%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 0x12f98
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0x12f9e
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 0x12fd5
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x16587(%rip), %rsi     # 0x29570
leaq 0x16584(%rip), %rdx     # 0x29574
callq 0xd588
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x16561(%rip), %rsi     # 0x29575
leaq 0x1655d(%rip), %rdx     # 0x29578
callq 0xd588
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x131a4
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 0xd4f2
movq %r15, %rdi
leaq 0x16519(%rip), %rsi     # 0x29577
callq 0x87f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x8940
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1308a
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 0xd4f2
movq %r15, %rdi
leaq 0x164c5(%rip), %rsi     # 0x29577
callq 0x87f0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x8940
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x130de
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 0x13133
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 0x13187
movq %rbp, %rdi
leaq 0x16781(%rip), %rsi     # 0x298d4
callq 0x87f0
cmpb $0x1, 0x180(%rsp)
jne 0x13187
leaq 0x30(%rsp), %rdi
leaq 0x16766(%rip), %rsi     # 0x298d4
callq 0x87f0
leaq 0x88(%rsp), %rdi
leaq 0x16752(%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 0x13038
movq %rbp, %rdi
leaq 0x163cb(%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 0x13624
cmpb $0x1, 0x180(%rsp)
leaq 0x138(%rsp), %rbx
jne 0x1355c
leaq 0x188(%rsp), %r13
movq %r13, %rdi
leaq 0x1638d(%rip), %rsi     # 0x2958b
leaq 0x148(%rsp), %rdx
callq 0xd469
movq %r13, %rdi
leaq 0x16394(%rip), %rsi     # 0x295a9
callq 0x87f0
movq %rbx, 0x128(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x13246
movq %rdx, 0x128(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x138(%rsp)
jmp 0x1324c
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 0x132b2
movq %rdx, 0xc8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd8(%rsp)
jmp 0x132b8
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 0x16e86(%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 0x1331b
movq %rdx, 0xe8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf8(%rsp)
jmp 0x13321
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 0x16257(%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 0x13384
movq %rdx, 0x108(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x118(%rsp)
jmp 0x1338a
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 0x133ea
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x133f0
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 0x16165(%rip), %rsi     # 0x29579
callq 0x87f0
movq %r12, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1343a
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x13442
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 0x13476
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x1349b
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x134c0
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x134e5
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x13502
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x13527
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 0x13650
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1355c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x13581
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1359d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x135c2
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x50(%rsp), %rdi
callq 0x13ae8
leaq 0x168(%rsp), %rdi
callq 0x13ae8
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x135fe
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
incl %r14d
movq 0x25020(%rip), %rax     # 0x38628
movq 0x25011(%rip), %rbx     # 0x38620
subq %rbx, %rax
sarq $0x6, %rax
movq %r14, %r13
cmpq %r14, %rax
ja 0x12ede
jmp 0x1367c
movq 0x23955(%rip), %rax     # 0x36f80
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x15f42(%rip), %rsi     # 0x2957c
xorl %eax, %eax
callq 0x8240
movq 0x20(%rsp), %rdi
callq 0x9010
jmp 0x131d6
movq 0x23929(%rip), %rax     # 0x36f80
movq (%rax), %rdi
movq 0x20(%rsp), %rdx
leaq 0x15f16(%rip), %rsi     # 0x2957c
xorl %eax, %eax
callq 0x8240
movq 0x20(%rsp), %rdi
callq 0x9010
jmp 0x13546
leaq 0x28(%rsp), %rdi
callq 0x12e7a
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 0x138f6
jmp 0x13869
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13767
movq %rdx, %rbx
movq %rax, %r14
jmp 0x1371d
movq %rdx, %rbx
movq %rax, %r14
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x136f8
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x136f8
movq %rdx, %rbx
movq %rax, %r14
jmp 0x1378c
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13742
movq %rdx, %rbx
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x1371d
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x13742
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x13767
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x1378c
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x1386f
movq 0x198(%rsp), %rsi
jmp 0x1385f
jmp 0x1384b
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138ec
movq %rdx, %rbx
movq %rax, %r14
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x138ec
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x138ec
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138df
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138d5
movq %rdx, %rbx
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x138d5
movq 0x40(%rsp), %rsi
jmp 0x138cd
movq %rdx, %rbx
movq %rax, %r14
jmp 0x138b0
movq %rdx, %rbx
movq %rax, %r14
jmp 0x13894
jmp 0x13869
jmp 0x1384b
jmp 0x1384b
jmp 0x1384b
jmp 0x13869
jmp 0x13869
movq %rdx, %rbx
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1386f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x1386f
movq %rdx, %rbx
movq %rax, %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x13894
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x138b0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x138d5
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x50(%rsp), %rdi
callq 0x13ae8
leaq 0x148(%rsp), %rdi
callq 0x139be
leaq 0x28(%rsp), %rdi
callq 0x12e7a
movq %r14, %rdi
cmpl $0x1, %ebx
jne 0x1390a
movl %ebx, %esi
callq 0x90f8
jmp 0x13686
callq 0x87b0
nop