#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ SQLITE_DONE;
int SQLITE_OK;
int SQLITE_OPEN_CREATE;
int SQLITE_OPEN_READWRITE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int sqlite3_close_v2(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_initialize();
int sqlite3_open_v2(char *, int /*<<< orphan*/ **, int, int /*<<< orphan*/ *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_shutdown();
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  sqlite3 *db = NULL;
  sqlite3_stmt *stmt = NULL;
  int res = 0;
  int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
  char *sql_str = "CREATE TABLE addressBook(id INTEGER PRIMARY KEY,"
                  "fullname TEXT NOT NULL UNIQUE,"
                  "alias TEXT NOT NULL,"
                  "email TEXT NOT NULL UNIQUE);";
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <database name>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_initialize() != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to initialize the library.\n");
    exit(EXIT_FAILURE);
  }
  res = sqlite3_open_v2(argv[1], &db, flags, NULL);
  if (res != SQLITE_OK) {
    fprintf(stderr, "Err. can't create database: %s\n", sqlite3_errmsg(db));
    return 1;
  }
  if (sqlite3_prepare_v2(db, sql_str, -1, &stmt, NULL) != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to create Prepared Statement.\n");
    return 1;
  }
  if (sqlite3_step(stmt) == SQLITE_DONE)
    printf("... Statement successfully executed: %s\n", sql_str);
  if (sqlite3_finalize(stmt) == SQLITE_OK)
    puts("... Prepared Statemend destroyed.");
  if (sqlite3_close_v2(db) == SQLITE_OK)
    puts("... Closed database connection. ");
  sqlite3_shutdown();
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    0x2df3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x28(%rbp)
lea    0xdf7(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1243 <main+0x83>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   1030 <sqlite3_initialize@plt>
mov    0x2d8f(%rip),%rcx
cmp    (%rcx),%eax
je     127e <main+0xbe>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x28(%rbp),%edx
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <sqlite3_open_v2@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d3d(%rip),%rcx
cmp    (%rcx),%eax
je     12e0 <main+0x120>
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <sqlite3_errmsg@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b1 <main+0x1f1>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10b0 <sqlite3_prepare_v2@plt>
mov    0x2cde(%rip),%rcx
cmp    (%rcx),%eax
je     132d <main+0x16d>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b1 <main+0x1f1>
mov    -0x20(%rbp),%rdi
call   1080 <sqlite3_step@plt>
mov    0x2c83(%rip),%rcx
cmp    (%rcx),%rax
jne    1356 <main+0x196>
mov    -0x30(%rbp),%rsi
lea    0xdbc(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <sqlite3_finalize@plt>
mov    0x2c7a(%rip),%rcx
cmp    (%rcx),%eax
jne    137a <main+0x1ba>
lea    0xdc1(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close_v2@plt>
mov    0x2c56(%rip),%rcx
cmp    (%rcx),%eax
jne    139e <main+0x1de>
lea    0xdbf(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <sqlite3_shutdown@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    1309 <main+0x149>
mov    0x2dec(%rip),%rax
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
xor    %eax,%eax
call   1030 <sqlite3_initialize@plt>
mov    0x2ddb(%rip),%r14
cmp    (%r14),%eax
jne    1325 <main+0x165>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   10c0 <sqlite3_open_v2@plt>
cmp    (%r14),%eax
jne    12bd <main+0xfd>
mov    (%rsp),%rdi
lea    0xdce(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10b0 <sqlite3_prepare_v2@plt>
cmp    (%r14),%eax
jne    12e4 <main+0x124>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_step@plt>
mov    0x2d62(%rip),%rcx
cmp    (%rcx),%rax
jne    1276 <main+0xb6>
lea    0xea3(%rip),%rdi
lea    0xd8f(%rip),%rsi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   10a0 <sqlite3_finalize@plt>
cmp    (%r14),%eax
jne    1291 <main+0xd1>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rdi
call   10e0 <sqlite3_close_v2@plt>
cmp    (%r14),%eax
jne    12ab <main+0xeb>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <sqlite3_shutdown@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
jmp    1300 <main+0x140>
mov    0x2d04(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   1070 <sqlite3_errmsg@plt>
lea    0xdec(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12fb <main+0x13b>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd63(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    133c <main+0x17c>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@SQLITE_OPEN_CREATE = global i32 0
@SQLITE_OPEN_READWRITE = global i32 0
@.str = [127 x i8] c"CREATE TABLE addressBook(id INTEGER PRIMARY KEY,fullname TEXT NOT NULL UNIQUE,alias TEXT NOT NULL,email TEXT NOT NULL UNIQUE);\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Usage: %s <database name>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.2 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.3 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.4 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@SQLITE_DONE = global i64 0
@.str.5 = [41 x i8] c"... Statement successfully executed: %s\0A\00"
@.str.6 = [34 x i8] c"... Prepared Statemend destroyed.\00"
@.str.7 = [33 x i8] c"... Closed database connection. \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
%11 = load i32, i32* @SQLITE_OPEN_CREATE
%12 = load i32, i32* @SQLITE_OPEN_READWRITE
%13 = or i32 %11, %12
store i32 %13, i32* %9
store i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str, i64 0, i64 0), i8** %10
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %24
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = call i32 (...) @sqlite3_initialize()
%26 = load i32, i32* @SQLITE_OK
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %9
%38 = call i32 @sqlite3_open_v2(i8* %36, i32** %6, i32 %37, i32* null)
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = load i32, i32* @SQLITE_OK
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %47
42: ; preds = %33
%43 = load i32, i32* @stderr
%44 = load i32*, i32** %6
%45 = call i8* @sqlite3_errmsg(i32* %44)
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %45)
store i32 1, i32* %3
br label %81
47: ; preds = %33
%48 = load i32*, i32** %6
%49 = load i8*, i8** %10
%50 = call i32 @sqlite3_prepare_v2(i32* %48, i8* %49, i32 -1, i32** %7, i32* null)
%51 = load i32, i32* @SQLITE_OK
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %81
56: ; preds = %47
%57 = load i32*, i32** %7
%58 = call i64 @sqlite3_step(i32* %57)
%59 = load i64, i64* @SQLITE_DONE
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i8*, i8** %10
%63 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %61, %56
%65 = load i32*, i32** %7
%66 = call i32 @sqlite3_finalize(i32* %65)
%67 = load i32, i32* @SQLITE_OK
%68 = icmp eq i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %69, %64
%72 = load i32*, i32** %6
%73 = call i32 @sqlite3_close_v2(i32* %72)
%74 = load i32, i32* @SQLITE_OK
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %78
78: ; preds = %76, %71
%79 = call i32 (...) @sqlite3_shutdown()
%80 = load i32, i32* @EXIT_SUCCESS
store i32 %80, i32* %3
br label %81
81: ; preds = %78, %53, %42
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
@SQLITE_OPEN_CREATE = global i32 0
@SQLITE_OPEN_READWRITE = global i32 0
@.str = [127 x i8] c"CREATE TABLE addressBook(id INTEGER PRIMARY KEY,fullname TEXT NOT NULL UNIQUE,alias TEXT NOT NULL,email TEXT NOT NULL UNIQUE);\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Usage: %s <database name>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.2 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.3 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.4 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@SQLITE_DONE = global i64 0
@.str.5 = [41 x i8] c"... Statement successfully executed: %s\0A\00"
@.str.6 = [34 x i8] c"... Prepared Statemend destroyed.\00"
@.str.7 = [33 x i8] c"... Closed database connection. \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%6 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%7 = load i32, i32* @SQLITE_OPEN_CREATE
%8 = load i32, i32* @SQLITE_OPEN_READWRITE
%9 = or i32 %8, %7
%10 = icmp eq i32 %0, 2
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = tail call i32 (...) @sqlite3_initialize()
%19 = load i32, i32* @SQLITE_OK
%20 = icmp eq i32 %18, %19
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %17
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @sqlite3_open_v2(i8* %28, i32** %3, i32 %9, i32* null)
%30 = load i32, i32* @SQLITE_OK
%31 = icmp eq i32 %29, %30
br i1 %31, label %37, label %32
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = load i32*, i32** %3
%35 = call i8* @sqlite3_errmsg(i32* %34)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %69
37: ; preds = %26
%38 = load i32*, i32** %3
%39 = call i32 @sqlite3_prepare_v2(i32* %38, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%40 = load i32, i32* @SQLITE_OK
%41 = icmp eq i32 %39, %40
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %69
45: ; preds = %37
%46 = load i32*, i32** %4
%47 = call i64 @sqlite3_step(i32* %46)
%48 = load i64, i64* @SQLITE_DONE
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str, i64 0, i64 0))
br label %52
52: ; preds = %50, %45
%53 = load i32*, i32** %4
%54 = call i32 @sqlite3_finalize(i32* %53)
%55 = load i32, i32* @SQLITE_OK
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %59
59: ; preds = %57, %52
%60 = load i32*, i32** %3
%61 = call i32 @sqlite3_close_v2(i32* %60)
%62 = load i32, i32* @SQLITE_OK
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %64, %59
%67 = call i32 (...) @sqlite3_shutdown()
%68 = load i32, i32* @EXIT_SUCCESS
br label %69
69: ; preds = %66, %42, %32
%70 = phi i32 [ 1, %32 ], [ 1, %42 ], [ %68, %66 ]
ret i32 %70
}