#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 SQLITE_OK;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/, char **);
int /*<<< orphan*/ sqlite3_free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void create_url_tables(sqlite3 *database) {
  char *table_start = "CREATE TABLE url_list("
                      "  urlid   INTEGER PRIMARY KEY AUTOINCREMENT,"
                      "  url     varchar(1024) NOT NULL UNIQUE, "
                      "  depth   INTEGER,"
                      "  position INTEGER,"
                      "  thread INTEGER"
                      ");"
                      "CREATE TABLE page ("
                      "  pageid  INTEGER primary key autoincrement,"
                      "  source  TEXT,"
                      "  urlid   INTEGER,"
                      "  FOREIGN KEY(urlid) REFERENCES url_list(urlid)"
                      ");";
  int rc = 0;
  char *ErrMsg = 0;
  rc = sqlite3_exec(database, table_start, 0, 0, &ErrMsg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "SQL error : %s\n", ErrMsg);
    sqlite3_free(ErrMsg);
    exit(0);
  } else {
    fprintf(stdout, "Table created successfully\n");
  }
}


x86 assembly (clang, -O0):
<create_url_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x20(%rbp),%r8
mov    %ecx,%edx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
je     11bb <create_url_tables+0x7b>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xf90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <sqlite3_free@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xf79(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_url_tables>:
push   %rax
movq   $0x0,(%rsp)
lea    0xeb0(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
jne    1180 <create_url_tables+0x40>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xfcd(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
pop    %rax
ret
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xfa0(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rsp),%rdi
call   1050 <sqlite3_free@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [308 x i8] c"CREATE TABLE url_list( urlid INTEGER PRIMARY KEY AUTOINCREMENT, url varchar(1024) NOT NULL UNIQUE, depth INTEGER, position INTEGER, thread INTEGER);CREATE TABLE page ( pageid INTEGER primary key autoincrement, source TEXT, urlid INTEGER, FOREIGN KEY(urlid) REFERENCES url_list(urlid));\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"SQL error : %s\0A\00"
@stdout = global i32 0
@.str.2 = [28 x i8] c"Table created successfully\0A\00"
define void @create_url_tables(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i32* %0, i32** %2
store i8* getelementptr inbounds ([308 x i8], [308 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 0, i32* %4
store i8* null, i8** %5
%6 = load i32*, i32** %2
%7 = load i8*, i8** %3
%8 = call i32 @sqlite3_exec(i32* %6, i8* %7, i32 0, i32 0, i8** %5)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = load i32, i32* @SQLITE_OK
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %5
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 @sqlite3_free(i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %1
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [308 x i8] c"CREATE TABLE url_list( urlid INTEGER PRIMARY KEY AUTOINCREMENT, url varchar(1024) NOT NULL UNIQUE, depth INTEGER, position INTEGER, thread INTEGER);CREATE TABLE page ( pageid INTEGER primary key autoincrement, source TEXT, urlid INTEGER, FOREIGN KEY(urlid) REFERENCES url_list(urlid));\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"SQL error : %s\0A\00"
@stdout = global i32 0
@.str.2 = [28 x i8] c"Table created successfully\0A\00"
define void @create_url_tables(i32* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i32 @sqlite3_exec(i32* %0, i8* getelementptr inbounds ([308 x i8], [308 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i8** %2)
%5 = load i32, i32* @SQLITE_OK
%6 = icmp eq i32 %4, %5
br i1 %6, label %14, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @sqlite3_free(i8* %11)
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
ret void
}