#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*/ 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);
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*/ **,
                       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;
  const char *colnms[4] = {NULL};
  int res = 0;
  const char *tail = NULL;
  char *sql_str = "SELECT * FROM addressbook ORDER by id";
  int flags = SQLITE_OPEN_READONLY;
  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);
  }
  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));
  }
  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)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xd91(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     12b5 <main+0x95>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd86(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   1030 <sqlite3_initialize@plt>
mov    0x2d1d(%rip),%rcx
cmp    (%rcx),%eax
je     12f0 <main+0xd0>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x5c(%rbp),%edx
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1120 <sqlite3_open_v2@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2ccb(%rip),%rcx
cmp    (%rcx),%eax
je     135d <main+0x13d>
mov    0x2cac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_errmsg@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <sqlite3_close@plt>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
lea    -0x50(%rbp),%r8
call   1110 <sqlite3_prepare_v2@plt>
mov    0x2c62(%rip),%rcx
cmp    (%rcx),%eax
je     13ab <main+0x18b>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    0xcf1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <sqlite3_column_count@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    13f4 <main+0x1d4>
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%esi
call   1040 <sqlite3_column_name@plt>
mov    %rax,%rcx
movslq -0x60(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    13b2 <main+0x192>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <sqlite3_step@plt>
mov    0x2b96(%rip),%rcx
cmp    (%rcx),%rax
jne    14a8 <main+0x288>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,-0x84(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <sqlite3_column_text@plt>
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   10f0 <sqlite3_column_text@plt>
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   10f0 <sqlite3_column_text@plt>
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   10d0 <sqlite3_column_bytes@plt>
mov    -0x84(%rbp),%esi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    -0x70(%rbp),%r8
mov    %eax,%r9d
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1412 <main+0x1f2>
mov    -0x20(%rbp),%rdi
call   1100 <sqlite3_finalize@plt>
mov    0x2b28(%rip),%rcx
cmp    (%rcx),%eax
je     14e5 <main+0x2c5>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xc14(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1140 <sqlite3_close_v2@plt>
mov    0x2aeb(%rip),%rcx
cmp    (%rcx),%eax
je     1522 <main+0x302>
mov    0x2acc(%rip),%rax
mov    (%rax),%edi
lea    0xbf1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2aad(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   1070 <sqlite3_shutdown@plt>
mov    0x2a90(%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    $0x48,%rsp
mov    %rsi,%rbx
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x2,%edi
jne    1417 <main+0x207>
mov    0x2d8f(%rip),%rax
mov    (%rax),%ebp
xor    %eax,%eax
call   1030 <sqlite3_initialize@plt>
mov    0x2d77(%rip),%r14
cmp    (%r14),%eax
jne    1433 <main+0x223>
mov    0x8(%rbx),%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1110 <sqlite3_open_v2@plt>
cmp    (%r14),%eax
jne    1445 <main+0x235>
mov    0x10(%rsp),%rdi
lea    0xd67(%rip),%rsi
lea    0x8(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    $0xffffffff,%edx
call   1100 <sqlite3_prepare_v2@plt>
cmp    (%r14),%eax
jne    1477 <main+0x267>
mov    0x8(%rsp),%rdi
call   10d0 <sqlite3_column_count@plt>
test   %eax,%eax
jle    130c <main+0xfc>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
call   1040 <sqlite3_column_name@plt>
mov    %rax,0x20(%rsp,%rbx,8)
add    $0x1,%rbx
mov    0x8(%rsp),%rdi
call   10d0 <sqlite3_column_count@plt>
cltq
cmp    %rax,%rbx
jl     12d0 <main+0xc0>
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    0x30(%rsp),%rcx
mov    0x38(%rsp),%r8
jmp    1315 <main+0x105>
xor    %r8d,%r8d
xor    %ecx,%ecx
xor    %edx,%edx
xor    %esi,%esi
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1090 <sqlite3_step@plt>
mov    0x2c84(%rip),%r13
cmp    0x0(%r13),%rax
jne    13cd <main+0x1bd>
lea    0xd80(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_int@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   10e0 <sqlite3_column_text@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   10e0 <sqlite3_column_text@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   10e0 <sqlite3_column_text@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   10c0 <sqlite3_column_bytes@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %eax,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1090 <sqlite3_step@plt>
cmp    0x0(%r13),%rax
je     1350 <main+0x140>
mov    0x8(%rsp),%rdi
call   10f0 <sqlite3_finalize@plt>
mov    0x2c02(%rip),%rbx
cmp    (%rbx),%eax
jne    1489 <main+0x279>
mov    0x10(%rsp),%rdi
call   1130 <sqlite3_close_v2@plt>
cmp    (%rbx),%eax
jne    149b <main+0x28b>
xor    %eax,%eax
call   1060 <sqlite3_shutdown@plt>
mov    0x2bba(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xbfc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    14b2 <main+0x2a2>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
lea    0xbfe(%rip),%rsi
jmp    14ab <main+0x29b>
mov    0x2b84(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xc0a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   10b0 <sqlite3_close@plt>
jmp    14b2 <main+0x2a2>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
lea    0xc00(%rip),%rsi
jmp    14ab <main+0x29b>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
lea    0xc4b(%rip),%rsi
jmp    14ab <main+0x29b>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
lea    0xc53(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"SELECT * FROM addressbook ORDER by id\00"
@SQLITE_OPEN_READONLY = global i32 0
@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 = [26 x i8] c"Err. Unable to finalize.\0A\00"
@.str.8 = [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 [4 x i8*]
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%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
%14 = bitcast [4 x i8*]* %8 to i8*
store i32 0, i32* %9
store i8* null, i8** %10
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %11
%15 = load i32, i32* @SQLITE_OPEN_READONLY
store i32 %15, i32* %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* %12
%40 = call i32 @sqlite3_open_v2(i8* %38, i32** %6, i32 %39, i32* null)
store i32 %40, i32* %9
%41 = load i32, i32* %9
%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
%54 = load i32*, i32** %6
%55 = load i8*, i8** %11
%56 = call i32 @sqlite3_prepare_v2(i32* %54, i8* %55, i32 -1, i32** %7, i8** %10)
%57 = load i32, i32* @SQLITE_OK
%58 = icmp ne i32 %56, %57
br i1 %58, label %59, label %64
59: ; preds = %53
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %53
store i32 0, i32* %13
br label %65
65: ; preds = %77, %64
%66 = load i32, i32* %13
%67 = load i32*, i32** %7
%68 = call i32 @sqlite3_column_count(i32* %67)
%69 = icmp slt i32 %66, %68
br i1 %69, label %70, label %80
70: ; preds = %65
%71 = load i32*, i32** %7
%72 = load i32, i32* %13
%73 = call i8* @sqlite3_column_name(i32* %71, i32 %72)
%74 = load i32, i32* %13
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 %75
store i8* %73, i8** %76
br label %77
77: ; preds = %70
%78 = load i32, i32* %13
%79 = add nsw i32 %78, 1
store i32 %79, i32* %13
br label %65
80: ; preds = %65
%81 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 0
%82 = load i8*, i8** %81
%83 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 1
%84 = load i8*, i8** %83
%85 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 2
%86 = load i8*, i8** %85
%87 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 3
%88 = load i8*, i8** %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %82, i8* %84, i8* %86, i8* %88)
br label %90
90: ; preds = %95, %80
%91 = load i32*, i32** %7
%92 = call i64 @sqlite3_step(i32* %91)
%93 = load i64, i64* @SQLITE_ROW
%94 = icmp eq i64 %92, %93
br i1 %94, label %95, label %110
95: ; preds = %90
%96 = load i32*, i32** %7
%97 = call i32 @sqlite3_column_int(i32* %96, i32 0)
%98 = load i32*, i32** %7
%99 = call i64 @sqlite3_column_text(i32* %98, i32 1)
%100 = inttoptr i64 %99 to i8*
%101 = load i32*, i32** %7
%102 = call i64 @sqlite3_column_text(i32* %101, i32 2)
%103 = inttoptr i64 %102 to i8*
%104 = load i32*, i32** %7
%105 = call i64 @sqlite3_column_text(i32* %104, i32 3)
%106 = inttoptr i64 %105 to i8*
%107 = load i32*, i32** %7
%108 = call i32 @sqlite3_column_bytes(i32* %107, i32 3)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %97, i8* %100, i8* %103, i8* %106, i32 %108)
br label %90
110: ; preds = %90
%111 = load i32*, i32** %7
%112 = call i32 @sqlite3_finalize(i32* %111)
%113 = load i32, i32* @SQLITE_OK
%114 = icmp ne i32 %112, %113
br i1 %114, label %115, label %120
115: ; preds = %110
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%118 = load i32, i32* @EXIT_FAILURE
%119 = call i32 @exit(i32 %118)
unreachable
120: ; preds = %110
%121 = load i32*, i32** %6
%122 = call i32 @sqlite3_close_v2(i32* %121)
%123 = load i32, i32* @SQLITE_OK
%124 = icmp ne i32 %122, %123
br i1 %124, label %125, label %130
125: ; preds = %120
%126 = load i32, i32* @stderr
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @exit(i32 %128)
unreachable
130: ; preds = %120
%131 = call i32 (...) @sqlite3_shutdown()
%132 = load i32, i32* @EXIT_SUCCESS
ret i32 %132
}

LLVM IR (-O2):
@.str = [38 x i8] c"SELECT * FROM addressbook ORDER by id\00"
@SQLITE_OPEN_READONLY = global i32 0
@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 = [26 x i8] c"Err. Unable to finalize.\0A\00"
@.str.8 = [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 = bitcast [4 x i8*]* %5 to i8*
%10 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%11 = load i32, i32* @SQLITE_OPEN_READONLY
%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 %11, i32* null)
%32 = load i32, i32* @SQLITE_OK
%33 = icmp eq i32 %31, %32
br i1 %33, label %43, label %34
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = load i32*, i32** %3
%37 = call i8* @sqlite3_errmsg(i32* %36)
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = load i32*, i32** %3
%40 = call i32 @sqlite3_close(i32* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %28
%44 = load i32*, i32** %3
%45 = call i32 @sqlite3_prepare_v2(i32* %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 -1, i32** %4, i8** %6)
%46 = load i32, i32* @SQLITE_OK
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i32*, i32** %4
%50 = call i32 @sqlite3_column_count(i32* %49)
%51 = icmp sgt i32 %50, 0
br i1 %51, label %76, label %66
52: ; preds = %43
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %76
%58 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 0
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 1
%61 = load i8*, i8** %60
%62 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 2
%63 = load i8*, i8** %62
%64 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 3
%65 = load i8*, i8** %64
br label %66
66: ; preds = %57, %48
%67 = phi i8* [ %65, %57 ], [ null, %48 ]
%68 = phi i8* [ %63, %57 ], [ null, %48 ]
%69 = phi i8* [ %61, %57 ], [ null, %48 ]
%70 = phi i8* [ %59, %57 ], [ null, %48 ]
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %70, i8* %69, i8* %68, i8* %67)
%72 = load i32*, i32** %4
%73 = call i64 @sqlite3_step(i32* %72)
%74 = load i64, i64* @SQLITE_ROW
%75 = icmp eq i64 %73, %74
br i1 %75, label %87, label %106
76: ; preds = %48, %76
%77 = phi i64 [ %82, %76 ], [ 0, %48 ]
%78 = load i32*, i32** %4
%79 = trunc i64 %77 to i32
%80 = call i8* @sqlite3_column_name(i32* %78, i32 %79)
%81 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %77
store i8* %80, i8** %81
%82 = add nuw nsw i64 %77, 1
%83 = load i32*, i32** %4
%84 = call i32 @sqlite3_column_count(i32* %83)
%85 = sext i32 %84 to i64
%86 = icmp slt i64 %82, %85
br i1 %86, label %76, label %57
87: ; preds = %66, %87
%88 = load i32*, i32** %4
%89 = call i32 @sqlite3_column_int(i32* %88, i32 0)
%90 = load i32*, i32** %4
%91 = call i64 @sqlite3_column_text(i32* %90, i32 1)
%92 = inttoptr i64 %91 to i8*
%93 = load i32*, i32** %4
%94 = call i64 @sqlite3_column_text(i32* %93, i32 2)
%95 = inttoptr i64 %94 to i8*
%96 = load i32*, i32** %4
%97 = call i64 @sqlite3_column_text(i32* %96, i32 3)
%98 = inttoptr i64 %97 to i8*
%99 = load i32*, i32** %4
%100 = call i32 @sqlite3_column_bytes(i32* %99, i32 3)
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %89, i8* %92, i8* %95, i8* %98, i32 %100)
%102 = load i32*, i32** %4
%103 = call i64 @sqlite3_step(i32* %102)
%104 = load i64, i64* @SQLITE_ROW
%105 = icmp eq i64 %103, %104
br i1 %105, label %87, label %106
106: ; preds = %87, %66
%107 = load i32*, i32** %4
%108 = call i32 @sqlite3_finalize(i32* %107)
%109 = load i32, i32* @SQLITE_OK
%110 = icmp eq i32 %108, %109
br i1 %110, label %116, label %111
111: ; preds = %106
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %106
%117 = load i32*, i32** %3
%118 = call i32 @sqlite3_close_v2(i32* %117)
%119 = load i32, i32* @SQLITE_OK
%120 = icmp eq i32 %118, %119
br i1 %120, label %126, label %121
121: ; preds = %116
%122 = load i32, i32* @stderr
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%124 = load i32, i32* @EXIT_FAILURE
%125 = call i32 @exit(i32 %124)
unreachable
126: ; preds = %116
%127 = call i32 (...) @sqlite3_shutdown()
%128 = load i32, i32* @EXIT_SUCCESS
ret i32 %128
}