#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 beholddb_exec(int /*<<< orphan*/ *, char *);
int beholddb_create_tables(sqlite3 *db) {
  return beholddb_exec(
      db, "create table if not exists files "
          "("
          "id integer primary key,"
          "type integer not null,"
          "name text unique on conflict ignore"
          ");"
          "create table if not exists tags"
          "("
          "id integer primary key,"
          "name text unique on conflict ignore"
          ");"
          "create table if not exists files_tags"
          "("
          "id_file integer not null references files(id) on delete cascade,"
          "id_tag integer not null references tags(id),"
          "unique ( id_file, id_tag ) on conflict ignore"
          ");"
          "create table if not exists dirs_tags"
          "("
          "id_file integer not null references files(id) on delete cascade,"
          "id_tag integer not null references tags(id),"
          "unique ( id_file, id_tag ) on conflict ignore"
          ");"
          "create view if not exists strong_tags as "
          "select dt.*, 1 type from dirs_tags dt "
          "union "
          "select ft.*, 0 type from files_tags ft "
          "join files f on f.id = ft.id_file "
          "where not f.type;");
}


x86 assembly (clang, -O0):
<beholddb_create_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <beholddb_exec@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beholddb_create_tables>:
lea    0xee9(%rip),%rsi
jmp    1030 <beholddb_exec@plt>

LLVM IR (-O0):
@.str = [769 x i8] c"create table if not exists files (id integer primary key,type integer not null,name text unique on conflict ignore);create table if not exists tags(id integer primary key,name text unique on conflict ignore);create table if not exists files_tags(id_file integer not null references files(id) on delete cascade,id_tag integer not null references tags(id),unique ( id_file, id_tag ) on conflict ignore);create table if not exists dirs_tags(id_file integer not null references files(id) on delete cascade,id_tag integer not null references tags(id),unique ( id_file, id_tag ) on conflict ignore);create view if not exists strong_tags as select dt.*, 1 type from dirs_tags dt union select ft.*, 0 type from files_tags ft join files f on f.id = ft.id_file where not f.type;\00"
define i32 @beholddb_create_tables(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @beholddb_exec(i32* %3, i8* getelementptr inbounds ([769 x i8], [769 x i8]* @.str, i64 0, i64 0))
ret i32 %4
}

LLVM IR (-O2):
@.str = [769 x i8] c"create table if not exists files (id integer primary key,type integer not null,name text unique on conflict ignore);create table if not exists tags(id integer primary key,name text unique on conflict ignore);create table if not exists files_tags(id_file integer not null references files(id) on delete cascade,id_tag integer not null references tags(id),unique ( id_file, id_tag ) on conflict ignore);create table if not exists dirs_tags(id_file integer not null references files(id) on delete cascade,id_tag integer not null references tags(id),unique ( id_file, id_tag ) on conflict ignore);create view if not exists strong_tags as select dt.*, 1 type from dirs_tags dt union select ft.*, 0 type from files_tags ft join files f on f.id = ft.id_file where not f.type;\00"
define i32 @beholddb_create_tables(i32* %0) {
%2 = tail call i32 @beholddb_exec(i32* %0, i8* getelementptr inbounds ([769 x i8], [769 x i8]* @.str, i64 0, i64 0))
ret i32 %2
}