// File: Overv[P]pqpp/example.cc
// Function: main
int main() {
    auto db = pq::connection("host=127.0.0.1 dbname=test user=test password=test");

    db.exec("CREATE TABLE people (name TEXT, age INTEGER)");

    auto stmt = db.prepare("inserter", "INSERT INTO people VALUES ($1, $2)", 2);
    db.exec(stmt, "John", 26);
    db.exec(stmt, "Fred", 53);
    db.exec(stmt, "Lisa", 37);
    db.exec(stmt, nullptr, 18);

    auto rows = db.exec("SELECT * FROM people ORDER BY age ASC");

    for (auto& row : rows) {
        int age = row["age"];
        std::string name = row["name"];

        if (!row["name"].is_null()) {
            std::cout << name << " is " << age << " years old" << std::endl;
        }
    }

    db.exec("DROP TABLE people");

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movl $0x0, -0x4(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x22f0
movq -0x2b0(%rbp), %rdx
leaq 0xa97a(%rip), %rsi      # 0xd04a
leaq -0x38(%rbp), %rdi
callq 0x2290
jmp 0x26db
leaq -0x18(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3100
jmp 0x26ea
leaq -0x38(%rbp), %rdi
callq 0x2240
leaq -0x39(%rbp), %rdi
callq 0x23a0
leaq -0x89(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x22f0
movq -0x2b8(%rbp), %rdx
leaq 0xa960(%rip), %rsi      # 0xd07d
leaq -0x88(%rbp), %rdi
callq 0x2290
jmp 0x272b
leaq -0x68(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x3210
jmp 0x2741
leaq -0x68(%rbp), %rdi
callq 0x33f0
leaq -0x88(%rbp), %rdi
callq 0x2240
leaq -0x89(%rbp), %rdi
callq 0x23a0
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x22f0
movq -0x2c0(%rbp), %rdx
leaq 0xa927(%rip), %rsi      # 0xd0aa
leaq -0xd8(%rbp), %rdi
callq 0x2290
jmp 0x2791
leaq -0x101(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x22f0
movq -0x2c8(%rbp), %rdx
leaq 0xa901(%rip), %rsi      # 0xd0b3
leaq -0x100(%rbp), %rdi
callq 0x2290
jmp 0x27c0
leaq -0xb8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
leaq -0x100(%rbp), %rcx
movl $0x2, %r8d
callq 0x3450
jmp 0x27e6
leaq -0x100(%rbp), %rdi
callq 0x2240
leaq -0x101(%rbp), %rdi
callq 0x23a0
leaq -0xd8(%rbp), %rdi
callq 0x2240
leaq -0xd9(%rbp), %rdi
callq 0x23a0
leaq 0xa8b9(%rip), %rcx      # 0xd0d6
leaq -0x120(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
movl $0x1a, %r8d
callq 0x3620
jmp 0x283c
leaq -0x120(%rbp), %rdi
callq 0x33f0
leaq 0xa88c(%rip), %rcx      # 0xd0db
leaq -0x138(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
movl $0x35, %r8d
callq 0x3620
jmp 0x286e
leaq -0x138(%rbp), %rdi
callq 0x33f0
leaq 0xa85f(%rip), %rcx      # 0xd0e0
leaq -0x150(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
movl $0x25, %r8d
callq 0x3620
jmp 0x28a0
leaq -0x150(%rbp), %rdi
callq 0x33f0
xorl %eax, %eax
movl %eax, %ecx
leaq -0x168(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
movl $0x12, %r8d
callq 0x3810
jmp 0x28cf
leaq -0x168(%rbp), %rdi
callq 0x33f0
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x22f0
movq -0x2d0(%rbp), %rdx
leaq 0xa7e9(%rip), %rsi      # 0xd0e5
leaq -0x1a0(%rbp), %rdi
callq 0x2290
jmp 0x290a
leaq -0x180(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x3210
jmp 0x2923
leaq -0x1a0(%rbp), %rdi
callq 0x2240
leaq -0x1a1(%rbp), %rdi
callq 0x23a0
leaq -0x180(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x39f0
movq %rax, -0x1b8(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x3a20
movq %rax, -0x1c0(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3a50
testb $0x1, %al
jne 0x298b
jmp 0x2dcb
leaq -0x1b8(%rbp), %rdi
callq 0x3a90
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x22f0
movq -0x2d8(%rbp), %rdx
leaq 0xa73e(%rip), %rsi      # 0xd10b
leaq -0x1f0(%rbp), %rdi
callq 0x2290
jmp 0x29db
movq -0x2e0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x3ab0
movq %rax, -0x2e8(%rbp)
jmp 0x29f7
movq -0x2e8(%rbp), %rdi
callq 0x3b90
movl %eax, -0x2ec(%rbp)
jmp 0x2a0b
leaq -0x1f0(%rbp), %rdi
callq 0x2240
leaq -0x1f1(%rbp), %rdi
callq 0x23a0
movl -0x2ec(%rbp), %eax
movl %eax, -0x1cc(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x300(%rbp)
leaq -0x239(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x22f0
movq -0x2f8(%rbp), %rdx
leaq 0xa6b1(%rip), %rsi      # 0xd10f
leaq -0x238(%rbp), %rdi
callq 0x2290
jmp 0x2a6c
movq -0x300(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x3ab0
movq %rax, -0x308(%rbp)
jmp 0x2a88
movq -0x308(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x3bb0
jmp 0x2a9d
leaq -0x238(%rbp), %rdi
callq 0x2240
leaq -0x239(%rbp), %rdi
callq 0x23a0
movq -0x1c8(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x261(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x22f0
movq -0x310(%rbp), %rdx
leaq 0xa62b(%rip), %rsi      # 0xd10f
leaq -0x260(%rbp), %rdi
callq 0x2290
jmp 0x2af2
movq -0x318(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x3ab0
movq %rax, -0x320(%rbp)
jmp 0x2b0e
movq -0x320(%rbp), %rdi
callq 0x3be0
movb %al, -0x321(%rbp)
jmp 0x2b22
movb -0x321(%rbp), %al
xorb $-0x1, %al
movb %al, -0x322(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x2240
leaq -0x261(%rbp), %rdi
callq 0x23a0
movb -0x322(%rbp), %al
testb $0x1, %al
jne 0x2b57
jmp 0x2d9d
movq 0x1343a(%rip), %rdi     # 0x15f98
leaq -0x218(%rbp), %rsi
callq 0x2100
movq %rax, -0x330(%rbp)
jmp 0x2b73
movq -0x330(%rbp), %rdi
leaq 0xa593(%rip), %rsi      # 0xd114
callq 0x21a0
movq %rax, -0x338(%rbp)
jmp 0x2b8f
movq -0x338(%rbp), %rdi
movl -0x1cc(%rbp), %esi
callq 0x2120
movq %rax, -0x340(%rbp)
jmp 0x2baa
movq -0x340(%rbp), %rdi
leaq 0xa561(%rip), %rsi      # 0xd119
callq 0x21a0
movq %rax, -0x348(%rbp)
jmp 0x2bc6
movq -0x348(%rbp), %rdi
movq 0x1340c(%rip), %rsi     # 0x15fe0
callq 0x2330
jmp 0x2bdb
jmp 0x2d9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2c03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2240
leaq -0x39(%rbp), %rdi
callq 0x23a0
jmp 0x2ebe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2c37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2240
leaq -0x89(%rbp), %rdi
callq 0x23a0
jmp 0x2eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2c94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2c7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x2240
leaq -0x101(%rbp), %rdi
callq 0x23a0
leaq -0xd8(%rbp), %rdi
callq 0x2240
leaq -0xd9(%rbp), %rdi
callq 0x23a0
jmp 0x2eb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2ea9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2cdc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x2240
leaq -0x1a1(%rbp), %rdi
callq 0x23a0
jmp 0x2ea9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x2240
leaq -0x1f1(%rbp), %rdi
callq 0x23a0
jmp 0x2e9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2240
leaq -0x239(%rbp), %rdi
callq 0x23a0
jmp 0x2e9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x2240
leaq -0x261(%rbp), %rdi
callq 0x23a0
jmp 0x2dba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2dba
leaq -0x218(%rbp), %rdi
callq 0x2240
leaq -0x1b8(%rbp), %rdi
callq 0x3c00
jmp 0x296f
leaq -0x218(%rbp), %rdi
callq 0x2240
jmp 0x2e9d
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x22f0
movq -0x350(%rbp), %rdx
leaq 0xa338(%rip), %rsi      # 0xd124
leaq -0x2a0(%rbp), %rdi
callq 0x2290
jmp 0x2dfa
leaq -0x280(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x2a0(%rbp), %rdx
callq 0x3210
jmp 0x2e13
leaq -0x280(%rbp), %rdi
callq 0x33f0
leaq -0x2a0(%rbp), %rdi
callq 0x2240
leaq -0x2a1(%rbp), %rdi
callq 0x23a0
movl $0x0, -0x4(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x33f0
leaq -0xb8(%rbp), %rdi
callq 0x3c20
leaq -0x18(%rbp), %rdi
callq 0x3c40
movl -0x4(%rbp), %eax
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2e91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x2240
leaq -0x2a1(%rbp), %rdi
callq 0x23a0
leaq -0x180(%rbp), %rdi
callq 0x33f0
leaq -0xb8(%rbp), %rdi
callq 0x3c20
leaq -0x18(%rbp), %rdi
callq 0x3c40
movq -0x48(%rbp), %rdi
callq 0x2200
nopw (%rax,%rax)