#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ sqlite3;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ exec(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ perf_test(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_enable_load_extension(int /*<<< orphan*/ *, int);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_load_extension(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                           char **);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ sqlite3_shutdown();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main() {
  sqlite3 *db;
  char *zErrMsg = 0;
  int rc;
  char buf[4096] = {0};
  rc = sqlite3_open("test.db", &db);
  if (rc) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    exit(1);
  } else {
    fprintf(stdout, "Opened database successfully\n");
  }
  sqlite3_enable_load_extension(db, 1);
  rc = sqlite3_load_extension(db, "../src/libredis_vtbl.so", 0, &zErrMsg);
  if (rc) {
    fprintf(stderr, "Can't load module: %s\n", zErrMsg);
    exit(1);
  } else {
    fprintf(stdout, "Loaded module successfully\n");
  }
  exec(db, "PRAGMA synchronous = OFF");
  snprintf(buf, sizeof(buf),
           "CREATE TABLE IF NOT EXISTS test0 (\n"
           "   blah          VARCHAR(255),\n"
           "   blah2          INTEGER,\n"
           "   blah3     VARCHAR(6)\n"
           ");\n");
  if (exec(db, buf))
    goto error;
  snprintf(buf, sizeof(buf),
           "CREATE VIRTUAL TABLE test1 USING redis (localhost:6379, prefix,\n"
           "   blah          VARCHAR(255),\n"
           "   blah2          INTEGER,\n"
           "   blah3     VARCHAR(6)\n"
           ");\n");
  if (exec(db, buf))
    goto error;
  exec(db, "select redis_create_index(blah) from test1");
  snprintf(buf, sizeof(buf),
           "insert into test0 "
           "(blah, blah2, blah3) "
           "values ('%s','%d', '%s')",
           "42ea2b19af3a4678b1b71a335cf5a9ce", 1377670786, "1008");
  if (exec(db, buf))
    goto error;
  snprintf(buf, sizeof(buf),
           "insert into test1 "
           "(blah, blah2, blah3) "
           "values ('%s','%d', '%s')",
           "42ea2b19af3a4678b1b71a335cf5a9ce", 1377670786, "1008");
  if (exec(db, buf))
    goto error;
  exec(db, "select * from test0");
  exec(db, "select * from test1");
  exec(db, "DELETE from test0");
  exec(db, "DELETE from test1");
  if (perf_test(db, 0))
    goto error;
  if (perf_test(db, 1))
    goto error;
  exec(db, "DROP TABLE test0");
  exec(db, "DROP TABLE test1");
  sqlite3_close(db);
  sqlite3_shutdown();
  return 0;
error:
  exec(db, "DROP TABLE test0");
  exec(db, "DROP TABLE test1");
  sqlite3_close(db);
  sqlite3_shutdown();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
