#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;
int SQLITE_OK;
int SQLITE_OPEN_READONLY;
scalar_t__ SQLITE_ROW;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_close_v2(int /*<<< orphan*/ *);
int sqlite3_column_bytes(int /*<<< orphan*/ *, int);
int sqlite3_column_count(int /*<<< orphan*/ *);
int sqlite3_column_int(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *sqlite3_column_name(int /*<<< orphan*/ *, int);
scalar_t__ sqlite3_column_text(int /*<<< orphan*/ *, int);
scalar_t__ sqlite3_complete(char const *);
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 const *, int,
                       int /*<<< orphan*/ **, char const **);
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_READONLY;
  const char *colnms[4] = {NULL};
  const char *tail = NULL;
  const char *sql_str = "SELECT * FROM addressbook ORDER by id;"
                        "SELECT * FROM addressbook ORDER by fullname;"
                        "SELECT * FROM addressbook ORDER by alias;"
                        "SELECT * FROM addressbook ORDER by email;";
  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 open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(EXIT_FAILURE);
  }
  while (sqlite3_complete(sql_str)) {
    if (sqlite3_prepare_v2(db, sql_str, -1, &stmt, &tail) != SQLITE_OK) {
      fprintf(stderr, "Err. Unable to create Prepared Statement.\n");
      exit(EXIT_FAILURE);
    }
    for (int i = 0; i < sqlite3_column_count(stmt); i++)
      colnms[i] = sqlite3_column_name(stmt, i);
    printf("%2s %10s %8s %14s\n", colnms[0], colnms[1], colnms[2], colnms[3]);
    while (sqlite3_step(stmt) == SQLITE_ROW) {
      printf("%2d %10s %5s %20s (byte: %3d)\n", sqlite3_column_int(stmt, 0),
             (const char *)sqlite3_column_text(stmt, 1),
             (const char *)sqlite3_column_text(stmt, 2),
             (const char *)sqlite3_column_text(stmt, 3),
             sqlite3_column_bytes(stmt, 3));
    }
    puts("\n");
    sql_str = tail;
  }
  if (sqlite3_finalize(stmt) != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to finalize.\n");
    exit(EXIT_FAILURE);
  }
  if (sqlite3_close_v2(db) != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to close connection.\n");
    exit(EXIT_FAILURE);
  }
  sqlite3_shutdown();
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
movq   $0x0,-0x58(%rbp)
lea    0xd65(%rip),%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     12d5 <main+0x95>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    $0x0,%al
call   1030 <sqlite3_initialize@plt>
mov    0x2cfd(%rip),%rcx
cmp    (%rcx),%eax
je     1310 <main+0xd0>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   1150 <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   1140 <sqlite3_open_v2@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2cab(%rip),%rcx
cmp    (%rcx),%eax
je     137d <main+0x13d>
mov    0x2c8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <sqlite3_errmsg@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
jmp    1382 <main+0x142>
mov    -0x60(%rbp),%rdi
call   1090 <sqlite3_complete@plt>
cmp    $0x0,%rax
je     14ff <main+0x2bf>
mov    -0x18(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
lea    -0x58(%rbp),%r8
call   1130 <sqlite3_prepare_v2@plt>
mov    0x2c2a(%rip),%rcx
cmp    (%rcx),%eax
je     13e3 <main+0x1a3>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x20(%rbp),%rdi
call   1100 <sqlite3_column_count@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    142c <main+0x1ec>
mov    -0x20(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1050 <sqlite3_column_name@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    13ea <main+0x1aa>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%r8
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x2b5e(%rip),%rcx
cmp    (%rcx),%rax
jne    14e6 <main+0x2a6>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   10a0 <sqlite3_column_int@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1110 <sqlite3_column_text@plt>
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1110 <sqlite3_column_text@plt>
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1110 <sqlite3_column_text@plt>
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   10f0 <sqlite3_column_bytes@plt>
mov    -0x8c(%rbp),%esi
mov    -0x88(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    -0x78(%rbp),%r8
mov    %eax,%r9d
lea    0xc6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    144a <main+0x20a>
lea    0xc74(%rip),%rdi
call   1040 <puts@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1382 <main+0x142>
mov    -0x20(%rbp),%rdi
call   1120 <sqlite3_finalize@plt>
mov    0x2ad1(%rip),%rcx
cmp    (%rcx),%eax
je     153c <main+0x2fc>
mov    0x2ab2(%rip),%rax
mov    (%rax),%edi
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2a93(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1160 <sqlite3_close_v2@plt>
mov    0x2a94(%rip),%rcx
cmp    (%rcx),%eax
je     1579 <main+0x339>
mov    0x2a75(%rip),%rax
mov    (%rax),%edi
lea    0xc19(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2a56(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    $0x0,%al
call   1080 <sqlite3_shutdown@plt>
mov    0x2a39(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movq   $0x0,0x38(%rsp)
cmp    $0x2,%edi
jne    14b2 <main+0x282>
xor    %eax,%eax
call   1030 <sqlite3_initialize@plt>
mov    0x2d57(%rip),%rbx
cmp    (%rbx),%eax
jne    14ce <main+0x29e>
mov    0x8(%r14),%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1130 <sqlite3_open_v2@plt>
cmp    (%rbx),%eax
jne    14e0 <main+0x2b0>
lea    0xd4e(%rip),%r13
mov    %r13,%rdi
call   1080 <sqlite3_complete@plt>
test   %rax,%rax
je     144d <main+0x21d>
mov    0x2cee(%rip),%r12
lea    0xe73(%rip),%r14
xor    %eax,%eax
mov    %rax,0x30(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
jmp    1319 <main+0xe9>
nop
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
mov    0x38(%rsp),%r13
mov    %r13,%rdi
call   1080 <sqlite3_complete@plt>
test   %rax,%rax
mov    0x2ccd(%rip),%rbx
je     1446 <main+0x216>
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    $0xffffffff,%edx
lea    0x8(%rsp),%rcx
lea    0x38(%rsp),%r8
call   1120 <sqlite3_prepare_v2@plt>
cmp    (%rbx),%eax
jne    148d <main+0x25d>
mov    0x8(%rsp),%rdi
call   10f0 <sqlite3_column_count@plt>
test   %eax,%eax
jle    139e <main+0x16e>
xor    %ebp,%ebp
nopl   (%rax)
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1050 <sqlite3_column_name@plt>
mov    %rax,0x40(%rsp,%rbp,8)
add    $0x1,%rbp
mov    0x8(%rsp),%rdi
call   10f0 <sqlite3_column_count@plt>
cltq
cmp    %rax,%rbp
jl     1350 <main+0x120>
mov    0x40(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x48(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x50(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x58(%rsp),%rax
mov    %rax,0x30(%rsp)
lea    0xd8c(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    0x28(%rsp),%rcx
mov    0x30(%rsp),%r8
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   10b0 <sqlite3_step@plt>
cmp    (%r12),%rax
jne    12f0 <main+0xc0>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_int@plt>
mov    %eax,%r13d
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1100 <sqlite3_column_text@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1100 <sqlite3_column_text@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1100 <sqlite3_column_text@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   10e0 <sqlite3_column_bytes@plt>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r15,%r8
mov    %eax,%r9d
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13c0 <main+0x190>
mov    0x8(%rsp),%rdi
jmp    144f <main+0x21f>
xor    %edi,%edi
call   1110 <sqlite3_finalize@plt>
cmp    (%rbx),%eax
jne    1512 <main+0x2e2>
mov    0x10(%rsp),%rdi
call   1150 <sqlite3_close_v2@plt>
cmp    (%rbx),%eax
jne    1527 <main+0x2f7>
xor    %eax,%eax
call   1070 <sqlite3_shutdown@plt>
mov    0x2b44(%rip),%rax
mov    (%rax),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b3c(%rip),%rax
mov    (%rax),%edi
lea    0xc69(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x2b1d(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xbe0(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14a4 <main+0x274>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
lea    0xbe2(%rip),%rsi
jmp    149d <main+0x26d>
mov    0x2ae9(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_errmsg@plt>
lea    0xbee(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   10d0 <sqlite3_close@plt>
jmp    14a4 <main+0x274>
mov    0x2ab7(%rip),%rax
mov    (%rax),%edi
lea    0xc41(%rip),%rsi
jmp    149d <main+0x26d>
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
lea    0xc46(%rip),%rsi
jmp    149d <main+0x26d>

LLVM IR (-O0):
@SQLITE_OPEN_READONLY = global i32 0
@.str = [165 x i8] c"SELECT * FROM addressbook ORDER by id;SELECT * FROM addressbook ORDER by fullname;SELECT * FROM addressbook ORDER by alias;SELECT * FROM addressbook ORDER by email;\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 = [30 x i8] c"Err. can't open database: %s\0A\00"
@.str.4 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@.str.5 = [19 x i8] c"%2s %10s %8s %14s\0A\00"
@SQLITE_ROW = global i64 0
@.str.6 = [31 x i8] c"%2d %10s %5s %20s (byte: %3d)\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [26 x i8] c"Err. Unable to finalize.\0A\00"
@.str.9 = [34 x i8] c"Err. Unable to close connection.\0A\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 [4 x i8*]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
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
%14 = load i32, i32* @SQLITE_OPEN_READONLY
store i32 %14, i32* %9
%15 = bitcast [4 x i8*]* %10 to i8*
store i8* null, i8** %11
store i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str, i64 0, i64 0), i8** %12
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %2
%27 = call i32 (...) @sqlite3_initialize()
%28 = load i32, i32* @SQLITE_OK
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %26
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = load i32, i32* %9
%40 = call i32 @sqlite3_open_v2(i8* %38, i32** %6, i32 %39, i32* null)
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = load i32, i32* @SQLITE_OK
%43 = icmp ne i32 %41, %42
br i1 %43, label %44, label %53
44: ; preds = %35
%45 = load i32, i32* @stderr
%46 = load i32*, i32** %6
%47 = call i8* @sqlite3_errmsg(i32* %46)
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load i32*, i32** %6
%50 = call i32 @sqlite3_close(i32* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %35
br label %54
54: ; preds = %115, %53
%55 = load i8*, i8** %12
%56 = call i64 @sqlite3_complete(i8* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %118
58: ; preds = %54
%59 = load i32*, i32** %6
%60 = load i8*, i8** %12
%61 = call i32 @sqlite3_prepare_v2(i32* %59, i8* %60, i32 -1, i32** %7, i8** %11)
%62 = load i32, i32* @SQLITE_OK
%63 = icmp ne i32 %61, %62
br i1 %63, label %64, label %69
64: ; preds = %58
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %58
store i32 0, i32* %13
br label %70
70: ; preds = %82, %69
%71 = load i32, i32* %13
%72 = load i32*, i32** %7
%73 = call i32 @sqlite3_column_count(i32* %72)
%74 = icmp slt i32 %71, %73
br i1 %74, label %75, label %85
75: ; preds = %70
%76 = load i32*, i32** %7
%77 = load i32, i32* %13
%78 = call i8* @sqlite3_column_name(i32* %76, i32 %77)
%79 = load i32, i32* %13
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 %80
store i8* %78, i8** %81
br label %82
82: ; preds = %75
%83 = load i32, i32* %13
%84 = add nsw i32 %83, 1
store i32 %84, i32* %13
br label %70
85: ; preds = %70
%86 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 0
%87 = load i8*, i8** %86
%88 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 1
%89 = load i8*, i8** %88
%90 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 2
%91 = load i8*, i8** %90
%92 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 3
%93 = load i8*, i8** %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %87, i8* %89, i8* %91, i8* %93)
br label %95
95: ; preds = %100, %85
%96 = load i32*, i32** %7
%97 = call i64 @sqlite3_step(i32* %96)
%98 = load i64, i64* @SQLITE_ROW
%99 = icmp eq i64 %97, %98
br i1 %99, label %100, label %115
100: ; preds = %95
%101 = load i32*, i32** %7
%102 = call i32 @sqlite3_column_int(i32* %101, i32 0)
%103 = load i32*, i32** %7
%104 = call i64 @sqlite3_column_text(i32* %103, i32 1)
%105 = inttoptr i64 %104 to i8*
%106 = load i32*, i32** %7
%107 = call i64 @sqlite3_column_text(i32* %106, i32 2)
%108 = inttoptr i64 %107 to i8*
%109 = load i32*, i32** %7
%110 = call i64 @sqlite3_column_text(i32* %109, i32 3)
%111 = inttoptr i64 %110 to i8*
%112 = load i32*, i32** %7
%113 = call i32 @sqlite3_column_bytes(i32* %112, i32 3)
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %102, i8* %105, i8* %108, i8* %111, i32 %113)
br label %95
115: ; preds = %95
%116 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%117 = load i8*, i8** %11
store i8* %117, i8** %12
br label %54
118: ; preds = %54
%119 = load i32*, i32** %7
%120 = call i32 @sqlite3_finalize(i32* %119)
%121 = load i32, i32* @SQLITE_OK
%122 = icmp ne i32 %120, %121
br i1 %122, label %123, label %128
123: ; preds = %118
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%126 = load i32, i32* @EXIT_FAILURE
%127 = call i32 @exit(i32 %126)
unreachable
128: ; preds = %118
%129 = load i32*, i32** %6
%130 = call i32 @sqlite3_close_v2(i32* %129)
%131 = load i32, i32* @SQLITE_OK
%132 = icmp ne i32 %130, %131
br i1 %132, label %133, label %138
133: ; preds = %128
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%136 = load i32, i32* @EXIT_FAILURE
%137 = call i32 @exit(i32 %136)
unreachable
138: ; preds = %128
%139 = call i32 (...) @sqlite3_shutdown()
%140 = load i32, i32* @EXIT_SUCCESS
ret i32 %140
}

LLVM IR (-O2):
@SQLITE_OPEN_READONLY = global i32 0
@.str = [165 x i8] c"SELECT * FROM addressbook ORDER by id;SELECT * FROM addressbook ORDER by fullname;SELECT * FROM addressbook ORDER by alias;SELECT * FROM addressbook ORDER by email;\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 = [30 x i8] c"Err. can't open database: %s\0A\00"
@.str.4 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@.str.5 = [19 x i8] c"%2s %10s %8s %14s\0A\00"
@SQLITE_ROW = global i64 0
@.str.6 = [31 x i8] c"%2d %10s %5s %20s (byte: %3d)\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [26 x i8] c"Err. Unable to finalize.\0A\00"
@.str.9 = [34 x i8] c"Err. Unable to close connection.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [4 x i8*]
%6 = alloca i8*
%7 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%8 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%9 = load i32, i32* @SQLITE_OPEN_READONLY
%10 = bitcast [4 x i8*]* %5 to i8*
%11 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%12 = icmp eq i32 %0, 2
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = tail call i32 (...) @sqlite3_initialize()
%21 = load i32, i32* @SQLITE_OK
%22 = icmp eq i32 %20, %21
br i1 %22, label %28, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @sqlite3_open_v2(i8* %30, i32** %3, i32 %9, i32* null)
%32 = load i32, i32* @SQLITE_OK
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = call i64 @sqlite3_complete(i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %122, label %37
37: ; preds = %34
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 0
%39 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 1
%40 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 2
%41 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 3
br label %51
42: ; preds = %28
%43 = load i32, i32* @stderr
%44 = load i32*, i32** %3
%45 = call i8* @sqlite3_errmsg(i32* %44)
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = load i32*, i32** %3
%48 = call i32 @sqlite3_close(i32* %47)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %37, %115
%52 = phi i8* [ null, %37 ], [ %76, %115 ]
%53 = phi i8* [ null, %37 ], [ %77, %115 ]
%54 = phi i8* [ null, %37 ], [ %78, %115 ]
%55 = phi i8* [ null, %37 ], [ %79, %115 ]
%56 = phi i8* [ getelementptr inbounds ([165 x i8], [165 x i8]* @.str, i64 0, i64 0), %37 ], [ %117, %115 ]
%57 = load i32*, i32** %3
%58 = call i32 @sqlite3_prepare_v2(i32* %57, i8* %56, i32 -1, i32** %4, i8** %6)
%59 = load i32, i32* @SQLITE_OK
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %65
61: ; preds = %51
%62 = load i32*, i32** %4
%63 = call i32 @sqlite3_column_count(i32* %62)
%64 = icmp sgt i32 %63, 0
br i1 %64, label %85, label %75
65: ; preds = %51
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %85
%71 = load i8*, i8** %38
%72 = load i8*, i8** %39
%73 = load i8*, i8** %40
%74 = load i8*, i8** %41
br label %75
75: ; preds = %70, %61
%76 = phi i8* [ %74, %70 ], [ %52, %61 ]
%77 = phi i8* [ %73, %70 ], [ %53, %61 ]
%78 = phi i8* [ %72, %70 ], [ %54, %61 ]
%79 = phi i8* [ %71, %70 ], [ %55, %61 ]
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %79, i8* %78, i8* %77, i8* %76)
%81 = load i32*, i32** %4
%82 = call i64 @sqlite3_step(i32* %81)
%83 = load i64, i64* @SQLITE_ROW
%84 = icmp eq i64 %82, %83
br i1 %84, label %96, label %115
85: ; preds = %61, %85
%86 = phi i64 [ %91, %85 ], [ 0, %61 ]
%87 = load i32*, i32** %4
%88 = trunc i64 %86 to i32
%89 = call i8* @sqlite3_column_name(i32* %87, i32 %88)
%90 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %86
store i8* %89, i8** %90
%91 = add nuw nsw i64 %86, 1
%92 = load i32*, i32** %4
%93 = call i32 @sqlite3_column_count(i32* %92)
%94 = sext i32 %93 to i64
%95 = icmp slt i64 %91, %94
br i1 %95, label %85, label %70
96: ; preds = %75, %96
%97 = load i32*, i32** %4
%98 = call i32 @sqlite3_column_int(i32* %97, i32 0)
%99 = load i32*, i32** %4
%100 = call i64 @sqlite3_column_text(i32* %99, i32 1)
%101 = inttoptr i64 %100 to i8*
%102 = load i32*, i32** %4
%103 = call i64 @sqlite3_column_text(i32* %102, i32 2)
%104 = inttoptr i64 %103 to i8*
%105 = load i32*, i32** %4
%106 = call i64 @sqlite3_column_text(i32* %105, i32 3)
%107 = inttoptr i64 %106 to i8*
%108 = load i32*, i32** %4
%109 = call i32 @sqlite3_column_bytes(i32* %108, i32 3)
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %98, i8* %101, i8* %104, i8* %107, i32 %109)
%111 = load i32*, i32** %4
%112 = call i64 @sqlite3_step(i32* %111)
%113 = load i64, i64* @SQLITE_ROW
%114 = icmp eq i64 %112, %113
br i1 %114, label %96, label %115
115: ; preds = %96, %75
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%117 = load i8*, i8** %6
%118 = call i64 @sqlite3_complete(i8* %117)
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %51
120: ; preds = %115
%121 = load i32*, i32** %4
br label %122
122: ; preds = %120, %34
%123 = phi i32* [ %121, %120 ], [ null, %34 ]
%124 = call i32 @sqlite3_finalize(i32* %123)
%125 = load i32, i32* @SQLITE_OK
%126 = icmp eq i32 %124, %125
br i1 %126, label %132, label %127
127: ; preds = %122
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %122
%133 = load i32*, i32** %3
%134 = call i32 @sqlite3_close_v2(i32* %133)
%135 = load i32, i32* @SQLITE_OK
%136 = icmp eq i32 %134, %135
br i1 %136, label %142, label %137
137: ; preds = %132
%138 = load i32, i32* @stderr
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%140 = load i32, i32* @EXIT_FAILURE
%141 = call i32 @exit(i32 %140)
unreachable
142: ; preds = %132
%143 = call i32 (...) @sqlite3_shutdown()
%144 = load i32, i32* @EXIT_SUCCESS
ret i32 %144
}