#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_stmt;
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
int /*<<< orphan*/ DirectExec(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ DirectExecNoResult(int /*<<< orphan*/ *, char *);
#define SQLITE_INTEGER 130
int SQLITE_OK;
#define SQLITE_ROW 129
#define SQLITE_TEXT 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
int sqlite3_bind_parameter_count(int /*<<< orphan*/ *);
int sqlite3_changes(int /*<<< orphan*/ *);
int sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_int(int /*<<< orphan*/ *, int);
char *sqlite3_column_name(int /*<<< orphan*/ *, int);
unsigned char *sqlite3_column_text(int /*<<< orphan*/ *, int);
int sqlite3_column_type(int /*<<< orphan*/ *, int);
int sqlite3_data_count(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int sqlite3_prepare(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                    char const **);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unlink(char *);
int main(void) {
  sqlite3 *db;
  int rc;
  sqlite3_stmt *stmt;
  const char *ptr;
  int i;
  (void)unlink("testc.db");
  rc = sqlite3_open("testc.db", &db);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    (void)sqlite3_close(db);
    exit(1);
  }
  printf("thread-safe: no\n");
  DirectExecNoResult(db, "create table a( b integer, s text )");
  DirectExecNoResult(db, "insert into a(b,s) values (8,'bla')");
  DirectExecNoResult(db, "insert into a(b,s) values (4,'blu')");
  DirectExecNoResult(db, "insert into a(b,s) values (1,'bli')");
  printf("number of rows changed: %d (MUST: 1)\n", sqlite3_changes(db));
  DirectExecNoResult(db, "delete from a where b=47");
  printf("number of rows changed: %d (MUST: 0)\n", sqlite3_changes(db));
  DirectExec(db, "select * from a");
  rc = sqlite3_prepare(db, "select * from a where b>=$1 and b<=$2", -1, &stmt,
                       &ptr);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Unable to prepare statement: %s\n", sqlite3_errmsg(db));
    (void)sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_bind_int(stmt, 1, 3);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Unable to bind first parameter: %s\n", sqlite3_errmsg(db));
    (void)sqlite3_finalize(stmt);
    (void)sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_bind_int(stmt, 2, 4);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Unable to bind second parameter: %s\n",
            sqlite3_errmsg(db));
    (void)sqlite3_finalize(stmt);
    (void)sqlite3_close(db);
    exit(1);
  }
  printf("number of bind parameters: %d (MUST: 2)\n",
         sqlite3_bind_parameter_count(stmt));
  rc = sqlite3_step(stmt);
  while (rc == SQLITE_ROW) {
    switch (rc) {
    case SQLITE_ROW:
      printf("nof columns: %d\n", sqlite3_data_count(stmt));
      for (i = 0; i < sqlite3_data_count(stmt); i++) {
        const char *colname = sqlite3_column_name(stmt, i);
        int data_type = sqlite3_column_type(stmt, i);
        switch (data_type) {
        case SQLITE_INTEGER: {
          int value = sqlite3_column_int(stmt, i);
          printf("%s(%d) = %d\n", colname, data_type, value);
        } break;
        case SQLITE_TEXT: {
          const unsigned char *value = sqlite3_column_text(stmt, i);
          printf("%s(%d) = %s\n", colname, data_type, value);
        } break;
        }
      }
      break;
    default:
      fprintf(stderr, "Unable to step through statement: %s\n",
              sqlite3_errmsg(db));
      (void)sqlite3_finalize(stmt);
      (void)sqlite3_close(db);
      exit(1);
    }
    rc = sqlite3_step(stmt);
  }
  rc = sqlite3_finalize(stmt);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Unable to finalize statement: %s\n", sqlite3_errmsg(db));
    (void)sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_close(db);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Can't close database: %s\n", sqlite3_errmsg(db));
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xdaa(%rip),%rdi
call   1030 <unlink@plt>
lea    0xd9e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <sqlite3_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2d70(%rip),%rcx
cmp    (%rcx),%eax
je     12ba <main+0x7a>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%rdx
lea    0xd67(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1060 <DirectExecNoResult@plt>
mov    -0x10(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1060 <DirectExecNoResult@plt>
mov    -0x10(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1060 <DirectExecNoResult@plt>
mov    -0x10(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1060 <DirectExecNoResult@plt>
mov    -0x10(%rbp),%rdi
call   1130 <sqlite3_changes@plt>
mov    %eax,%esi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1060 <DirectExecNoResult@plt>
mov    -0x10(%rbp),%rdi
call   1130 <sqlite3_changes@plt>
mov    %eax,%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdd3(%rip),%rsi
call   1040 <DirectExec@plt>
mov    -0x10(%rbp),%rdi
lea    0xdd3(%rip),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1140 <sqlite3_prepare@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2c64(%rip),%rcx
cmp    (%rcx),%eax
je     13c6 <main+0x186>
mov    0x2c45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%rdx
lea    0xdb0(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1080 <sqlite3_bind_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2c02(%rip),%rcx
cmp    (%rcx),%eax
je     1431 <main+0x1f1>
mov    0x2be3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xd6f(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1150 <sqlite3_finalize@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1080 <sqlite3_bind_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2b97(%rip),%rcx
cmp    (%rcx),%eax
je     149c <main+0x25c>
mov    0x2b78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xd28(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1150 <sqlite3_finalize@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <sqlite3_bind_parameter_count@plt>
mov    %eax,%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10e0 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x81,-0x14(%rbp)
jne    1626 <main+0x3e6>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
jne    15d2 <main+0x392>
jmp    14e1 <main+0x2a1>
mov    -0x20(%rbp),%rdi
call   1100 <sqlite3_data_count@plt>
mov    %eax,%esi
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x20(%rbp),%rdi
call   1100 <sqlite3_data_count@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jge    15cd <main+0x38d>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <sqlite3_column_name@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10d0 <sqlite3_column_type@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x60(%rbp)
sub    $0x80,%eax
je     1591 <main+0x351>
jmp    1552 <main+0x312>
mov    -0x60(%rbp),%eax
sub    $0x82,%eax
jne    15ba <main+0x37a>
jmp    1565 <main+0x325>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10b0 <sqlite3_column_int@plt>
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
lea    0xc7d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    15ba <main+0x37a>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1120 <sqlite3_column_text@plt>
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x48(%rbp),%rcx
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    15bf <main+0x37f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1501 <main+0x2c1>
jmp    1615 <main+0x3d5>
mov    0x29ff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xc28(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1150 <sqlite3_finalize@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10e0 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
jmp    14c1 <main+0x281>
mov    -0x20(%rbp),%rdi
call   1150 <sqlite3_finalize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x29ac(%rip),%rcx
cmp    (%rcx),%eax
je     167e <main+0x43e>
mov    0x298d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rdx
lea    0xbdc(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1110 <sqlite3_close@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2954(%rip),%rcx
cmp    (%rcx),%eax
je     16cd <main+0x48d>
mov    0x2935(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <sqlite3_errmsg@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xba6(%rip),%rsi
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   1160 <exit@plt>
xor    %edi,%edi
call   1160 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xd9b(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <sqlite3_open@plt>
mov    0x2d69(%rip),%r13
cmp    0x0(%r13),%eax
jne    149d <main+0x24d>
lea    0xfb7(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%rdi
lea    0xd82(%rip),%rsi
call   1070 <DirectExecNoResult@plt>
mov    (%rsp),%rdi
lea    0xd96(%rip),%rsi
call   1070 <DirectExecNoResult@plt>
mov    (%rsp),%rdi
lea    0xdaa(%rip),%rsi
call   1070 <DirectExecNoResult@plt>
mov    (%rsp),%rdi
lea    0xdbe(%rip),%rsi
call   1070 <DirectExecNoResult@plt>
mov    (%rsp),%rdi
call   1140 <sqlite3_changes@plt>
lea    0xdcd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    (%rsp),%rdi
lea    0xddf(%rip),%rsi
call   1070 <DirectExecNoResult@plt>
mov    (%rsp),%rdi
call   1140 <sqlite3_changes@plt>
lea    0xde3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    (%rsp),%rdi
lea    0xdf5(%rip),%rsi
call   1040 <DirectExec@plt>
mov    (%rsp),%rdi
lea    0xdf5(%rip),%rsi
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    $0xffffffff,%edx
call   1150 <sqlite3_prepare@plt>
cmp    0x0(%r13),%eax
jne    14b8 <main+0x268>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1090 <sqlite3_bind_int@plt>
cmp    0x0(%r13),%eax
jne    14ee <main+0x29e>
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1090 <sqlite3_bind_int@plt>
cmp    0x0(%r13),%eax
jne    1509 <main+0x2b9>
mov    0x8(%rsp),%rdi
call   10b0 <sqlite3_bind_parameter_count@plt>
lea    0xe1a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x8(%rsp),%rdi
call   10f0 <sqlite3_step@plt>
cmp    $0x81,%eax
jne    1538 <main+0x2e8>
lea    0xe1e(%rip),%r14
lea    0xe35(%rip),%r15
lea    0xe21(%rip),%r12
jmp    13f5 <main+0x1a5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%rdi
call   10f0 <sqlite3_step@plt>
cmp    $0x81,%eax
jne    1538 <main+0x2e8>
mov    0x8(%rsp),%rdi
call   1110 <sqlite3_data_count@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x8(%rsp),%rdi
call   1110 <sqlite3_data_count@plt>
test   %eax,%eax
jle    13e0 <main+0x190>
xor    %ebp,%ebp
jmp    1452 <main+0x202>
nopl   (%rax)
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1130 <sqlite3_column_text@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x80,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%rdi
call   1110 <sqlite3_data_count@plt>
cmp    %eax,%ebp
jge    13e0 <main+0x190>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1060 <sqlite3_column_name@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   10e0 <sqlite3_column_type@plt>
cmp    $0x80,%eax
je     1420 <main+0x1d0>
cmp    $0x82,%eax
jne    1441 <main+0x1f1>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   10c0 <sqlite3_column_int@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x82,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    1441 <main+0x1f1>
mov    0x2b34(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xb53(%rip),%rsi
jmp    14d1 <main+0x281>
mov    0x2b19(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xc7c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1100 <fprintf@plt>
mov    (%rsp),%rdi
call   1120 <sqlite3_close@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2ae3(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xc67(%rip),%rsi
jmp    1522 <main+0x2d2>
mov    0x2ac8(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xc70(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1100 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1160 <sqlite3_finalize@plt>
jmp    14db <main+0x28b>
mov    0x8(%rsp),%rdi
call   1160 <sqlite3_finalize@plt>
cmp    0x0(%r13),%eax
jne    155e <main+0x30e>
mov    (%rsp),%rdi
call   1120 <sqlite3_close@plt>
cmp    0x0(%r13),%eax
jne    157c <main+0x32c>
xor    %edi,%edi
call   1170 <exit@plt>
mov    0x2a73(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xc94(%rip),%rsi
jmp    14d1 <main+0x281>
mov    0x2a55(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   10d0 <sqlite3_errmsg@plt>
lea    0xc98(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"testc.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.2 = [17 x i8] c"thread-safe: no\0A\00"
@.str.3 = [36 x i8] c"create table a( b integer, s text )\00"
@.str.4 = [36 x i8] c"insert into a(b,s) values (8,'bla')\00"
@.str.5 = [36 x i8] c"insert into a(b,s) values (4,'blu')\00"
@.str.6 = [36 x i8] c"insert into a(b,s) values (1,'bli')\00"
@.str.7 = [38 x i8] c"number of rows changed: %d (MUST: 1)\0A\00"
@.str.8 = [25 x i8] c"delete from a where b=47\00"
@.str.9 = [38 x i8] c"number of rows changed: %d (MUST: 0)\0A\00"
@.str.10 = [16 x i8] c"select * from a\00"
@.str.11 = [38 x i8] c"select * from a where b>=$1 and b<=$2\00"
@.str.12 = [33 x i8] c"Unable to prepare statement: %s\0A\00"
@.str.13 = [36 x i8] c"Unable to bind first parameter: %s\0A\00"
@.str.14 = [37 x i8] c"Unable to bind second parameter: %s\0A\00"
@.str.15 = [41 x i8] c"number of bind parameters: %d (MUST: 2)\0A\00"
@.str.16 = [17 x i8] c"nof columns: %d\0A\00"
@.str.17 = [13 x i8] c"%s(%d) = %d\0A\00"
@.str.18 = [13 x i8] c"%s(%d) = %s\0A\00"
@.str.19 = [38 x i8] c"Unable to step through statement: %s\0A\00"
@.str.20 = [34 x i8] c"Unable to finalize statement: %s\0A\00"
@.str.21 = [26 x i8] c"Can't close database: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %1
%11 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @sqlite3_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32** %2)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = load i32, i32* @SQLITE_OK
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = load i32*, i32** %2
%19 = call i8* @sqlite3_errmsg(i32* %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i32*, i32** %2
%22 = call i32 @sqlite3_close(i32* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** %2
%27 = call i32 @DirectExecNoResult(i32* %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32*, i32** %2
%29 = call i32 @DirectExecNoResult(i32* %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32*, i32** %2
%31 = call i32 @DirectExecNoResult(i32* %30, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32*, i32** %2
%33 = call i32 @DirectExecNoResult(i32* %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%34 = load i32*, i32** %2
%35 = call i32 @sqlite3_changes(i32* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %2
%38 = call i32 @DirectExecNoResult(i32* %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%39 = load i32*, i32** %2
%40 = call i32 @sqlite3_changes(i32* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %2
%43 = call i32 @DirectExec(i32* %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%44 = load i32*, i32** %2
%45 = call i32 @sqlite3_prepare(i32* %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 -1, i32** %4, i8** %5)
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = load i32, i32* @SQLITE_OK
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %57
49: ; preds = %24
%50 = load i32, i32* @stderr
%51 = load i32*, i32** %2
%52 = call i8* @sqlite3_errmsg(i32* %51)
%53 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i8* %52)
%54 = load i32*, i32** %2
%55 = call i32 @sqlite3_close(i32* %54)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %24
%58 = load i32*, i32** %4
%59 = call i32 @sqlite3_bind_int(i32* %58, i32 1, i32 3)
store i32 %59, i32* %3
%60 = load i32, i32* %3
%61 = load i32, i32* @SQLITE_OK
%62 = icmp ne i32 %60, %61
br i1 %62, label %63, label %73
63: ; preds = %57
%64 = load i32, i32* @stderr
%65 = load i32*, i32** %2
%66 = call i8* @sqlite3_errmsg(i32* %65)
%67 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8* %66)
%68 = load i32*, i32** %4
%69 = call i32 @sqlite3_finalize(i32* %68)
%70 = load i32*, i32** %2
%71 = call i32 @sqlite3_close(i32* %70)
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %57
%74 = load i32*, i32** %4
%75 = call i32 @sqlite3_bind_int(i32* %74, i32 2, i32 4)
store i32 %75, i32* %3
%76 = load i32, i32* %3
%77 = load i32, i32* @SQLITE_OK
%78 = icmp ne i32 %76, %77
br i1 %78, label %79, label %89
79: ; preds = %73
%80 = load i32, i32* @stderr
%81 = load i32*, i32** %2
%82 = call i8* @sqlite3_errmsg(i32* %81)
%83 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* %82)
%84 = load i32*, i32** %4
%85 = call i32 @sqlite3_finalize(i32* %84)
%86 = load i32*, i32** %2
%87 = call i32 @sqlite3_close(i32* %86)
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %73
%90 = load i32*, i32** %4
%91 = call i32 @sqlite3_bind_parameter_count(i32* %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i32 %91)
%93 = load i32*, i32** %4
%94 = call i32 @sqlite3_step(i32* %93)
store i32 %94, i32* %3
br label %95
95: ; preds = %148, %89
%96 = load i32, i32* %3
%97 = icmp eq i32 %96, 129
br i1 %97, label %98, label %151
98: ; preds = %95
%99 = load i32, i32* %3
switch i32 %99, label %138 [
i32 129, label %100
]
100: ; preds = %98
%101 = load i32*, i32** %4
%102 = call i32 @sqlite3_data_count(i32* %101)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i32 %102)
store i32 0, i32* %6
br label %104
104: ; preds = %134, %100
%105 = load i32, i32* %6
%106 = load i32*, i32** %4
%107 = call i32 @sqlite3_data_count(i32* %106)
%108 = icmp slt i32 %105, %107
br i1 %108, label %109, label %137
109: ; preds = %104
%110 = load i32*, i32** %4
%111 = load i32, i32* %6
%112 = call i8* @sqlite3_column_name(i32* %110, i32 %111)
store i8* %112, i8** %7
%113 = load i32*, i32** %4
%114 = load i32, i32* %6
%115 = call i32 @sqlite3_column_type(i32* %113, i32 %114)
store i32 %115, i32* %8
%116 = load i32, i32* %8
switch i32 %116, label %133 [
i32 130, label %117
i32 128, label %125
]
117: ; preds = %109
%118 = load i32*, i32** %4
%119 = load i32, i32* %6
%120 = call i32 @sqlite3_column_int(i32* %118, i32 %119)
store i32 %120, i32* %9
%121 = load i8*, i8** %7
%122 = load i32, i32* %8
%123 = load i32, i32* %9
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* %121, i32 %122, i32 %123)
br label %133
125: ; preds = %109
%126 = load i32*, i32** %4
%127 = load i32, i32* %6
%128 = call i8* @sqlite3_column_text(i32* %126, i32 %127)
store i8* %128, i8** %10
%129 = load i8*, i8** %7
%130 = load i32, i32* %8
%131 = load i8*, i8** %10
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* %129, i32 %130, i8* %131)
br label %133
133: ; preds = %109, %125, %117
br label %134
134: ; preds = %133
%135 = load i32, i32* %6
%136 = add nsw i32 %135, 1
store i32 %136, i32* %6
br label %104
137: ; preds = %104
br label %148
138: ; preds = %98
%139 = load i32, i32* @stderr
%140 = load i32*, i32** %2
%141 = call i8* @sqlite3_errmsg(i32* %140)
%142 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.19, i64 0, i64 0), i8* %141)
%143 = load i32*, i32** %4
%144 = call i32 @sqlite3_finalize(i32* %143)
%145 = load i32*, i32** %2
%146 = call i32 @sqlite3_close(i32* %145)
%147 = call i32 @exit(i32 1)
unreachable
148: ; preds = %137
%149 = load i32*, i32** %4
%150 = call i32 @sqlite3_step(i32* %149)
store i32 %150, i32* %3
br label %95
151: ; preds = %95
%152 = load i32*, i32** %4
%153 = call i32 @sqlite3_finalize(i32* %152)
store i32 %153, i32* %3
%154 = load i32, i32* %3
%155 = load i32, i32* @SQLITE_OK
%156 = icmp ne i32 %154, %155
br i1 %156, label %157, label %165
157: ; preds = %151
%158 = load i32, i32* @stderr
%159 = load i32*, i32** %2
%160 = call i8* @sqlite3_errmsg(i32* %159)
%161 = call i32 @fprintf(i32 %158, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.20, i64 0, i64 0), i8* %160)
%162 = load i32*, i32** %2
%163 = call i32 @sqlite3_close(i32* %162)
%164 = call i32 @exit(i32 1)
unreachable
165: ; preds = %151
%166 = load i32*, i32** %2
%167 = call i32 @sqlite3_close(i32* %166)
store i32 %167, i32* %3
%168 = load i32, i32* %3
%169 = load i32, i32* @SQLITE_OK
%170 = icmp ne i32 %168, %169
br i1 %170, label %171, label %177
171: ; preds = %165
%172 = load i32, i32* @stderr
%173 = load i32*, i32** %2
%174 = call i8* @sqlite3_errmsg(i32* %173)
%175 = call i32 @fprintf(i32 %172, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0), i8* %174)
%176 = call i32 @exit(i32 1)
unreachable
177: ; preds = %165
%178 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"testc.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.3 = [36 x i8] c"create table a( b integer, s text )\00"
@.str.4 = [36 x i8] c"insert into a(b,s) values (8,'bla')\00"
@.str.5 = [36 x i8] c"insert into a(b,s) values (4,'blu')\00"
@.str.6 = [36 x i8] c"insert into a(b,s) values (1,'bli')\00"
@.str.7 = [38 x i8] c"number of rows changed: %d (MUST: 1)\0A\00"
@.str.8 = [25 x i8] c"delete from a where b=47\00"
@.str.9 = [38 x i8] c"number of rows changed: %d (MUST: 0)\0A\00"
@.str.10 = [16 x i8] c"select * from a\00"
@.str.11 = [38 x i8] c"select * from a where b>=$1 and b<=$2\00"
@.str.12 = [33 x i8] c"Unable to prepare statement: %s\0A\00"
@.str.13 = [36 x i8] c"Unable to bind first parameter: %s\0A\00"
@.str.14 = [37 x i8] c"Unable to bind second parameter: %s\0A\00"
@.str.15 = [41 x i8] c"number of bind parameters: %d (MUST: 2)\0A\00"
@.str.16 = [17 x i8] c"nof columns: %d\0A\00"
@.str.17 = [13 x i8] c"%s(%d) = %d\0A\00"
@.str.18 = [13 x i8] c"%s(%d) = %s\0A\00"
@.str.20 = [34 x i8] c"Unable to finalize statement: %s\0A\00"
@.str.21 = [26 x i8] c"Can't close database: %s\0A\00"
@str = [16 x i8] c"thread-safe: no\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i8*
%4 = bitcast i32** %1 to i8*
%5 = bitcast i32** %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = tail call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @sqlite3_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32** %1)
%9 = load i32, i32* @SQLITE_OK
%10 = icmp eq i32 %8, %9
br i1 %10, label %19, label %11
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = load i32*, i32** %1
%14 = call i8* @sqlite3_errmsg(i32* %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32*, i32** %1
%17 = call i32 @sqlite3_close(i32* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%21 = load i32*, i32** %1
%22 = call i32 @DirectExecNoResult(i32* %21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32*, i32** %1
%24 = call i32 @DirectExecNoResult(i32* %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32*, i32** %1
%26 = call i32 @DirectExecNoResult(i32* %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%27 = load i32*, i32** %1
%28 = call i32 @DirectExecNoResult(i32* %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%29 = load i32*, i32** %1
%30 = call i32 @sqlite3_changes(i32* %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %1
%33 = call i32 @DirectExecNoResult(i32* %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%34 = load i32*, i32** %1
%35 = call i32 @sqlite3_changes(i32* %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %1
%38 = call i32 @DirectExec(i32* %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%39 = load i32*, i32** %1
%40 = call i32 @sqlite3_prepare(i32* %39, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 -1, i32** %2, i8** %3)
%41 = load i32, i32* @SQLITE_OK
%42 = icmp eq i32 %40, %41
br i1 %42, label %51, label %43
43: ; preds = %19
%44 = load i32, i32* @stderr
%45 = load i32*, i32** %1
%46 = call i8* @sqlite3_errmsg(i32* %45)
%47 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i8* %46)
%48 = load i32*, i32** %1
%49 = call i32 @sqlite3_close(i32* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %19
%52 = load i32*, i32** %2
%53 = call i32 @sqlite3_bind_int(i32* %52, i32 1, i32 3)
%54 = load i32, i32* @SQLITE_OK
%55 = icmp eq i32 %53, %54
br i1 %55, label %66, label %56
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = load i32*, i32** %1
%59 = call i8* @sqlite3_errmsg(i32* %58)
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8* %59)
%61 = load i32*, i32** %2
%62 = call i32 @sqlite3_finalize(i32* %61)
%63 = load i32*, i32** %1
%64 = call i32 @sqlite3_close(i32* %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %51
%67 = load i32*, i32** %2
%68 = call i32 @sqlite3_bind_int(i32* %67, i32 2, i32 4)
%69 = load i32, i32* @SQLITE_OK
%70 = icmp eq i32 %68, %69
br i1 %70, label %81, label %71
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = load i32*, i32** %1
%74 = call i8* @sqlite3_errmsg(i32* %73)
%75 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* %74)
%76 = load i32*, i32** %2
%77 = call i32 @sqlite3_finalize(i32* %76)
%78 = load i32*, i32** %1
%79 = call i32 @sqlite3_close(i32* %78)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %66
%82 = load i32*, i32** %2
%83 = call i32 @sqlite3_bind_parameter_count(i32* %82)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i32 %83)
%85 = load i32*, i32** %2
%86 = call i32 @sqlite3_step(i32* %85)
%87 = icmp eq i32 %86, 129
br i1 %87, label %88, label %118
88: ; preds = %81, %114
%89 = load i32*, i32** %2
%90 = call i32 @sqlite3_data_count(i32* %89)
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i32 %90)
%92 = load i32*, i32** %2
%93 = call i32 @sqlite3_data_count(i32* %92)
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %114
95: ; preds = %88, %109
%96 = phi i32 [ %110, %109 ], [ 0, %88 ]
%97 = load i32*, i32** %2
%98 = call i8* @sqlite3_column_name(i32* %97, i32 %96)
%99 = load i32*, i32** %2
%100 = call i32 @sqlite3_column_type(i32* %99, i32 %96)
switch i32 %100, label %109 [
i32 130, label %101
i32 128, label %105
]
101: ; preds = %95
%102 = load i32*, i32** %2
%103 = call i32 @sqlite3_column_int(i32* %102, i32 %96)
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* %98, i32 130, i32 %103)
br label %109
105: ; preds = %95
%106 = load i32*, i32** %2
%107 = call i8* @sqlite3_column_text(i32* %106, i32 %96)
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* %98, i32 128, i8* %107)
br label %109
109: ; preds = %95, %105, %101
%110 = add nuw nsw i32 %96, 1
%111 = load i32*, i32** %2
%112 = call i32 @sqlite3_data_count(i32* %111)
%113 = icmp slt i32 %110, %112
br i1 %113, label %95, label %114
114: ; preds = %109, %88
%115 = load i32*, i32** %2
%116 = call i32 @sqlite3_step(i32* %115)
%117 = icmp eq i32 %116, 129
br i1 %117, label %88, label %118
118: ; preds = %114, %81
%119 = load i32*, i32** %2
%120 = call i32 @sqlite3_finalize(i32* %119)
%121 = load i32, i32* @SQLITE_OK
%122 = icmp eq i32 %120, %121
br i1 %122, label %131, label %123
123: ; preds = %118
%124 = load i32, i32* @stderr
%125 = load i32*, i32** %1
%126 = call i8* @sqlite3_errmsg(i32* %125)
%127 = call i32 @fprintf(i32 %124, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.20, i64 0, i64 0), i8* %126)
%128 = load i32*, i32** %1
%129 = call i32 @sqlite3_close(i32* %128)
%130 = call i32 @exit(i32 1)
unreachable
131: ; preds = %118
%132 = load i32*, i32** %1
%133 = call i32 @sqlite3_close(i32* %132)
%134 = load i32, i32* @SQLITE_OK
%135 = icmp eq i32 %133, %134
br i1 %135, label %142, label %136
136: ; preds = %131
%137 = load i32, i32* @stderr
%138 = load i32*, i32** %1
%139 = call i8* @sqlite3_errmsg(i32* %138)
%140 = call i32 @fprintf(i32 %137, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0), i8* %139)
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %131
%143 = call i32 @exit(i32 0)
unreachable
}