#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 PATH_MAX;
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int sqlite3_column_int(int /*<<< orphan*/ *, int);
scalar_t__ sqlite3_column_text(int /*<<< orphan*/ *, int);
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 *, int);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int db_upgrade_v16(sqlite3 *hdl) {
  sqlite3_stmt *stmt;
  char *query;
  char *uquery;
  char *errmsg;
  char *artist;
  char *album;
  char *title;
  int id;
  char *path;
  int type;
  char virtual_path[PATH_MAX];
  int ret;
  query = "SELECT id, album_artist, album, title, path FROM files;";
  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\n", sqlite3_errmsg(hdl));
    return -1;
  }
  while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
    id = sqlite3_column_int(stmt, 0);
    artist = (char *)sqlite3_column_text(stmt, 1);
    album = (char *)sqlite3_column_text(stmt, 2);
    title = (char *)sqlite3_column_text(stmt, 3);
    path = (char *)sqlite3_column_text(stmt, 4);
    if (strncmp(path, "http:", strlen("http:")) == 0) {
      snprintf(virtual_path, PATH_MAX, "/http:/%s", title);
    } else if (strncmp(path, "spotify:", strlen("spotify:")) == 0) {
      snprintf(virtual_path, PATH_MAX, "/spotify:/%s/%s/%s", artist, album,
               title);
    } else {
      snprintf(virtual_path, PATH_MAX, "/file:%s", path);
    }
    uquery =
        sqlite3_mprintf("UPDATE files SET virtual_path = '%q' WHERE id = %d;",
                        virtual_path, id);
    ret = sqlite3_exec(hdl, uquery, NULL, NULL, &errmsg);
    if (ret != SQLITE_OK) {
      DPRINTF(1, 2, "Error updating files: %s\n", errmsg);
    }
    sqlite3_free(uquery);
    sqlite3_free(errmsg);
  }
  sqlite3_finalize(stmt);
  query = "SELECT id, title, path, type FROM playlists;";
  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\n", sqlite3_errmsg(hdl));
    return -1;
  }
  while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
    id = sqlite3_column_int(stmt, 0);
    title = (char *)sqlite3_column_text(stmt, 1);
    path = (char *)sqlite3_column_text(stmt, 2);
    type = sqlite3_column_int(stmt, 3);
    if (type == 0) {
      if (strncmp(path, "spotify:", strlen("spotify:")) == 0)
        snprintf(virtual_path, PATH_MAX, "/spotify:/%s", title);
      else
        snprintf(virtual_path, PATH_MAX, "/file:%s", path);
      uquery = sqlite3_mprintf(
          "UPDATE playlists SET virtual_path = '%q' WHERE id = %d;",
          virtual_path, id);
      ret = sqlite3_exec(hdl, uquery, NULL, NULL, &errmsg);
      if (ret != SQLITE_OK)
        DPRINTF(1, 2, "Error updating playlists: %s\n", errmsg);
      sqlite3_free(uquery);
      sqlite3_free(errmsg);
    }
  }
  sqlite3_finalize(stmt);
  return 0;
}