lea    0xe0c(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1243 <main+0x83>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <sqlite3_errmsg@plt>
mov    -0x1024(%rbp),%edi
mov    %rax,%rdx
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1090 <sqlite3_enable_load_extension@plt>
mov    -0x10(%rbp),%rdi
lea    0xdcc(%rip),%rsi
xor    %edx,%edx
lea    -0x18(%rbp),%rcx
call   10e0 <sqlite3_load_extension@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12b0 <main+0xf0>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   10d0 <exec@plt>
lea    -0x1020(%rbp),%rdi
mov    $0x1000,%esi
lea    0xdb9(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10d0 <exec@plt>
cmp    $0x0,%rax
je     1310 <main+0x150>
jmp    14a6 <main+0x2e6>
lea    -0x1020(%rbp),%rdi
mov    $0x1000,%esi
lea    0xdf9(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10d0 <exec@plt>
cmp    $0x0,%rax
je     1349 <main+0x189>
jmp    14a6 <main+0x2e6>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   10d0 <exec@plt>
lea    -0x1020(%rbp),%rdi
mov    $0x1000,%esi
lea    0xe71(%rip),%rdx
lea    0xeaa(%rip),%rcx
mov    $0x521d9682,%r8d
lea    0xebe(%rip),%r9
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10d0 <exec@plt>
cmp    $0x0,%rax
je     13a6 <main+0x1e6>
jmp    14a6 <main+0x2e6>
lea    -0x1020(%rbp),%rdi
mov    $0x1000,%esi
lea    0xe8a(%rip),%rdx
lea    0xe5d(%rip),%rcx
mov    $0x521d9682,%r8d
lea    0xe71(%rip),%r9
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   10d0 <exec@plt>
cmp    $0x0,%rax
je     13f3 <main+0x233>
jmp    14a6 <main+0x2e6>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10b0 <perf_test@plt>
cmp    $0x0,%rax
je     144d <main+0x28d>
jmp    14a6 <main+0x2e6>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <perf_test@plt>
cmp    $0x0,%rax
je     146a <main+0x2aa>
jmp    14a6 <main+0x2e6>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
mov    $0x0,%al
call   1060 <sqlite3_shutdown@plt>
movl   $0x0,-0x4(%rbp)
jmp    14dd <main+0x31d>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   10d0 <exec@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
mov    $0x0,%al
call   1060 <sqlite3_shutdown@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1010,%rsp
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe17(%rip),%rdi
mov    %rsp,%rsi
call   1030 <sqlite3_open@plt>
test   %eax,%eax
jne    1408 <main+0x248>
mov    0x2dd8(%rip),%rbx
mov    (%rbx),%edi
lea    0xe18(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rsp),%rdi
mov    $0x1,%esi
call   1090 <sqlite3_enable_load_extension@plt>
mov    (%rsp),%rdi
lea    0xe16(%rip),%rsi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   10e0 <sqlite3_load_extension@plt>
test   %eax,%eax
jne    1428 <main+0x268>
mov    (%rbx),%edi
lea    0xe28(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rsp),%rdi
lea    0xe32(%rip),%rsi
call   10d0 <exec@plt>
lea    0xe3f(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <exec@plt>
test   %rax,%rax
jne    13b4 <main+0x1f4>
lea    0xe88(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <exec@plt>
test   %rax,%rax
jne    13b4 <main+0x1f4>
mov    (%rsp),%rdi
lea    0xeea(%rip),%rsi
call   10d0 <exec@plt>
lea    0xf09(%rip),%rdx
lea    0xf42(%rip),%rcx
lea    0xf5c(%rip),%r9
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x521d9682,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <exec@plt>
test   %rax,%rax
jne    13b4 <main+0x1f4>
lea    0xf2b(%rip),%rdx
lea    0xefe(%rip),%rcx
lea    0xf18(%rip),%r9
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x521d9682,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <exec@plt>
test   %rax,%rax
jne    13b4 <main+0x1f4>
mov    (%rsp),%rdi
lea    0xf27(%rip),%rsi
call   10d0 <exec@plt>
mov    (%rsp),%rdi
lea    0xf2b(%rip),%rsi
call   10d0 <exec@plt>
mov    (%rsp),%rdi
lea    0xf2f(%rip),%rsi
call   10d0 <exec@plt>
mov    (%rsp),%rdi
lea    0xf31(%rip),%rsi
call   10d0 <exec@plt>
mov    (%rsp),%rdi
xor    %esi,%esi
call   10b0 <perf_test@plt>
test   %rax,%rax
jne    13b4 <main+0x1f4>
mov    (%rsp),%rdi
mov    $0x1,%esi
call   10b0 <perf_test@plt>
test   %rax,%rax
je     13f4 <main+0x234>
mov    (%rsp),%rdi
lea    0xf10(%rip),%rsi
call   10d0 <exec@plt>
mov    $0x1,%ebx
mov    (%rsp),%rdi
lea    0xf0c(%rip),%rsi
call   10d0 <exec@plt>
mov    (%rsp),%rdi
call   10a0 <sqlite3_close@plt>
xor    %eax,%eax
call   1060 <sqlite3_shutdown@plt>
mov    %ebx,%eax
add    $0x1010,%rsp
pop    %rbx
ret
mov    (%rsp),%rdi
lea    0xed0(%rip),%rsi
call   10d0 <exec@plt>
xor    %ebx,%ebx
jmp    13c9 <main+0x209>
mov    0x2bd1(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   1070 <sqlite3_errmsg@plt>
lea    0xbe7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
jmp    143d <main+0x27d>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xc1a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"test.db\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@stdout = global i32 0
@.str.2 = [30 x i8] c"Opened database successfully\0A\00"
@.str.3 = [24 x i8] c"../src/libredis_vtbl.so\00"
@.str.4 = [23 x i8] c"Can't load module: %s\0A\00"
@.str.5 = [28 x i8] c"Loaded module successfully\0A\00"
@.str.6 = [25 x i8] c"PRAGMA synchronous = OFF\00"
@.str.7 = [121 x i8] c"CREATE TABLE IF NOT EXISTS test0 (\0A blah VARCHAR(255),\0A blah2 INTEGER,\0A blah3 VARCHAR(6)\0A);\0A\00"
@.str.8 = [150 x i8] c"CREATE VIRTUAL TABLE test1 USING redis (localhost:6379, prefix,\0A blah VARCHAR(255),\0A blah2 INTEGER,\0A blah3 VARCHAR(6)\0A);\0A\00"
@.str.9 = [43 x i8] c"select redis_create_index(blah) from test1\00"
@.str.10 = [64 x i8] c"insert into test0 (blah, blah2, blah3) values ('%s','%d', '%s')\00"
@.str.11 = [33 x i8] c"42ea2b19af3a4678b1b71a335cf5a9ce\00"
@.str.12 = [5 x i8] c"1008\00"
@.str.13 = [64 x i8] c"insert into test1 (blah, blah2, blah3) values ('%s','%d', '%s')\00"
@.str.14 = [20 x i8] c"select * from test0\00"
@.str.15 = [20 x i8] c"select * from test1\00"
@.str.16 = [18 x i8] c"DELETE from test0\00"
@.str.17 = [18 x i8] c"DELETE from test1\00"
@.str.18 = [17 x i8] c"DROP TABLE test0\00"
@.str.19 = [17 x i8] c"DROP TABLE test1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [4096 x i8]
store i32 0, i32* %1
store i8* null, i8** %3
%6 = bitcast [4096 x i8]* %5 to i8*
%7 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32** %2)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = load i32*, i32** %2
%13 = call i8* @sqlite3_errmsg(i32* %12)
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* @stdout
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16
%20 = load i32*, i32** %2
%21 = call i32 @sqlite3_enable_load_extension(i32* %20, i32 1)
%22 = load i32*, i32** %2
%23 = call i32 @sqlite3_load_extension(i32* %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 0, i8** %3)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %3
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = load i32, i32* @stdout
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %31
%35 = load i32*, i32** %2
%36 = call i64 @exec(i32* %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%38 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %37, i32 4096, i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.7, i64 0, i64 0))
%39 = load i32*, i32** %2
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%41 = call i64 @exec(i32* %39, i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %34
br label %96
44: ; preds = %34
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%46 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %45, i32 4096, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32*, i32** %2
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%49 = call i64 @exec(i32* %47, i8* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %44
br label %96
52: ; preds = %44
%53 = load i32*, i32** %2
%54 = call i64 @exec(i32* %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%56 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %55, i32 4096, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 1377670786, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%57 = load i32*, i32** %2
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%59 = call i64 @exec(i32* %57, i8* %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %52
br label %96
62: ; preds = %52
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%64 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %63, i32 4096, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 1377670786, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%65 = load i32*, i32** %2
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%67 = call i64 @exec(i32* %65, i8* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %62
br label %96
70: ; preds = %62
%71 = load i32*, i32** %2
%72 = call i64 @exec(i32* %71, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%73 = load i32*, i32** %2
%74 = call i64 @exec(i32* %73, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
%75 = load i32*, i32** %2
%76 = call i64 @exec(i32* %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0))
%77 = load i32*, i32** %2
%78 = call i64 @exec(i32* %77, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
%79 = load i32*, i32** %2
%80 = call i64 @perf_test(i32* %79, i32 0)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %70
br label %96
83: ; preds = %70
%84 = load i32*, i32** %2
%85 = call i64 @perf_test(i32* %84, i32 1)
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %83
br label %96
88: ; preds = %83
%89 = load i32*, i32** %2
%90 = call i64 @exec(i32* %89, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i64 0, i64 0))
%91 = load i32*, i32** %2
%92 = call i64 @exec(i32* %91, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0))
%93 = load i32*, i32** %2
%94 = call i32 @sqlite3_close(i32* %93)
%95 = call i32 (...) @sqlite3_shutdown()
store i32 0, i32* %1
br label %104
96: ; preds = %87, %82, %69, %61, %51, %43
%97 = load i32*, i32** %2
%98 = call i64 @exec(i32* %97, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i64 0, i64 0))
%99 = load i32*, i32** %2
%100 = call i64 @exec(i32* %99, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0))
%101 = load i32*, i32** %2
%102 = call i32 @sqlite3_close(i32* %101)
%103 = call i32 (...) @sqlite3_shutdown()
store i32 1, i32* %1
br label %104
104: ; preds = %96, %88
%105 = load i32, i32* %1
ret i32 %105
}

LLVM IR (-O2):
@.str = [8 x i8] c"test.db\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@stdout = global i32 0
@.str.2 = [30 x i8] c"Opened database successfully\0A\00"
@.str.3 = [24 x i8] c"../src/libredis_vtbl.so\00"
@.str.4 = [23 x i8] c"Can't load module: %s\0A\00"
@.str.5 = [28 x i8] c"Loaded module successfully\0A\00"
@.str.6 = [25 x i8] c"PRAGMA synchronous = OFF\00"
@.str.7 = [121 x i8] c"CREATE TABLE IF NOT EXISTS test0 (\0A blah VARCHAR(255),\0A blah2 INTEGER,\0A blah3 VARCHAR(6)\0A);\0A\00"
@.str.8 = [150 x i8] c"CREATE VIRTUAL TABLE test1 USING redis (localhost:6379, prefix,\0A blah VARCHAR(255),\0A blah2 INTEGER,\0A blah3 VARCHAR(6)\0A);\0A\00"
@.str.9 = [43 x i8] c"select redis_create_index(blah) from test1\00"
@.str.10 = [64 x i8] c"insert into test0 (blah, blah2, blah3) values ('%s','%d', '%s')\00"
@.str.11 = [33 x i8] c"42ea2b19af3a4678b1b71a335cf5a9ce\00"
@.str.12 = [5 x i8] c"1008\00"
@.str.13 = [64 x i8] c"insert into test1 (blah, blah2, blah3) values ('%s','%d', '%s')\00"
@.str.14 = [20 x i8] c"select * from test0\00"
@.str.15 = [20 x i8] c"select * from test1\00"
@.str.16 = [18 x i8] c"DELETE from test0\00"
@.str.17 = [18 x i8] c"DELETE from test1\00"
@.str.18 = [17 x i8] c"DROP TABLE test0\00"
@.str.19 = [17 x i8] c"DROP TABLE test1\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i8*
%3 = alloca [4096 x i8]
%4 = bitcast i32** %1 to i8*
%5 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32** %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i32*, i32** %1
%12 = call i8* @sqlite3_errmsg(i32* %11)
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32*, i32** %1
%19 = call i32 @sqlite3_enable_load_extension(i32* %18, i32 1)
%20 = load i32*, i32** %1
%21 = call i32 @sqlite3_load_extension(i32* %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 0, i8** %2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %2
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %15
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%31 = load i32*, i32** %1
%32 = call i64 @exec(i32* %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 4096, i8* getelementptr inbounds ([121 x i8], [121 x i8]* @.str.7, i64 0, i64 0))
%34 = load i32*, i32** %1
%35 = call i64 @exec(i32* %34, i8* %6)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %73
37: ; preds = %28
%38 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 4096, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.8, i64 0, i64 0))
%39 = load i32*, i32** %1
%40 = call i64 @exec(i32* %39, i8* %6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %73
42: ; preds = %37
%43 = load i32*, i32** %1
%44 = call i64 @exec(i32* %43, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
%45 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 4096, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 1377670786, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%46 = load i32*, i32** %1
%47 = call i64 @exec(i32* %46, i8* %6)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %73
49: ; preds = %42
%50 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 4096, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 1377670786, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%51 = load i32*, i32** %1
%52 = call i64 @exec(i32* %51, i8* %6)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %73
54: ; preds = %49
%55 = load i32*, i32** %1
%56 = call i64 @exec(i32* %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%57 = load i32*, i32** %1
%58 = call i64 @exec(i32* %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
%59 = load i32*, i32** %1
%60 = call i64 @exec(i32* %59, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0))
%61 = load i32*, i32** %1
%62 = call i64 @exec(i32* %61, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
%63 = load i32*, i32** %1
%64 = call i64 @perf_test(i32* %63, i32 0)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %54
%67 = load i32*, i32** %1
%68 = call i64 @perf_test(i32* %67, i32 1)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32*, i32** %1
%72 = call i64 @exec(i32* %71, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i64 0, i64 0))
br label %76
73: ; preds = %66, %54, %49, %42, %37, %28
%74 = load i32*, i32** %1
%75 = call i64 @exec(i32* %74, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i64 0, i64 0))
br label %76
76: ; preds = %73, %70
%77 = phi i32 [ 1, %73 ], [ 0, %70 ]
%78 = load i32*, i32** %1
%79 = call i64 @exec(i32* %78, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0))
%80 = load i32*, i32** %1
%81 = call i32 @sqlite3_close(i32* %80)
%82 = call i32 (...) @sqlite3_shutdown()
ret i32 %77
}