#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 *);
scalar_t__ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
scalar_t__ sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ stderr;
void mbtiles_close(sqlite3 *outdb, char **argv) {
  char *err;
  if (sqlite3_exec(outdb, "ANALYZE;", NULL, NULL, &err) != SQLITE_OK) {
    fprintf(stderr, "%s: ANALYZE failed: %s\n", argv[0], err);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_close(outdb) != SQLITE_OK) {
    fprintf(stderr, "%s: could not close database: %s\n", argv[0],
            sqlite3_errmsg(outdb));
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<mbtiles_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
je     11b9 <mbtiles_close+0x69>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1060 <sqlite3_close@plt>
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%rax
je     1216 <mbtiles_close+0xc6>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <sqlite3_errmsg@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe1e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbtiles_close>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe9b(%rip),%rsi
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    0x2e6e(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    1197 <mbtiles_close+0x47>
mov    %rbx,%rdi
call   1060 <sqlite3_close@plt>
cmp    0x0(%rbp),%rax
jne    11b1 <mbtiles_close+0x61>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%rsp),%rcx
lea    0xe5a(%rip),%rsi
jmp    11d4 <mbtiles_close+0x84>
mov    0x2e20(%rip),%rax
mov    (%rax),%ebp
mov    (%r14),%r14
mov    %rbx,%rdi
call   1040 <sqlite3_errmsg@plt>
lea    0xe55(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"ANALYZE;\00"
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: ANALYZE failed: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [34 x i8] c"%s: could not close database: %s\0A\00"
define void @mbtiles_close(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i8*
store i32* %0, i32** %3
store i8** %1, i8*** %4
%6 = load i32*, i32** %3
%7 = call i64 @sqlite3_exec(i32* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* null, i32* null, i8** %5)
%8 = load i64, i64* @SQLITE_OK
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i8*, i8** %5
%16 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i32*, i32** %3
%21 = call i64 @sqlite3_close(i32* %20)
%22 = load i64, i64* @SQLITE_OK
%23 = icmp ne i64 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i32*, i32** %3
%30 = call i8* @sqlite3_errmsg(i32* %29)
%31 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"ANALYZE;\00"
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: ANALYZE failed: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [34 x i8] c"%s: could not close database: %s\0A\00"
define void @mbtiles_close(i32* %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @sqlite3_exec(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* null, i32* null, i8** %3)
%6 = load i64, i64* @SQLITE_OK
%7 = icmp eq i64 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = load i8*, i8** %3
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i64 @sqlite3_close(i32* %0)
%17 = load i64, i64* @SQLITE_OK
%18 = icmp eq i64 %16, %17
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = call i8* @sqlite3_errmsg(i32* %0)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %15
ret void
}