// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: sqlGenericQuery
int sqlGenericQuery(sqlRow *row, const char *sql, va_list ap) {
    int rc = SQLITE_ERROR;
    sqlite3_stmt *stmt = NULL;
    sds query = sdsempty();
    if (row) row->stmt = NULL; /* On error sqlNextRow() should return false. */

    /* We need to build the query, substituting the following three
     * classes of patterns with just "?", remembering the order and
     * type, and later using the sql3 binding API in order to prepare
     * the query:
     *
     * ?s string
     * ?b blob (varargs must have char ptr and size_t len)
     * ?i int64_t
     * ?d double
     */
    char spec[SQL_MAX_SPEC];
    int numspec = 0;
    const char *p = sql;
    while(p[0]) {
        if (p[0] == '?') {
            if (p[1] == 's' || p[1] == 'i' || p[1] == 'd' || p[1] == 'b') {
                if (numspec == SQL_MAX_SPEC) goto error;
                spec[numspec++] = p[1];
            } else {
                goto error;
            }
            query = sdscatlen(query,"?",1);
            p++; /* Skip the specifier. */
        } else {
            query = sdscatlen(query,p,1);
        }
        p++;
    }

    /* Prepare the query and bind the query arguments. */
    rc = sqlite3_prepare_v2(DbHandle,query,-1,&stmt,NULL);
    if (rc != SQLITE_OK) {
        if (VerboseMode) printf("%p: Query error: %s: %s\n",
                                (void*)DbHandle,
                                query,
                                sqlite3_errmsg(DbHandle));
        goto error;
    }

    for (int j = 0; j < numspec; j++) {
        switch(spec[j]) {
        case 'b': {
                  char *blobptr = va_arg(ap,char*);
                  size_t bloblen = va_arg(ap,size_t);
                  rc = sqlite3_bind_blob64(stmt,j+1,blobptr,bloblen,NULL);
                  }
                  break;
        case 's': rc = sqlite3_bind_text(stmt,j+1,va_arg(ap,char*),-1,NULL);
                  break;
        case 'i': rc = sqlite3_bind_int64(stmt,j+1,va_arg(ap,int64_t));
                  break;
        case 'd': rc = sqlite3_bind_double(stmt,j+1,va_arg(ap,double));
                  break;
        }
        if (rc != SQLITE_OK) goto error;
    }

    /* Execute. */
    rc = sqlite3_step(stmt);
    if (rc == SQLITE_ROW) {
        if (row) {
            row->stmt = stmt;
            row->cols = 0;
            row->col = NULL;
            stmt = NULL; /* Don't free it on cleanup. */
        }
    }

error:
    if (stmt) sqlite3_finalize(stmt);
    sdsfree(query);
    return rc;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movq %rdx, 0x130(%rsp)
movl $0x1, 0x12c(%rsp)
movq $0x0, 0x120(%rsp)
callq 0x8610
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x140(%rsp)
je 0xbf7d
movq 0x140(%rsp), %rax
movq $0x0, (%rax)
movl $0x0, 0xec(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
cmpb $0x0, (%rax)
je 0xc0b0
movq 0xe0(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0xc075
movq 0xe0(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x73, %eax
je 0xc001
movq 0xe0(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x69, %eax
je 0xc001
movq 0xe0(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x64, %eax
je 0xc001
movq 0xe0(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x62, %eax
jne 0xc039
cmpl $0x20, 0xec(%rsp)
jne 0xc010
jmp 0xc52b
movq 0xe0(%rsp), %rax
movb 0x1(%rax), %cl
movl 0xec(%rsp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0xec(%rsp)
cltq
movb %cl, 0xf0(%rsp,%rax)
jmp 0xc03e
jmp 0xc52b
movq 0x118(%rsp), %rdi
leaq 0x9dd0(%rip), %rsi      # 0x15e1d
movl $0x1, %edx
callq 0x92b0
movq %rax, 0x118(%rsp)
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
jmp 0xc097
movq 0x118(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movl $0x1, %edx
callq 0x92b0
movq %rax, 0x118(%rsp)
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
jmp 0xbf98
movq %fs:0x0, %rax
leaq -0x8(%rax), %rax
movq (%rax), %rdi
movq 0x118(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq 0x120(%rsp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x2200
movl %eax, 0x12c(%rsp)
cmpl $0x0, 0x12c(%rsp)
je 0xc165
cmpl $0x0, 0xf1ba(%rip)      # 0x1b2b4
je 0xc160
movq %fs:0x0, %rax
leaq -0x8(%rax), %rax
movq (%rax), %rax
movq %rax, 0xb8(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %fs:0x0, %rax
leaq -0x8(%rax), %rax
movq (%rax), %rdi
callq 0x2220
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq %rax, %rcx
leaq 0x9575(%rip), %rdi      # 0x156ce
movb $0x0, %al
callq 0x2030
jmp 0xc52b
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
cmpl 0xec(%rsp), %eax
jge 0xc4c0
movslq 0xdc(%rsp), %rax
movsbl 0xf0(%rsp,%rax), %eax
addl $-0x62, %eax
movl %eax, %ecx
movq %rcx, 0xb0(%rsp)
subl $0x11, %eax
ja 0xc499
movq 0xb0(%rsp), %rax
leaq 0x944f(%rip), %rcx      # 0x15608
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x130(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl (%rax), %eax
movl %eax, 0xac(%rsp)
cmpl $0x28, %eax
ja 0xc205
movq 0xa0(%rsp), %rcx
movl 0xac(%rsp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, 0x98(%rsp)
jmp 0xc224
movq 0xa0(%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xd0(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x88(%rsp)
movl (%rax), %eax
movl %eax, 0x94(%rsp)
cmpl $0x28, %eax
ja 0xc27a
movq 0x88(%rsp), %rcx
movl 0x94(%rsp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, 0x80(%rsp)
jmp 0xc299
movq 0x88(%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xc8(%rsp)
movq 0x120(%rsp), %rdi
movl 0xdc(%rsp), %esi
addl $0x1, %esi
movq 0xd0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x2370
movl %eax, 0x12c(%rsp)
jmp 0xc499
movq 0x120(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x70(%rsp)
movl (%rax), %eax
movl %eax, 0x7c(%rsp)
cmpl $0x28, %eax
ja 0xc333
movq 0x70(%rsp), %rcx
movl 0x7c(%rsp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, 0x58(%rsp)
jmp 0xc34c
movq 0x70(%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, 0x58(%rsp)
movl 0x6c(%rsp), %esi
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rax
movq (%rax), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %r8d
callq 0x21d0
movl %eax, 0x12c(%rsp)
jmp 0xc499
movq 0x120(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x48(%rsp)
movl (%rax), %eax
movl %eax, 0x54(%rsp)
cmpl $0x28, %eax
ja 0xc3c7
movq 0x48(%rsp), %rcx
movl 0x54(%rsp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, 0x30(%rsp)
jmp 0xc3e0
movq 0x48(%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, 0x30(%rsp)
movl 0x44(%rsp), %esi
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rdx
callq 0x2240
movl %eax, 0x12c(%rsp)
jmp 0xc499
movq 0x120(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x20(%rsp)
movl 0x4(%rax), %eax
movl %eax, 0x2c(%rsp)
cmpl $0xa0, %eax
ja 0xc464
movq 0x20(%rsp), %rcx
movl 0x2c(%rsp), %edx
movq 0x18(%rsp), %rsi
movslq %edx, %rax
addq 0x10(%rsi), %rax
addl $0x10, %edx
movl %edx, (%rcx)
movq %rax, (%rsp)
jmp 0xc47c
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rsp)
movl 0x14(%rsp), %esi
movq 0x8(%rsp), %rdi
movq (%rsp), %rax
movsd (%rax), %xmm0
callq 0x2090
movl %eax, 0x12c(%rsp)
cmpl $0x0, 0x12c(%rsp)
je 0xc4a8
jmp 0xc52b
jmp 0xc4aa
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0xc170
movq 0x120(%rsp), %rdi
callq 0x2310
movl %eax, 0x12c(%rsp)
cmpl $0x64, 0x12c(%rsp)
jne 0xc529
cmpq $0x0, 0x140(%rsp)
je 0xc527
movq 0x120(%rsp), %rcx
movq 0x140(%rsp), %rax
movq %rcx, (%rax)
movq 0x140(%rsp), %rax
movl $0x0, 0x8(%rax)
movq 0x140(%rsp), %rax
movq $0x0, 0x10(%rax)
movq $0x0, 0x120(%rsp)
jmp 0xc529
jmp 0xc52b
cmpq $0x0, 0x120(%rsp)
je 0xc543
movq 0x120(%rsp), %rdi
callq 0x23c0
movq 0x118(%rsp), %rdi
callq 0x8750
movl 0x12c(%rsp), %eax
addq $0x148, %rsp            # imm = 0x148
retq
nop