#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;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
scalar_t__ sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *, char **);
scalar_t__ sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
sqlite3 *mbtiles_open(char *dbname, char **argv) {
  sqlite3 *outdb;
  if (sqlite3_open(dbname, &outdb) != SQLITE_OK) {
    fprintf(stderr, "%s: %s: %s\n", argv[0], dbname, sqlite3_errmsg(outdb));
    exit(EXIT_FAILURE);
  }
  char *err = NULL;
  if (sqlite3_exec(outdb, "PRAGMA synchronous=0", NULL, NULL, &err) !=
      SQLITE_OK) {
    fprintf(stderr, "%s: async: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL, &err) !=
      SQLITE_OK) {
    fprintf(stderr, "%s: async: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb, "PRAGMA journal_mode=DELETE", NULL, NULL, &err) !=
      SQLITE_OK) {
    fprintf(stderr, "%s: async: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb, "CREATE TABLE metadata (name text, value text);",
                   NULL, NULL, &err) != SQLITE_OK) {
    fprintf(stderr, "%s: create metadata table: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb,
                   "CREATE TABLE tiles (zoom_level integer, tile_column "
                   "integer, tile_row integer, tile_data blob);",
                   NULL, NULL, &err) != SQLITE_OK) {
    fprintf(stderr, "%s: create tiles table: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb, "create unique index name on metadata (name);", NULL,
                   NULL, &err) != SQLITE_OK) {
    fprintf(stderr, "%s: index metadata: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_exec(outdb,
                   "create unique index tile_index on tiles (zoom_level, "
                   "tile_column, tile_row);",
                   NULL, NULL, &err) != SQLITE_OK) {
    fprintf(stderr, "%s: index tiles: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  return outdb;
}


x86 assembly (clang, -O0):
<mbtiles_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%rax
je     11cf <mbtiles_open+0x7f>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
je     1232 <mbtiles_open+0xe2>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2d94(%rip),%rcx
cmp    (%rcx),%rax
je     128d <mbtiles_open+0x13d>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xdb6(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2d39(%rip),%rcx
cmp    (%rcx),%rax
je     12e8 <mbtiles_open+0x198>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd76(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2cde(%rip),%rcx
cmp    (%rcx),%rax
je     1343 <mbtiles_open+0x1f3>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd69(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2c83(%rip),%rcx
cmp    (%rcx),%rax
je     139e <mbtiles_open+0x24e>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2c28(%rip),%rcx
cmp    (%rcx),%rax
je     13f9 <mbtiles_open+0x2a9>
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd74(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2bcd(%rip),%rcx
cmp    (%rcx),%rax
je     1454 <mbtiles_open+0x304>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
lea    0xd86(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbtiles_open>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <sqlite3_open@plt>
mov    0x2e79(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1299 <mbtiles_open+0x149>
movq   $0x0,(%rsp)
mov    0x8(%rsp),%rdi
lea    0xe7f(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    127d <mbtiles_open+0x12d>
mov    0x8(%rsp),%rdi
lea    0xe81(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    127d <mbtiles_open+0x12d>
mov    0x8(%rsp),%rdi
lea    0xe7d(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    127d <mbtiles_open+0x12d>
mov    0x8(%rsp),%rdi
lea    0xe76(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    12ca <mbtiles_open+0x17a>
mov    0x8(%rsp),%rdi
lea    0xea2(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    12e3 <mbtiles_open+0x193>
mov    0x8(%rsp),%rdi
lea    0xefc(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    12fc <mbtiles_open+0x1ac>
mov    0x8(%rsp),%rdi
lea    0xf1f(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
cmp    0x0(%rbp),%rax
jne    1315 <mbtiles_open+0x1c5>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    (%rsp),%rcx
lea    0xd8d(%rip),%rsi
jmp    132c <mbtiles_open+0x1dc>
mov    0x2d38(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%r14
mov    0x8(%rsp),%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xd4a(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1333 <mbtiles_open+0x1e3>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    (%rsp),%rcx
lea    0xdb7(%rip),%rsi
jmp    132c <mbtiles_open+0x1dc>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    (%rsp),%rcx
lea    0xe1d(%rip),%rsi
jmp    132c <mbtiles_open+0x1dc>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    (%rsp),%rcx
lea    0xe4d(%rip),%rsi
jmp    132c <mbtiles_open+0x1dc>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    (%rsp),%rcx
lea    0xe99(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str = [12 x i8] c"%s: %s: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [21 x i8] c"PRAGMA synchronous=0\00"
@.str.2 = [15 x i8] c"%s: async: %s\0A\00"
@.str.3 = [30 x i8] c"PRAGMA locking_mode=EXCLUSIVE\00"
@.str.4 = [27 x i8] c"PRAGMA journal_mode=DELETE\00"
@.str.5 = [47 x i8] c"CREATE TABLE metadata (name text, value text);\00"
@.str.6 = [31 x i8] c"%s: create metadata table: %s\0A\00"
@.str.7 = [96 x i8] c"CREATE TABLE tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob);\00"
@.str.8 = [28 x i8] c"%s: create tiles table: %s\0A\00"
@.str.9 = [45 x i8] c"create unique index name on metadata (name);\00"
@.str.10 = [24 x i8] c"%s: index metadata: %s\0A\00"
@.str.11 = [77 x i8] c"create unique index tile_index on tiles (zoom_level, tile_column, tile_row);\00"
@.str.12 = [21 x i8] c"%s: index tiles: %s\0A\00"
define i32* @mbtiles_open(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = load i8*, i8** %3
%8 = call i64 @sqlite3_open(i8* %7, i32** %5)
%9 = load i64, i64* @SQLITE_OK
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i8*, i8** %3
%17 = load i32*, i32** %5
%18 = call i8* @sqlite3_errmsg(i32* %17)
%19 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16, i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
store i8* null, i8** %6
%23 = load i32*, i32** %5
%24 = call i64 @sqlite3_exec(i32* %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* null, i32* null, i8** %6)
%25 = load i64, i64* @SQLITE_OK
%26 = icmp ne i64 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %4
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i8*, i8** %6
%33 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %22
%37 = load i32*, i32** %5
%38 = call i64 @sqlite3_exec(i32* %37, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32* null, i32* null, i8** %6)
%39 = load i64, i64* @SQLITE_OK
%40 = icmp ne i64 %38, %39
br i1 %40, label %41, label %50
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %4
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = load i8*, i8** %6
%47 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %36
%51 = load i32*, i32** %5
%52 = call i64 @sqlite3_exec(i32* %51, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null, i8** %6)
%53 = load i64, i64* @SQLITE_OK
%54 = icmp ne i64 %52, %53
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %4
%58 = getelementptr inbounds i8*, i8** %57, i64 0
%59 = load i8*, i8** %58
%60 = load i8*, i8** %6
%61 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %59, i8* %60)
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %50
%65 = load i32*, i32** %5
%66 = call i64 @sqlite3_exec(i32* %65, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32* null, i32* null, i8** %6)
%67 = load i64, i64* @SQLITE_OK
%68 = icmp ne i64 %66, %67
br i1 %68, label %69, label %78
69: ; preds = %64
%70 = load i32, i32* @stderr
%71 = load i8**, i8*** %4
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = load i8*, i8** %6
%75 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %73, i8* %74)
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %64
%79 = load i32*, i32** %5
%80 = call i64 @sqlite3_exec(i32* %79, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.7, i64 0, i64 0), i32* null, i32* null, i8** %6)
%81 = load i64, i64* @SQLITE_OK
%82 = icmp ne i64 %80, %81
br i1 %82, label %83, label %92
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = load i8**, i8*** %4
%86 = getelementptr inbounds i8*, i8** %85, i64 0
%87 = load i8*, i8** %86
%88 = load i8*, i8** %6
%89 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %87, i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %78
%93 = load i32*, i32** %5
%94 = call i64 @sqlite3_exec(i32* %93, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32* null, i32* null, i8** %6)
%95 = load i64, i64* @SQLITE_OK
%96 = icmp ne i64 %94, %95
br i1 %96, label %97, label %106
97: ; preds = %92
%98 = load i32, i32* @stderr
%99 = load i8**, i8*** %4
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = load i8*, i8** %6
%103 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %101, i8* %102)
%104 = load i32, i32* @EXIT_FAILURE
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %92
%107 = load i32*, i32** %5
%108 = call i64 @sqlite3_exec(i32* %107, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.11, i64 0, i64 0), i32* null, i32* null, i8** %6)
%109 = load i64, i64* @SQLITE_OK
%110 = icmp ne i64 %108, %109
br i1 %110, label %111, label %120
111: ; preds = %106
%112 = load i32, i32* @stderr
%113 = load i8**, i8*** %4
%114 = getelementptr inbounds i8*, i8** %113, i64 0
%115 = load i8*, i8** %114
%116 = load i8*, i8** %6
%117 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %115, i8* %116)
%118 = load i32, i32* @EXIT_FAILURE
%119 = call i32 @exit(i32 %118)
unreachable
120: ; preds = %106
%121 = load i32*, i32** %5
ret i32* %121
}

LLVM IR (-O2):
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str = [12 x i8] c"%s: %s: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [21 x i8] c"PRAGMA synchronous=0\00"
@.str.2 = [15 x i8] c"%s: async: %s\0A\00"
@.str.3 = [30 x i8] c"PRAGMA locking_mode=EXCLUSIVE\00"
@.str.4 = [27 x i8] c"PRAGMA journal_mode=DELETE\00"
@.str.5 = [47 x i8] c"CREATE TABLE metadata (name text, value text);\00"
@.str.6 = [31 x i8] c"%s: create metadata table: %s\0A\00"
@.str.7 = [96 x i8] c"CREATE TABLE tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob);\00"
@.str.8 = [28 x i8] c"%s: create tiles table: %s\0A\00"
@.str.9 = [45 x i8] c"create unique index name on metadata (name);\00"
@.str.10 = [24 x i8] c"%s: index metadata: %s\0A\00"
@.str.11 = [77 x i8] c"create unique index tile_index on tiles (zoom_level, tile_column, tile_row);\00"
@.str.12 = [21 x i8] c"%s: index tiles: %s\0A\00"
define i32* @mbtiles_open(i8* %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = bitcast i32** %3 to i8*
%6 = call i64 @sqlite3_open(i8* %0, i32** %3)
%7 = load i64, i64* @SQLITE_OK
%8 = icmp eq i64 %6, %7
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = load i32*, i32** %3
%13 = call i8* @sqlite3_errmsg(i32* %12)
%14 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %0, i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%19 = load i32*, i32** %3
%20 = call i64 @sqlite3_exec(i32* %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* null, i32* null, i8** %4)
%21 = load i64, i64* @SQLITE_OK
%22 = icmp eq i64 %20, %21
br i1 %22, label %30, label %23
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %1
%26 = load i8*, i8** %4
%27 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %17
%31 = load i32*, i32** %3
%32 = call i64 @sqlite3_exec(i32* %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32* null, i32* null, i8** %4)
%33 = load i64, i64* @SQLITE_OK
%34 = icmp eq i64 %32, %33
br i1 %34, label %42, label %35
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %1
%38 = load i8*, i8** %4
%39 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %30
%43 = load i32*, i32** %3
%44 = call i64 @sqlite3_exec(i32* %43, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null, i8** %4)
%45 = load i64, i64* @SQLITE_OK
%46 = icmp eq i64 %44, %45
br i1 %46, label %54, label %47
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %1
%50 = load i8*, i8** %4
%51 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %49, i8* %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %42
%55 = load i32*, i32** %3
%56 = call i64 @sqlite3_exec(i32* %55, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32* null, i32* null, i8** %4)
%57 = load i64, i64* @SQLITE_OK
%58 = icmp eq i64 %56, %57
br i1 %58, label %66, label %59
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = load i8*, i8** %1
%62 = load i8*, i8** %4
%63 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %61, i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %54
%67 = load i32*, i32** %3
%68 = call i64 @sqlite3_exec(i32* %67, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.7, i64 0, i64 0), i32* null, i32* null, i8** %4)
%69 = load i64, i64* @SQLITE_OK
%70 = icmp eq i64 %68, %69
br i1 %70, label %78, label %71
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %1
%74 = load i8*, i8** %4
%75 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8* %73, i8* %74)
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %66
%79 = load i32*, i32** %3
%80 = call i64 @sqlite3_exec(i32* %79, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32* null, i32* null, i8** %4)
%81 = load i64, i64* @SQLITE_OK
%82 = icmp eq i64 %80, %81
br i1 %82, label %90, label %83
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = load i8*, i8** %1
%86 = load i8*, i8** %4
%87 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %85, i8* %86)
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %78
%91 = load i32*, i32** %3
%92 = call i64 @sqlite3_exec(i32* %91, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.11, i64 0, i64 0), i32* null, i32* null, i8** %4)
%93 = load i64, i64* @SQLITE_OK
%94 = icmp eq i64 %92, %93
br i1 %94, label %102, label %95
95: ; preds = %90
%96 = load i32, i32* @stderr
%97 = load i8*, i8** %1
%98 = load i8*, i8** %4
%99 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %97, i8* %98)
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %90
%103 = load i32*, i32** %3
ret i32* %103
}