#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 */
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ sqlite3_exec(int /*<<< orphan*/ *, char const *,
                        int /*<<< orphan*/ *, int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ sqlite3_free(char *);
int /*<<< orphan*/ stderr;
void createTable(sqlite3 *database) {
  const char *query =
      "CREATE TABLE IF NOT EXISTS "
      "connections(address TEXT NOT NULL, time DATETIME NOT NULL);";
  char *error;
  if (sqlite3_exec(database, query, NULL, NULL, &error) != SQLITE_OK) {
    fprintf(stderr, "Failed to create database: %s.\n", error);
    sqlite3_free(error);
  }
}


x86 assembly (clang, -O0):
<createTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
je     1191 <createTable+0x61>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xed4(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <sqlite3_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTable>:
push   %rax
lea    0xec8(%rip),%rsi
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%rax
je     1172 <createTable+0x42>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xef3(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rsp),%rdi
call   1050 <sqlite3_free@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [87 x i8] c"CREATE TABLE IF NOT EXISTS connections(address TEXT NOT NULL, time DATETIME NOT NULL);\00"
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Failed to create database: %s.\0A\00"
define void @createTable(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
store i32* %0, i32** %2
store i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i32*, i32** %2
%6 = load i8*, i8** %3
%7 = call i64 @sqlite3_exec(i32* %5, i8* %6, i32* null, i32* null, i8** %4)
%8 = load i64, i64* @SQLITE_OK
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @sqlite3_free(i8* %14)
br label %16
16: ; preds = %10, %1
ret void
}

LLVM IR (-O2):
@.str = [87 x i8] c"CREATE TABLE IF NOT EXISTS connections(address TEXT NOT NULL, time DATETIME NOT NULL);\00"
@SQLITE_OK = global i64 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Failed to create database: %s.\0A\00"
define void @createTable(i32* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @sqlite3_exec(i32* %0, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i32* null, i32* null, i8** %2)
%5 = load i64, i64* @SQLITE_OK
%6 = icmp eq i64 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @sqlite3_free(i8* %11)
br label %13
13: ; preds = %7, %1
ret void
}