#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*/ DPRINTF(int, int, char *, char *, ...);
int SQLITE_DONE;
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ free(char *);
scalar_t__ sqlite3_column_text(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_free(char *);
char *sqlite3_mprintf(char *, char const *, char const *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
char *strdup(char *);
int db_drop_from_master(sqlite3 *hdl, const char *type, const char *prefix) {
  sqlite3_stmt *stmt;
  char *errmsg;
  char *query;
  char *name[256];
  int ret;
  int i;
  int n;
  query = sqlite3_mprintf("SELECT name FROM sqlite_master WHERE type == "
                          "lower('%s') AND name LIKE '%s_%%';",
                          type, prefix);
  DPRINTF(4, 2, "Running query '%s'\n", query);
  ret = sqlite3_prepare_v2(hdl, query, -1, &stmt, NULL);
  if (ret != SQLITE_OK) {
    DPRINTF(1, 2, "Could not prepare statement '%s': %s\n", query,
            sqlite3_errmsg(hdl));
    sqlite3_free(query);
    return -1;
  }
  n = 0;
  while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
    name[n] = strdup((char *)sqlite3_column_text(stmt, 0));
    n++;
  }
  sqlite3_finalize(stmt);
  if (ret != SQLITE_DONE) {
    DPRINTF(1, 2, "Could not step '%s': %s\n", query, sqlite3_errmsg(hdl));
    sqlite3_free(query);
    ret = -1;
    goto out;
  }
  sqlite3_free(query);
  for (i = 0; i < n; i++) {
    query = sqlite3_mprintf("DROP %s %q;", type, name[i]);
    DPRINTF(4, 2, "Running query '%s'\n", query);
    ret = sqlite3_exec(hdl, query, NULL, NULL, &errmsg);
    if (ret != SQLITE_OK) {
      DPRINTF(1, 2, "DB error while running '%s': %s\n", query, errmsg);
      sqlite3_free(errmsg);
      sqlite3_free(query);
      ret = -1;
      goto out;
    }
    sqlite3_free(query);
  }
out:
  for (i = 0; i < n; i++)
    free(name[i]);
  return ret;
}


x86 assembly (clang, -O0):
<db_drop_from_master>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe2a(%rip),%rdi
call   10b0 <sqlite3_mprintf@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xe5c(%rip),%rdx
mov    $0x0,%al
call   10d0 <DPRINTF@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x28(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    %eax,-0x844(%rbp)
mov    -0x844(%rbp),%eax
mov    0x2dbf(%rip),%rcx
cmp    (%rcx),%eax
je     127c <db_drop_from_master+0xcc>
mov    -0x38(%rbp),%rax
mov    %rax,-0x858(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x858(%rbp),%rcx
mov    %rax,%r8
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xe04(%rip),%rdx
mov    $0x0,%al
call   10d0 <DPRINTF@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1490 <db_drop_from_master+0x2e0>
movl   $0x0,-0x84c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <sqlite3_step@plt>
mov    %eax,-0x844(%rbp)
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%eax
jne    12dd <db_drop_from_master+0x12d>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%rdi
call   10c0 <strdup@plt>
mov    %rax,%rcx
movslq -0x84c(%rbp),%rax
mov    %rcx,-0x840(%rbp,%rax,8)
ff
mov    -0x84c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84c(%rbp)
jmp    1286 <db_drop_from_master+0xd6>
mov    -0x28(%rbp),%rdi
call   1080 <sqlite3_finalize@plt>
mov    -0x844(%rbp),%eax
mov    0x2ce5(%rip),%rcx
cmp    (%rcx),%eax
je     1349 <db_drop_from_master+0x199>
mov    -0x38(%rbp),%rax
mov    %rax,-0x860(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x860(%rbp),%rcx
mov    %rax,%r8
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xd60(%rip),%rdx
mov    $0x0,%al
call   10d0 <DPRINTF@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
movl   $0xffffffff,-0x844(%rbp)
ff ff ff
jmp    1443 <db_drop_from_master+0x293>
mov    -0x38(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
movl   $0x0,-0x848(%rbp)
mov    -0x848(%rbp),%eax
cmp    -0x84c(%rbp),%eax
jge    143e <db_drop_from_master+0x28e>
mov    -0x18(%rbp),%rsi
movslq -0x848(%rbp),%rax
mov    -0x840(%rbp,%rax,8),%rdx
ff
lea    0xd1b(%rip),%rdi
call   10b0 <sqlite3_mprintf@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xcaa(%rip),%rdx
mov    $0x0,%al
call   10d0 <DPRINTF@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <sqlite3_exec@plt>
mov    %eax,-0x844(%rbp)
mov    -0x844(%rbp),%eax
mov    0x2c10(%rip),%rcx
cmp    (%rcx),%eax
je     1421 <db_drop_from_master+0x271>
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xcb6(%rip),%rdx
mov    $0x0,%al
call   10d0 <DPRINTF@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
movl   $0xffffffff,-0x844(%rbp)
ff ff ff
jmp    1443 <db_drop_from_master+0x293>
mov    -0x38(%rbp),%rdi
call   10a0 <sqlite3_free@plt>
mov    -0x848(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x848(%rbp)
jmp    135c <db_drop_from_master+0x1ac>
jmp    1443 <db_drop_from_master+0x293>
movl   $0x0,-0x848(%rbp)
mov    -0x848(%rbp),%eax
cmp    -0x84c(%rbp),%eax
jge    1487 <db_drop_from_master+0x2d7>
movslq -0x848(%rbp),%rax
mov    -0x840(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x848(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x848(%rbp)
jmp    144d <db_drop_from_master+0x29d>
mov    -0x844(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_drop_from_master>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rdi,%r14
lea    0xe35(%rip),%rdi
mov    %rsi,0x18(%rsp)
call   10b0 <sqlite3_mprintf@plt>
mov    %rax,%rbx
lea    0xe71(%rip),%rdx
xor    %r13d,%r13d
mov    $0x4,%edi
mov    $0x2,%esi
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <DPRINTF@plt>
mov    $0xffffffff,%ebp
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    0x2dce(%rip),%rcx
cmp    (%rcx),%eax
jne    1314 <db_drop_from_master+0x164>
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_step@plt>
mov    %eax,%ebp
mov    0x2d9b(%rip),%r15
cmp    (%r15),%eax
jne    126e <db_drop_from_master+0xbe>
xor    %r13d,%r13d
nopl   (%rax)
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%rdi
call   10c0 <strdup@plt>
mov    %rax,0x20(%rsp,%r13,8)
add    $0x1,%r13
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_step@plt>
cmp    (%r15),%eax
je     1240 <db_drop_from_master+0x90>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_finalize@plt>
mov    0x2d59(%rip),%rax
cmp    (%rax),%ebp
jne    1347 <db_drop_from_master+0x197>
mov    %rbx,%rdi
call   10a0 <sqlite3_free@plt>
test   %r13d,%r13d
je     13c3 <db_drop_from_master+0x213>
mov    %r13d,%r12d
xor    %r15d,%r15d
xchg   %ax,%ax
mov    0x20(%rsp,%r15,8),%rdx
lea    0xdf7(%rip),%rdi
mov    0x18(%rsp),%rsi
call   10b0 <sqlite3_mprintf@plt>
mov    %rax,%rbx
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xd86(%rip),%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <DPRINTF@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x10(%rsp),%r8
call   1040 <sqlite3_exec@plt>
mov    %eax,%ebp
mov    0x2cf7(%rip),%rax
cmp    (%rax),%ebp
jne    136f <db_drop_from_master+0x1bf>
mov    %rbx,%rdi
call   10a0 <sqlite3_free@plt>
add    $0x1,%r15
cmp    %r15,%r12
jne    12a0 <db_drop_from_master+0xf0>
test   %r13d,%r13d
jne    13ab <db_drop_from_master+0x1fb>
jmp    13c3 <db_drop_from_master+0x213>
mov    %r14,%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xd41(%rip),%rdx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   10d0 <DPRINTF@plt>
mov    %rbx,%rdi
call   10a0 <sqlite3_free@plt>
jmp    13c3 <db_drop_from_master+0x213>
mov    %r14,%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xd34(%rip),%rdx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   10d0 <DPRINTF@plt>
jmp    1399 <db_drop_from_master+0x1e9>
mov    0x10(%rsp),%r8
lea    0xd34(%rip),%rdx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10d0 <DPRINTF@plt>
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_free@plt>
mov    %rbx,%rdi
call   10a0 <sqlite3_free@plt>
mov    $0xffffffff,%ebp
test   %r13d,%r13d
je     13c3 <db_drop_from_master+0x213>
mov    %r13d,%r14d
xor    %ebx,%ebx
mov    0x20(%rsp,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    13b0 <db_drop_from_master+0x200>
mov    %ebp,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [80 x i8] c"SELECT name FROM sqlite_master WHERE type == lower('%s') AND name LIKE '%s_%%';\00"
@.str.1 = [20 x i8] c"Running query '%s'\0A\00"
@SQLITE_OK = global i32 0
@.str.2 = [38 x i8] c"Could not prepare statement '%s': %s\0A\00"
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@.str.3 = [25 x i8] c"Could not step '%s': %s\0A\00"
@.str.4 = [12 x i8] c"DROP %s %q;\00"
@.str.5 = [33 x i8] c"DB error while running '%s': %s\0A\00"
define i32 @db_drop_from_master(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [256 x i8*]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16)
store i8* %17, i8** %10
%18 = load i8*, i8** %10
%19 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32*, i32** %5
%21 = load i8*, i8** %10
%22 = call i32 @sqlite3_prepare_v2(i32* %20, i8* %21, i32 -1, i32** %8, i32* null)
store i32 %22, i32* %12
%23 = load i32, i32* %12
%24 = load i32, i32* @SQLITE_OK
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %3
%27 = load i8*, i8** %10
%28 = load i32*, i32** %5
%29 = call i8* @sqlite3_errmsg(i32* %28)
%30 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %29)
%31 = load i8*, i8** %10
%32 = call i32 @sqlite3_free(i8* %31)
store i32 -1, i32* %4
br label %115
33: ; preds = %3
store i32 0, i32* %14
br label %34
34: ; preds = %39, %33
%35 = load i32*, i32** %8
%36 = call i32 @sqlite3_step(i32* %35)
store i32 %36, i32* %12
%37 = load i32, i32* @SQLITE_ROW
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %34
%40 = load i32*, i32** %8
%41 = call i64 @sqlite3_column_text(i32* %40, i32 0)
%42 = inttoptr i64 %41 to i8*
%43 = call i8* @strdup(i8* %42)
%44 = load i32, i32* %14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 %45
store i8* %43, i8** %46
%47 = load i32, i32* %14
%48 = add nsw i32 %47, 1
store i32 %48, i32* %14
br label %34
49: ; preds = %34
%50 = load i32*, i32** %8
%51 = call i32 @sqlite3_finalize(i32* %50)
%52 = load i32, i32* %12
%53 = load i32, i32* @SQLITE_DONE
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %62
55: ; preds = %49
%56 = load i8*, i8** %10
%57 = load i32*, i32** %5
%58 = call i8* @sqlite3_errmsg(i32* %57)
%59 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %56, i8* %58)
%60 = load i8*, i8** %10
%61 = call i32 @sqlite3_free(i8* %60)
store i32 -1, i32* %12
br label %99
62: ; preds = %49
%63 = load i8*, i8** %10
%64 = call i32 @sqlite3_free(i8* %63)
store i32 0, i32* %13
br label %65
65: ; preds = %95, %62
%66 = load i32, i32* %13
%67 = load i32, i32* %14
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %98
69: ; preds = %65
%70 = load i8*, i8** %6
%71 = load i32, i32* %13
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 %72
%74 = load i8*, i8** %73
%75 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %70, i8* %74)
store i8* %75, i8** %10
%76 = load i8*, i8** %10
%77 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %76)
%78 = load i32*, i32** %5
%79 = load i8*, i8** %10
%80 = call i32 @sqlite3_exec(i32* %78, i8* %79, i32* null, i32* null, i8** %9)
store i32 %80, i32* %12
%81 = load i32, i32* %12
%82 = load i32, i32* @SQLITE_OK
%83 = icmp ne i32 %81, %82
br i1 %83, label %84, label %92
84: ; preds = %69
%85 = load i8*, i8** %10
%86 = load i8*, i8** %9
%87 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %85, i8* %86)
%88 = load i8*, i8** %9
%89 = call i32 @sqlite3_free(i8* %88)
%90 = load i8*, i8** %10
%91 = call i32 @sqlite3_free(i8* %90)
store i32 -1, i32* %12
br label %99
92: ; preds = %69
%93 = load i8*, i8** %10
%94 = call i32 @sqlite3_free(i8* %93)
br label %95
95: ; preds = %92
%96 = load i32, i32* %13
%97 = add nsw i32 %96, 1
store i32 %97, i32* %13
br label %65
98: ; preds = %65
br label %99
99: ; preds = %98, %84, %55
store i32 0, i32* %13
br label %100
100: ; preds = %110, %99
%101 = load i32, i32* %13
%102 = load i32, i32* %14
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %113
104: ; preds = %100
%105 = load i32, i32* %13
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [256 x i8*], [256 x i8*]* %11, i64 0, i64 %106
%108 = load i8*, i8** %107
%109 = call i32 @free(i8* %108)
br label %110
110: ; preds = %104
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
store i32 %112, i32* %13
br label %100
113: ; preds = %100
%114 = load i32, i32* %12
store i32 %114, i32* %4
br label %115
115: ; preds = %113, %26
%116 = load i32, i32* %4
ret i32 %116
}

LLVM IR (-O2):
@.str = [80 x i8] c"SELECT name FROM sqlite_master WHERE type == lower('%s') AND name LIKE '%s_%%';\00"
@.str.1 = [20 x i8] c"Running query '%s'\0A\00"
@SQLITE_OK = global i32 0
@.str.2 = [38 x i8] c"Could not prepare statement '%s': %s\0A\00"
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@.str.3 = [25 x i8] c"Could not step '%s': %s\0A\00"
@.str.4 = [12 x i8] c"DROP %s %q;\00"
@.str.5 = [33 x i8] c"DB error while running '%s': %s\0A\00"
define i32 @db_drop_from_master(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [256 x i8*]
%7 = bitcast i32** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = bitcast [256 x i8*]* %6 to i8*
%10 = tail call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%11 = tail call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @sqlite3_prepare_v2(i32* %0, i8* %10, i32 -1, i32** %4, i32* null)
%13 = load i32, i32* @SQLITE_OK
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32*, i32** %4
%17 = call i32 @sqlite3_step(i32* %16)
%18 = load i32, i32* @SQLITE_ROW
%19 = icmp eq i32 %17, %18
br i1 %19, label %24, label %38
20: ; preds = %3
%21 = call i8* @sqlite3_errmsg(i32* %0)
%22 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %21)
%23 = call i32 @sqlite3_free(i8* %10)
br label %86
24: ; preds = %15, %24
%25 = phi i64 [ %31, %24 ], [ 0, %15 ]
%26 = load i32*, i32** %4
%27 = call i64 @sqlite3_column_text(i32* %26, i32 0)
%28 = inttoptr i64 %27 to i8*
%29 = call i8* @strdup(i8* %28)
%30 = getelementptr inbounds [256 x i8*], [256 x i8*]* %6, i64 0, i64 %25
store i8* %29, i8** %30
%31 = add nuw i64 %25, 1
%32 = load i32*, i32** %4
%33 = call i32 @sqlite3_step(i32* %32)
%34 = load i32, i32* @SQLITE_ROW
%35 = icmp eq i32 %33, %34
br i1 %35, label %24, label %36
36: ; preds = %24
%37 = trunc i64 %31 to i32
br label %38
38: ; preds = %36, %15
%39 = phi i32 [ 0, %15 ], [ %37, %36 ]
%40 = phi i32 [ %17, %15 ], [ %33, %36 ]
%41 = load i32*, i32** %4
%42 = call i32 @sqlite3_finalize(i32* %41)
%43 = load i32, i32* @SQLITE_DONE
%44 = icmp eq i32 %40, %43
br i1 %44, label %48, label %45
45: ; preds = %38
%46 = call i8* @sqlite3_errmsg(i32* %0)
%47 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %46)
br label %71
48: ; preds = %38
%49 = call i32 @sqlite3_free(i8* %10)
%50 = icmp eq i32 %39, 0
br i1 %50, label %86, label %51
51: ; preds = %48
%52 = zext i32 %39 to i64
br label %53
53: ; preds = %51, %67
%54 = phi i64 [ 0, %51 ], [ %69, %67 ]
%55 = getelementptr inbounds [256 x i8*], [256 x i8*]* %6, i64 0, i64 %54
%56 = load i8*, i8** %55
%57 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %56)
%58 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %57)
%59 = call i32 @sqlite3_exec(i32* %0, i8* %57, i32* null, i32* null, i8** %5)
%60 = load i32, i32* @SQLITE_OK
%61 = icmp eq i32 %59, %60
br i1 %61, label %67, label %62
62: ; preds = %53
%63 = load i8*, i8** %5
%64 = call i32 (i32, i32, i8*, i8*, ...) @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %57, i8* %63)
%65 = load i8*, i8** %5
%66 = call i32 @sqlite3_free(i8* %65)
br label %71
67: ; preds = %53
%68 = call i32 @sqlite3_free(i8* %57)
%69 = add nuw nsw i64 %54, 1
%70 = icmp eq i64 %69, %52
br i1 %70, label %74, label %53
71: ; preds = %45, %62
%72 = phi i8* [ %57, %62 ], [ %10, %45 ]
%73 = call i32 @sqlite3_free(i8* %72)
br label %74
74: ; preds = %67, %71
%75 = phi i32 [ -1, %71 ], [ %59, %67 ]
%76 = icmp eq i32 %39, 0
br i1 %76, label %86, label %77
77: ; preds = %74
%78 = zext i32 %39 to i64
br label %79
79: ; preds = %77, %79
%80 = phi i64 [ 0, %77 ], [ %84, %79 ]
%81 = getelementptr inbounds [256 x i8*], [256 x i8*]* %6, i64 0, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @free(i8* %82)
%84 = add nuw nsw i64 %80, 1
%85 = icmp eq i64 %84, %78
br i1 %85, label %86, label %79
86: ; preds = %79, %48, %74, %20
%87 = phi i32 [ -1, %20 ], [ %75, %74 ], [ %40, %48 ], [ %75, %79 ]
ret i32 %87
}