x86 assembly (clang, -O0):
<db_upgrade_v16>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
lea    0xdee(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xe0d(%rip),%rdx
call   10f0 <DPRINTF@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10c0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x2d88(%rip),%rcx
cmp    (%rcx),%eax
je     1295 <db_upgrade_v16+0xc5>
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    %rax,%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xdcf(%rip),%rdx
call   10f0 <DPRINTF@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    1665 <db_upgrade_v16+0x495>
jmp    129a <db_upgrade_v16+0xca>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_step@plt>
mov    %eax,-0x74(%rbp)
mov    0x2d23(%rip),%rcx
cmp    (%rcx),%eax
jne    1460 <db_upgrade_v16+0x290>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    0xd50(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%edx
lea    0xd3b(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1365 <db_upgrade_v16+0x195>
mov    -0x80(%rbp),%rdi
mov    0x2ca4(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rcx
lea    0xd1a(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    13eb <db_upgrade_v16+0x21b>
mov    -0x58(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    0xd06(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%edx
lea    0xcf1(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13c7 <db_upgrade_v16+0x1f7>
mov    -0x80(%rbp),%rdi
mov    0x2c4a(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
lea    0xccb(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    13e6 <db_upgrade_v16+0x216>
mov    -0x80(%rbp),%rdi
mov    0x2c1e(%rip),%rax
mov    (%rax),%esi
mov    -0x58(%rbp),%rcx
lea    0xcba(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    13eb <db_upgrade_v16+0x21b>
mov    -0x80(%rbp),%rsi
mov    -0x4c(%rbp),%edx
lea    0xca9(%rip),%rdi
call   10e0 <sqlite3_mprintf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <sqlite3_exec@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x2bb9(%rip),%rcx
cmp    (%rcx),%eax
je     1449 <db_upgrade_v16+0x279>
mov    -0x30(%rbp),%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xc92(%rip),%rdx
call   10f0 <DPRINTF@plt>
mov    -0x28(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
jmp    129a <db_upgrade_v16+0xca>
mov    -0x18(%rbp),%rdi
call   10b0 <sqlite3_finalize@plt>
lea    0xc80(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xbaf(%rip),%rdx
call   10f0 <DPRINTF@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10c0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x2b2a(%rip),%rcx
cmp    (%rcx),%eax
je     14f3 <db_upgrade_v16+0x323>
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    %rax,%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xb71(%rip),%rdx
call   10f0 <DPRINTF@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    1665 <db_upgrade_v16+0x495>
jmp    14f8 <db_upgrade_v16+0x328>
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_step@plt>
mov    %eax,-0x74(%rbp)
mov    0x2ac5(%rip),%rcx
cmp    (%rcx),%eax
jne    164e <db_upgrade_v16+0x47e>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jne    1649 <db_upgrade_v16+0x479>
mov    -0x58(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    0xb0b(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%edx
lea    0xaf6(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    15ba <db_upgrade_v16+0x3ea>
mov    -0x80(%rbp),%rdi
mov    0x2a4f(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rcx
lea    0xb6f(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    15d9 <db_upgrade_v16+0x409>
mov    -0x80(%rbp),%rdi
mov    0x2a2b(%rip),%rax
mov    (%rax),%esi
mov    -0x58(%rbp),%rcx
lea    0xac7(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x80(%rbp),%rsi
mov    -0x4c(%rbp),%edx
lea    0xb43(%rip),%rdi
call   10e0 <sqlite3_mprintf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <sqlite3_exec@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    0x29cb(%rip),%rcx
cmp    (%rcx),%eax
je     1637 <db_upgrade_v16+0x467>
mov    -0x30(%rbp),%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xb30(%rip),%rdx
call   10f0 <DPRINTF@plt>
mov    -0x28(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
jmp    14f8 <db_upgrade_v16+0x328>
mov    -0x18(%rbp),%rdi
call   10b0 <sqlite3_finalize@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_upgrade_v16>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r13
mov    %rsp,%r14
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe30(%rip),%rdx
lea    0xdf1(%rip),%r12
mov    $0x4,%edi
mov    $0x2,%esi
mov    %r12,%rcx
call   10f0 <DPRINTF@plt>
mov    $0xffffffff,%r15d
lea    -0x30(%rbp),%rcx
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10c0 <sqlite3_prepare_v2@plt>
mov    0x2d9b(%rip),%r12
cmp    (%r12),%eax
jne    13e8 <db_upgrade_v16+0x218>
mov    %rbx,-0x38(%rbp)
mov    %r14,-0x48(%rbp)
jmp    1271 <db_upgrade_v16+0xa1>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x40(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x30(%rbp),%rdi
call   1090 <sqlite3_step@plt>
mov    0x2d4f(%rip),%rcx
cmp    (%rcx),%eax
jne    140e <db_upgrade_v16+0x23e>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,%r12d
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,%r15
lea    0xd89(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1340 <db_upgrade_v16+0x170>
lea    0xd78(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    0x2ccf(%rip),%rcx
mov    (%rcx),%esi
test   %rax,%rax
je     1370 <db_upgrade_v16+0x1a0>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
lea    0xd63(%rip),%rdx
mov    %r15,%rcx
jmp    135a <db_upgrade_v16+0x18a>
nopl   0x0(%rax,%rax,1)
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
lea    0xd1c(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    1390 <db_upgrade_v16+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
lea    0xd08(%rip),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    %r14,%r9
xor    %eax,%eax
call   1060 <snprintf@plt>
lea    0xd0b(%rip),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   10e0 <sqlite3_mprintf@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    -0x40(%rbp),%r8
call   1040 <sqlite3_exec@plt>
mov    0x2c21(%rip),%r12
cmp    (%r12),%eax
je     1260 <db_upgrade_v16+0x90>
mov    -0x40(%rbp),%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xcf8(%rip),%rdx
call   10f0 <DPRINTF@plt>
jmp    1260 <db_upgrade_v16+0x90>
mov    %r13,%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xc55(%rip),%rdx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rax,%rcx
call   10f0 <DPRINTF@plt>
jmp    15b9 <db_upgrade_v16+0x3e9>
mov    -0x30(%rbp),%rdi
call   10b0 <sqlite3_finalize@plt>
lea    0xc1a(%rip),%rdx
lea    0xccb(%rip),%rbx
mov    $0x4,%edi
mov    $0x2,%esi
mov    %rbx,%rcx
call   10f0 <DPRINTF@plt>
mov    $0xffffffff,%r15d
lea    -0x30(%rbp),%rcx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10c0 <sqlite3_prepare_v2@plt>
cmp    (%r12),%eax
jne    1586 <db_upgrade_v16+0x3b6>
mov    %r13,%r12
jmp    1481 <db_upgrade_v16+0x2b1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x40(%rbp),%rdi
call   10d0 <sqlite3_free@plt>
mov    -0x30(%rbp),%rdi
call   1090 <sqlite3_step@plt>
mov    0x2b3f(%rip),%rcx
cmp    (%rcx),%eax
jne    15a9 <db_upgrade_v16+0x3d9>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,%r13d
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    -0x30(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <sqlite3_column_text@plt>
mov    %rax,%rbx
mov    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1070 <sqlite3_column_int@plt>
test   %eax,%eax
jne    1481 <db_upgrade_v16+0x2b1>
lea    0xb9b(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    0x2af2(%rip),%rcx
mov    (%rcx),%esi
test   %rax,%rax
je     1518 <db_upgrade_v16+0x348>
mov    -0x38(%rbp),%r15
mov    %r15,%rdi
lea    0xb86(%rip),%rdx
mov    %rbx,%rcx
jmp    1529 <db_upgrade_v16+0x359>
mov    -0x38(%rbp),%r15
mov    %r15,%rdi
lea    0xbf7(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
lea    0xbf3(%rip),%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   10e0 <sqlite3_mprintf@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    -0x40(%rbp),%r8
call   1040 <sqlite3_exec@plt>
mov    0x2a81(%rip),%rcx
cmp    (%rcx),%eax
je     1470 <db_upgrade_v16+0x2a0>
mov    -0x40(%rbp),%rcx
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xbe6(%rip),%rdx
call   10f0 <DPRINTF@plt>
jmp    1470 <db_upgrade_v16+0x2a0>
mov    %r13,%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xab7(%rip),%rdx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rax,%rcx
call   10f0 <DPRINTF@plt>
jmp    15b5 <db_upgrade_v16+0x3e5>
mov    -0x30(%rbp),%rdi
call   10b0 <sqlite3_finalize@plt>
xor    %r15d,%r15d
mov    -0x48(%rbp),%r14
mov    %r14,%rsp
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [56 x i8] c"SELECT id, album_artist, album, title, path FROM files;\00"
@.str.1 = [20 x i8] c"Running query '%s'\0A\00"
@SQLITE_OK = global i32 0
@.str.2 = [33 x i8] c"Could not prepare statement: %s\0A\00"
@SQLITE_ROW = global i32 0
@.str.3 = [6 x i8] c"http:\00"
@.str.4 = [10 x i8] c"/http:/%s\00"
@.str.5 = [9 x i8] c"spotify:\00"
@.str.6 = [19 x i8] c"/spotify:/%s/%s/%s\00"
@.str.7 = [9 x i8] c"/file:%s\00"
@.str.8 = [52 x i8] c"UPDATE files SET virtual_path = '%q' WHERE id = %d;\00"
@.str.9 = [26 x i8] c"Error updating files: %s\0A\00"
@.str.10 = [45 x i8] c"SELECT id, title, path, type FROM playlists;\00"
@.str.11 = [13 x i8] c"/spotify:/%s\00"
@.str.12 = [56 x i8] c"UPDATE playlists SET virtual_path = '%q' WHERE id = %d;\00"
@.str.13 = [30 x i8] c"Error updating playlists: %s\0A\00"
define i32 @db_upgrade_v16(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i32* %0, i32** %3
%18 = load i32, i32* @PATH_MAX
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %14
%21 = alloca i8, i64 %19
store i64 %19, i64* %15
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32*, i32** %3
%25 = load i8*, i8** %5
%26 = call i32 @sqlite3_prepare_v2(i32* %24, i8* %25, i32 -1, i32** %4, i32* null)
store i32 %26, i32* %16
%27 = load i32, i32* %16
%28 = load i32, i32* @SQLITE_OK
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %1
%31 = load i32*, i32** %3
%32 = call i8* @sqlite3_errmsg(i32* %31)
%33 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %32)
store i32 -1, i32* %2
store i32 1, i32* %17
br label %164
34: ; preds = %1
br label %35
35: ; preds = %91, %34
%36 = load i32*, i32** %4
%37 = call i32 @sqlite3_step(i32* %36)
store i32 %37, i32* %16
%38 = load i32, i32* @SQLITE_ROW
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %96
40: ; preds = %35
%41 = load i32*, i32** %4
%42 = call i32 @sqlite3_column_int(i32* %41, i32 0)
store i32 %42, i32* %11
%43 = load i32*, i32** %4
%44 = call i64 @sqlite3_column_text(i32* %43, i32 1)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %8
%46 = load i32*, i32** %4
%47 = call i64 @sqlite3_column_text(i32* %46, i32 2)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %9
%49 = load i32*, i32** %4
%50 = call i64 @sqlite3_column_text(i32* %49, i32 3)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %10
%52 = load i32*, i32** %4
%53 = call i64 @sqlite3_column_text(i32* %52, i32 4)
%54 = inttoptr i64 %53 to i8*
store i8* %54, i8** %12
%55 = load i8*, i8** %12
%56 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%57 = call i64 @strncmp(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %40
%60 = load i32, i32* @PATH_MAX
%61 = load i8*, i8** %10
%62 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %61)
br label %79
63: ; preds = %40
%64 = load i8*, i8** %12
%65 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%66 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %63
%69 = load i32, i32* @PATH_MAX
%70 = load i8*, i8** %8
%71 = load i8*, i8** %9
%72 = load i8*, i8** %10
%73 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %69, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %70, i8* %71, i8* %72)
br label %78
74: ; preds = %63
%75 = load i32, i32* @PATH_MAX
%76 = load i8*, i8** %12
%77 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %75, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %74, %68
br label %79
79: ; preds = %78, %59
%80 = load i32, i32* %11
%81 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* %21, i32 %80)
store i8* %81, i8** %6
%82 = load i32*, i32** %3
%83 = load i8*, i8** %6
%84 = call i32 @sqlite3_exec(i32* %82, i8* %83, i32* null, i32* null, i8** %7)
store i32 %84, i32* %16
%85 = load i32, i32* %16
%86 = load i32, i32* @SQLITE_OK
%87 = icmp ne i32 %85, %86
br i1 %87, label %88, label %91
88: ; preds = %79
%89 = load i8*, i8** %7
%90 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %89)
br label %91
91: ; preds = %88, %79
%92 = load i8*, i8** %6
%93 = call i32 @sqlite3_free(i8* %92)
%94 = load i8*, i8** %7
%95 = call i32 @sqlite3_free(i8* %94)
br label %35
96: ; preds = %35
%97 = load i32*, i32** %4
%98 = call i32 @sqlite3_finalize(i32* %97)
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i8** %5
%99 = load i8*, i8** %5
%100 = call i32 @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %99)
%101 = load i32*, i32** %3
%102 = load i8*, i8** %5
%103 = call i32 @sqlite3_prepare_v2(i32* %101, i8* %102, i32 -1, i32** %4, i32* null)
store i32 %103, i32* %16
%104 = load i32, i32* %16
%105 = load i32, i32* @SQLITE_OK
%106 = icmp ne i32 %104, %105
br i1 %106, label %107, label %111
107: ; preds = %96
%108 = load i32*, i32** %3
%109 = call i8* @sqlite3_errmsg(i32* %108)
%110 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %109)
store i32 -1, i32* %2
store i32 1, i32* %17
br label %164
111: ; preds = %96
br label %112
112: ; preds = %160, %111
%113 = load i32*, i32** %4
%114 = call i32 @sqlite3_step(i32* %113)
store i32 %114, i32* %16
%115 = load i32, i32* @SQLITE_ROW
%116 = icmp eq i32 %114, %115
br i1 %116, label %117, label %161
117: ; preds = %112
%118 = load i32*, i32** %4
%119 = call i32 @sqlite3_column_int(i32* %118, i32 0)
store i32 %119, i32* %11
%120 = load i32*, i32** %4
%121 = call i64 @sqlite3_column_text(i32* %120, i32 1)
%122 = inttoptr i64 %121 to i8*
store i8* %122, i8** %10
%123 = load i32*, i32** %4
%124 = call i64 @sqlite3_column_text(i32* %123, i32 2)
%125 = inttoptr i64 %124 to i8*
store i8* %125, i8** %12
%126 = load i32*, i32** %4
%127 = call i32 @sqlite3_column_int(i32* %126, i32 3)
store i32 %127, i32* %13
%128 = load i32, i32* %13
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %160
130: ; preds = %117
%131 = load i8*, i8** %12
%132 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%133 = call i64 @strncmp(i8* %131, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %132)
%134 = icmp eq i64 %133, 0
br i1 %134, label %135, label %139
135: ; preds = %130
%136 = load i32, i32* @PATH_MAX
%137 = load i8*, i8** %10
%138 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %136, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %137)
br label %143
139: ; preds = %130
%140 = load i32, i32* @PATH_MAX
%141 = load i8*, i8** %12
%142 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 %140, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %141)
br label %143
143: ; preds = %139, %135
%144 = load i32, i32* %11
%145 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0), i8* %21, i32 %144)
store i8* %145, i8** %6
%146 = load i32*, i32** %3
%147 = load i8*, i8** %6
%148 = call i32 @sqlite3_exec(i32* %146, i8* %147, i32* null, i32* null, i8** %7)
store i32 %148, i32* %16
%149 = load i32, i32* %16
%150 = load i32, i32* @SQLITE_OK
%151 = icmp ne i32 %149, %150
br i1 %151, label %152, label %155
152: ; preds = %143
%153 = load i8*, i8** %7
%154 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* %153)
br label %155
155: ; preds = %152, %143
%156 = load i8*, i8** %6
%157 = call i32 @sqlite3_free(i8* %156)
%158 = load i8*, i8** %7
%159 = call i32 @sqlite3_free(i8* %158)
br label %160
160: ; preds = %155, %117
br label %112
161: ; preds = %112
%162 = load i32*, i32** %4
%163 = call i32 @sqlite3_finalize(i32* %162)
store i32 0, i32* %2
store i32 1, i32* %17
br label %164
164: ; preds = %161, %107, %30
%165 = load i8*, i8** %14
%166 = load i32, i32* %2
ret i32 %166
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [56 x i8] c"SELECT id, album_artist, album, title, path FROM files;\00"
@.str.1 = [20 x i8] c"Running query '%s'\0A\00"
@SQLITE_OK = global i32 0
@.str.2 = [33 x i8] c"Could not prepare statement: %s\0A\00"
@SQLITE_ROW = global i32 0
@.str.3 = [6 x i8] c"http:\00"
@.str.4 = [10 x i8] c"/http:/%s\00"
@.str.5 = [9 x i8] c"spotify:\00"
@.str.6 = [19 x i8] c"/spotify:/%s/%s/%s\00"
@.str.7 = [9 x i8] c"/file:%s\00"
@.str.8 = [52 x i8] c"UPDATE files SET virtual_path = '%q' WHERE id = %d;\00"
@.str.9 = [26 x i8] c"Error updating files: %s\0A\00"
@.str.10 = [45 x i8] c"SELECT id, title, path, type FROM playlists;\00"
@.str.11 = [13 x i8] c"/spotify:/%s\00"
@.str.12 = [56 x i8] c"UPDATE playlists SET virtual_path = '%q' WHERE id = %d;\00"
@.str.13 = [30 x i8] c"Error updating playlists: %s\0A\00"
define i32 @db_upgrade_v16(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = bitcast i32** %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = load i32, i32* @PATH_MAX
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = tail call i32 @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 -1, i32** %2, i32* null)
%12 = load i32, i32* @SQLITE_OK
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i32*, i32** %2
%16 = call i32 @sqlite3_step(i32* %15)
%17 = load i32, i32* @SQLITE_ROW
%18 = icmp eq i32 %16, %17
br i1 %18, label %22, label %68
19: ; preds = %1
%20 = call i8* @sqlite3_errmsg(i32* %0)
%21 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %124
22: ; preds = %14, %60
%23 = load i32*, i32** %2
%24 = call i32 @sqlite3_column_int(i32* %23, i32 0)
%25 = load i32*, i32** %2
%26 = call i64 @sqlite3_column_text(i32* %25, i32 1)
%27 = inttoptr i64 %26 to i8*
%28 = load i32*, i32** %2
%29 = call i64 @sqlite3_column_text(i32* %28, i32 2)
%30 = inttoptr i64 %29 to i8*
%31 = load i32*, i32** %2
%32 = call i64 @sqlite3_column_text(i32* %31, i32 3)
%33 = inttoptr i64 %32 to i8*
%34 = load i32*, i32** %2
%35 = call i64 @sqlite3_column_text(i32* %34, i32 4)
%36 = inttoptr i64 %35 to i8*
%37 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%38 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %22
%41 = load i32, i32* @PATH_MAX
%42 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %52
43: ; preds = %22
%44 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%45 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = icmp eq i64 %45, 0
%47 = load i32, i32* @PATH_MAX
br i1 %46, label %48, label %50
48: ; preds = %43
%49 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %27, i8* %30, i8* %33)
br label %52
50: ; preds = %43
%51 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %36)
br label %52
52: ; preds = %48, %50, %40
%53 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %24)
%54 = call i32 @sqlite3_exec(i32* %0, i8* %53, i32* null, i32* null, i8** %3)
%55 = load i32, i32* @SQLITE_OK
%56 = icmp eq i32 %54, %55
br i1 %56, label %60, label %57
57: ; preds = %52
%58 = load i8*, i8** %3
%59 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %57, %52
%61 = call i32 @sqlite3_free(i8* %53)
%62 = load i8*, i8** %3
%63 = call i32 @sqlite3_free(i8* %62)
%64 = load i32*, i32** %2
%65 = call i32 @sqlite3_step(i32* %64)
%66 = load i32, i32* @SQLITE_ROW
%67 = icmp eq i32 %65, %66
br i1 %67, label %22, label %68
68: ; preds = %60, %14
%69 = load i32*, i32** %2
%70 = call i32 @sqlite3_finalize(i32* %69)
%71 = call i32 @DPRINTF(i32 4, i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%72 = call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 -1, i32** %2, i32* null)
%73 = load i32, i32* @SQLITE_OK
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %80
75: ; preds = %68
%76 = load i32*, i32** %2
%77 = call i32 @sqlite3_step(i32* %76)
%78 = load i32, i32* @SQLITE_ROW
%79 = icmp eq i32 %77, %78
br i1 %79, label %83, label %121
80: ; preds = %68
%81 = call i8* @sqlite3_errmsg(i32* %0)
%82 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %81)
br label %124
83: ; preds = %75, %116
%84 = load i32*, i32** %2
%85 = call i32 @sqlite3_column_int(i32* %84, i32 0)
%86 = load i32*, i32** %2
%87 = call i64 @sqlite3_column_text(i32* %86, i32 1)
%88 = inttoptr i64 %87 to i8*
%89 = load i32*, i32** %2
%90 = call i64 @sqlite3_column_text(i32* %89, i32 2)
%91 = inttoptr i64 %90 to i8*
%92 = load i32*, i32** %2
%93 = call i32 @sqlite3_column_int(i32* %92, i32 3)
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %116
95: ; preds = %83
%96 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%97 = call i64 @strncmp(i8* %91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %96)
%98 = icmp eq i64 %97, 0
%99 = load i32, i32* @PATH_MAX
br i1 %98, label %100, label %102
100: ; preds = %95
%101 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 %99, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8* %88)
br label %104
102: ; preds = %95
%103 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 %99, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %91)
br label %104
104: ; preds = %102, %100
%105 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0), i8* %9, i32 %85)
%106 = call i32 @sqlite3_exec(i32* %0, i8* %105, i32* null, i32* null, i8** %3)
%107 = load i32, i32* @SQLITE_OK
%108 = icmp eq i32 %106, %107
br i1 %108, label %112, label %109
109: ; preds = %104
%110 = load i8*, i8** %3
%111 = call i32 @DPRINTF(i32 1, i32 2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %109, %104
%113 = call i32 @sqlite3_free(i8* %105)
%114 = load i8*, i8** %3
%115 = call i32 @sqlite3_free(i8* %114)
br label %116
116: ; preds = %112, %83
%117 = load i32*, i32** %2
%118 = call i32 @sqlite3_step(i32* %117)
%119 = load i32, i32* @SQLITE_ROW
%120 = icmp eq i32 %118, %119
br i1 %120, label %83, label %121
121: ; preds = %116, %75
%122 = load i32*, i32** %2
%123 = call i32 @sqlite3_finalize(i32* %122)
br label %124
124: ; preds = %121, %80, %19
%125 = phi i32 [ -1, %19 ], [ -1, %80 ], [ 0, %121 ]
ret i32 %125
}