#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_blob;
typedef int /*<<< orphan*/ sqlite3;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int SQLITE_OK;
int SQLITE_OPEN_READWRITE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char const *const);
int /*<<< orphan*/ puts(char *);
int sqlite3_blob_bytes(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_blob_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_blob_open(int /*<<< orphan*/ *, char *, char *,
                                     char *, int, int /*<<< orphan*/,
                                     int /*<<< orphan*/ **);
int /*<<< orphan*/ sqlite3_blob_read(int /*<<< orphan*/ *, char *, int,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_close_v2(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_initialize();
int sqlite3_open_v2(char const *const, int /*<<< orphan*/ **, int,
                    int /*<<< orphan*/ *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_shutdown();
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  sqlite3 *db = NULL;
  sqlite3_stmt *stmt = NULL;
  sqlite3_blob *blob = NULL;
  FILE *fblob = NULL;
  int res = 0;
  int blob_size = 0;
  int flags = SQLITE_OPEN_READWRITE;
  char *blob_data = NULL;
  char *sql_data = "SELECT rowid FROM blobs WHERE id = 1";
  if (argc < 3) {
    fprintf(stderr, "Usage: %s <database> <filename>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  const char *const db_name = (argc && argv[1]) ? argv[1] : "";
  const char *const data_name = (argc && argv[2]) ? argv[2] : "";
  if (sqlite3_initialize() != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to initialize the library.\n");
    exit(EXIT_FAILURE);
  }
  res = sqlite3_open_v2(db_name, &db, flags, NULL);
  if (res != SQLITE_OK) {
    fprintf(stderr, "Err. can't create database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(EXIT_FAILURE);
  }
  if (sqlite3_prepare_v2(db, sql_data, -1, &stmt, NULL) != SQLITE_OK) {
    fprintf(stderr, "Err. Unable to create Prepared Statement.\n");
    exit(EXIT_FAILURE);
  }
  sqlite3_blob_open(db, "main", "blobs", "data", 1, 0, &blob);
  blob_size = sqlite3_blob_bytes(blob);
  blob_data = malloc(blob_size);
  sqlite3_blob_read(blob, blob_data, blob_size, 0);
  sqlite3_blob_close(blob);
  fblob = fopen(data_name, "w");
  if (fblob == NULL) {
    fprintf(stderr, "Err. Open file failed: %s\n", strerror(errno));
    return 1;
  }
  if (fwrite(blob_data, blob_size, 1, fblob) != 1) {
    fprintf(stderr, "Err. Write file failed: %s\n", strerror(errno));
    return 1;
  } else
    printf("Written BLOB data into \'%s\'\n", data_name);
  fclose(fblob);
  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    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
lea    0xd4e(%rip),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    12ec <main+0x9c>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
je     1316 <main+0xc6>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1316 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x68(%rbp)
jmp    1326 <main+0xd6>
lea    0xe01(%rip),%rax
mov    %rax,-0x68(%rbp)
jmp    1326 <main+0xd6>
mov    -0x68(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1358 <main+0x108>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1358 <main+0x108>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    1368 <main+0x118>
lea    0xdbf(%rip),%rax
mov    %rax,-0x70(%rbp)
jmp    1368 <main+0x118>
mov    -0x70(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1030 <sqlite3_initialize@plt>
mov    0x2c62(%rip),%rcx
cmp    (%rcx),%eax
je     13ab <main+0x15b>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    -0x3c(%rbp),%edx
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1130 <sqlite3_open_v2@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2c14(%rip),%rcx
cmp    (%rcx),%eax
je     1414 <main+0x1c4>
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <sqlite3_errmsg@plt>
mov    -0x74(%rbp),%edi
mov    %rax,%rdx
lea    0xc78(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <sqlite3_close@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1120 <sqlite3_prepare_v2@plt>
mov    0x2baa(%rip),%rcx
cmp    (%rcx),%eax
je     1463 <main+0x213>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
lea    0xc40(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2b64(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xc4b(%rip),%rsi
lea    0xc49(%rip),%rdx
lea    0xc48(%rip),%rcx
mov    $0x1,%r8d
xor    %r9d,%r9d
lea    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <sqlite3_blob_open@plt>
mov    -0x28(%rbp),%rdi
call   10e0 <sqlite3_blob_bytes@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x38(%rbp),%edx
xor    %ecx,%ecx
call   10d0 <sqlite3_blob_read@plt>
mov    -0x28(%rbp),%rdi
call   10f0 <sqlite3_blob_close@plt>
mov    -0x60(%rbp),%rdi
lea    0xbf9(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    151e <main+0x2ce>
mov    0x2ae5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2ad1(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0x78(%rbp),%edi
mov    %rax,%rdx
lea    0xbc0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ea <main+0x39a>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1160 <fwrite@plt>
cmp    $0x1,%eax
je     1576 <main+0x326>
mov    0x2a8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2a79(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rdx
lea    0xb83(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ea <main+0x39a>
mov    -0x60(%rbp),%rsi
lea    0xb81(%rip),%rdi
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1110 <sqlite3_finalize@plt>
mov    0x2a41(%rip),%rcx
cmp    (%rcx),%eax
jne    15b3 <main+0x363>
lea    0xb71(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1150 <sqlite3_close_v2@plt>
mov    0x2a1d(%rip),%rcx
cmp    (%rcx),%eax
jne    15d7 <main+0x387>
lea    0xb6f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1080 <sqlite3_shutdown@plt>
mov    0x29d3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%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    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x2,%edi
jle    1467 <main+0x217>
mov    0x2d67(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r15
test   %r15,%r15
lea    0xe80(%rip),%rbp
cmove  %rbp,%r15
xor    %eax,%eax
call   1030 <sqlite3_initialize@plt>
mov    0x2d30(%rip),%r13
cmp    0x0(%r13),%eax
jne    1483 <main+0x233>
test   %rbx,%rbx
cmovne %rbx,%rbp
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1130 <sqlite3_open_v2@plt>
cmp    0x0(%r13),%eax
jne    1495 <main+0x245>
mov    0x10(%rsp),%rdi
lea    0xd17(%rip),%rsi
lea    0x20(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1120 <sqlite3_prepare_v2@plt>
cmp    0x0(%r13),%eax
jne    14c7 <main+0x277>
mov    0x10(%rsp),%rdi
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0xd9f(%rip),%rsi
lea    0xd9d(%rip),%rdx
lea    0xd9c(%rip),%rcx
mov    $0x1,%r14d
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1050 <sqlite3_blob_open@plt>
mov    0x18(%rsp),%rdi
call   10e0 <sqlite3_blob_bytes@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%r12
mov    0x18(%rsp),%rdi
mov    %rax,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   10d0 <sqlite3_blob_read@plt>
mov    0x18(%rsp),%rdi
call   10f0 <sqlite3_blob_close@plt>
lea    0xd55(%rip),%rsi
mov    %r15,%rdi
call   1100 <fopen@plt>
test   %rax,%rax
je     140b <main+0x1bb>
mov    %rax,%rbx
mov    $0x1,%r14d
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1160 <fwrite@plt>
cmp    $0x1,%eax
jne    142b <main+0x1db>
lea    0xd52(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1110 <sqlite3_finalize@plt>
cmp    0x0(%r13),%eax
jne    13dc <main+0x18c>
lea    0xd48(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%rdi
call   1150 <sqlite3_close_v2@plt>
cmp    0x0(%r13),%eax
jne    13f8 <main+0x1a8>
lea    0xd4e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <sqlite3_shutdown@plt>
mov    0x2bb2(%rip),%rax
mov    (%rax),%r14d
jmp    1455 <main+0x205>
mov    0x2bbe(%rip),%rax
mov    (%rax),%ebx
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
lea    0xca2(%rip),%rsi
jmp    1449 <main+0x1f9>
mov    0x2b9e(%rip),%rax
mov    (%rax),%ebx
mov    0x2b8d(%rip),%rax
mov    (%rax),%edi
call   1170 <strerror@plt>
lea    0xc9d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b62(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xbab(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    14de <main+0x28e>
mov    0x2b46(%rip),%rax
mov    (%rax),%edi
lea    0xbb3(%rip),%rsi
jmp    14d7 <main+0x287>
mov    0x2b34(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   1090 <sqlite3_errmsg@plt>
lea    0xbbf(%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    14de <main+0x28e>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
lea    0xbb7(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2adb(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@SQLITE_OPEN_READWRITE = global i32 0
@.str = [37 x i8] c"SELECT rowid FROM blobs WHERE id = 1\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Usage: %s <database> <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@SQLITE_OK = global i32 0
@.str.3 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.4 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.5 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@.str.6 = [5 x i8] c"main\00"
@.str.7 = [6 x i8] c"blobs\00"
@.str.8 = [5 x i8] c"data\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [27 x i8] c"Err. Open file failed: %s\0A\00"
@errno = global i32 0
@.str.11 = [28 x i8] c"Err. Write file failed: %s\0A\00"
@.str.12 = [29 x i8] c"Written BLOB data into '%s'\0A\00"
@.str.13 = [34 x i8] c"... Prepared Statemend destroyed.\00"
@.str.14 = [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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = 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* null, i32** %8
store i32* null, i32** %9
store i32 0, i32* %10
store i32 0, i32* %11
%17 = load i32, i32* @SQLITE_OPEN_READWRITE
store i32 %17, i32* %12
store i8* null, i8** %13
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %14
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %28
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %2
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
br label %41
40: ; preds = %31, %28
br label %41
41: ; preds = %40, %36
%42 = phi i8* [ %39, %36 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %40 ]
store i8* %42, i8** %15
%43 = load i32, i32* %4
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
br label %55
54: ; preds = %45, %41
br label %55
55: ; preds = %54, %50
%56 = phi i8* [ %53, %50 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %54 ]
store i8* %56, i8** %16
%57 = call i32 (...) @sqlite3_initialize()
%58 = load i32, i32* @SQLITE_OK
%59 = icmp ne i32 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %55
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %55
%66 = load i8*, i8** %15
%67 = load i32, i32* %12
%68 = call i32 @sqlite3_open_v2(i8* %66, i32** %6, i32 %67, i32* null)
store i32 %68, i32* %10
%69 = load i32, i32* %10
%70 = load i32, i32* @SQLITE_OK
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %81
72: ; preds = %65
%73 = load i32, i32* @stderr
%74 = load i32*, i32** %6
%75 = call i8* @sqlite3_errmsg(i32* %74)
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %75)
%77 = load i32*, i32** %6
%78 = call i32 @sqlite3_close(i32* %77)
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %65
%82 = load i32*, i32** %6
%83 = load i8*, i8** %14
%84 = call i32 @sqlite3_prepare_v2(i32* %82, i8* %83, i32 -1, i32** %7, i32* null)
%85 = load i32, i32* @SQLITE_OK
%86 = icmp ne i32 %84, %85
br i1 %86, label %87, label %92
87: ; preds = %81
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %81
%93 = load i32*, i32** %6
%94 = call i32 @sqlite3_blob_open(i32* %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 1, i32 0, i32** %8)
%95 = load i32*, i32** %8
%96 = call i32 @sqlite3_blob_bytes(i32* %95)
store i32 %96, i32* %11
%97 = load i32, i32* %11
%98 = call i8* @malloc(i32 %97)
store i8* %98, i8** %13
%99 = load i32*, i32** %8
%100 = load i8*, i8** %13
%101 = load i32, i32* %11
%102 = call i32 @sqlite3_blob_read(i32* %99, i8* %100, i32 %101, i32 0)
%103 = load i32*, i32** %8
%104 = call i32 @sqlite3_blob_close(i32* %103)
%105 = load i8*, i8** %16
%106 = call i32* @fopen(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %106, i32** %9
%107 = load i32*, i32** %9
%108 = icmp eq i32* %107, null
br i1 %108, label %109, label %114
109: ; preds = %92
%110 = load i32, i32* @stderr
%111 = load i32, i32* @errno
%112 = call i8* @strerror(i32 %111)
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %112)
store i32 1, i32* %3
br label %147
114: ; preds = %92
%115 = load i8*, i8** %13
%116 = load i32, i32* %11
%117 = load i32*, i32** %9
%118 = call i32 @fwrite(i8* %115, i32 %116, i32 1, i32* %117)
%119 = icmp ne i32 %118, 1
br i1 %119, label %120, label %125
120: ; preds = %114
%121 = load i32, i32* @stderr
%122 = load i32, i32* @errno
%123 = call i8* @strerror(i32 %122)
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %123)
store i32 1, i32* %3
br label %147
125: ; preds = %114
%126 = load i8*, i8** %16
%127 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* %126)
br label %128
128: ; preds = %125
%129 = load i32*, i32** %9
%130 = call i32 @fclose(i32* %129)
%131 = load i32*, i32** %7
%132 = call i32 @sqlite3_finalize(i32* %131)
%133 = load i32, i32* @SQLITE_OK
%134 = icmp eq i32 %132, %133
br i1 %134, label %135, label %137
135: ; preds = %128
%136 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
br label %137
137: ; preds = %135, %128
%138 = load i32*, i32** %6
%139 = call i32 @sqlite3_close_v2(i32* %138)
%140 = load i32, i32* @SQLITE_OK
%141 = icmp eq i32 %139, %140
br i1 %141, label %142, label %144
142: ; preds = %137
%143 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0))
br label %144
144: ; preds = %142, %137
%145 = call i32 (...) @sqlite3_shutdown()
%146 = load i32, i32* @EXIT_SUCCESS
store i32 %146, i32* %3
br label %147
147: ; preds = %144, %120, %109
%148 = load i32, i32* %3
ret i32 %148
}

LLVM IR (-O2):
@SQLITE_OPEN_READWRITE = global i32 0
@.str = [37 x i8] c"SELECT rowid FROM blobs WHERE id = 1\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Usage: %s <database> <filename>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@SQLITE_OK = global i32 0
@.str.3 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.4 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.5 = [43 x i8] c"Err. Unable to create Prepared Statement.\0A\00"
@.str.6 = [5 x i8] c"main\00"
@.str.7 = [6 x i8] c"blobs\00"
@.str.8 = [5 x i8] c"data\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [27 x i8] c"Err. Open file failed: %s\0A\00"
@errno = global i32 0
@.str.11 = [28 x i8] c"Err. Write file failed: %s\0A\00"
@.str.12 = [29 x i8] c"Written BLOB data into '%s'\0A\00"
@.str.13 = [34 x i8] c"... Prepared Statemend destroyed.\00"
@.str.14 = [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 = alloca i32*
%6 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%7 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%8 = bitcast i32** %5 to i8*
store i32* null, i32** %5
%9 = load i32, i32* @SQLITE_OPEN_READWRITE
%10 = icmp slt i32 %0, 3
br i1 %10, label %11, label %17
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 ([33 x i8], [33 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 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
%23 = select i1 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %21
%24 = tail call i32 (...) @sqlite3_initialize()
%25 = load i32, i32* @SQLITE_OK
%26 = icmp eq i32 %24, %25
br i1 %26, label %32, label %27
27: ; preds = %17
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %17
%33 = icmp eq i8* %19, null
%34 = select i1 %33, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %19
%35 = call i32 @sqlite3_open_v2(i8* %34, i32** %3, i32 %9, i32* null)
%36 = load i32, i32* @SQLITE_OK
%37 = icmp eq i32 %35, %36
br i1 %37, label %47, label %38
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = load i32*, i32** %3
%41 = call i8* @sqlite3_errmsg(i32* %40)
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = load i32*, i32** %3
%44 = call i32 @sqlite3_close(i32* %43)
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %32
%48 = load i32*, i32** %3
%49 = call i32 @sqlite3_prepare_v2(i32* %48, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%50 = load i32, i32* @SQLITE_OK
%51 = icmp eq i32 %49, %50
br i1 %51, label %57, label %52
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %47
%58 = load i32*, i32** %3
%59 = call i32 @sqlite3_blob_open(i32* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 1, i32 0, i32** %5)
%60 = load i32*, i32** %5
%61 = call i32 @sqlite3_blob_bytes(i32* %60)
%62 = call i8* @malloc(i32 %61)
%63 = load i32*, i32** %5
%64 = call i32 @sqlite3_blob_read(i32* %63, i8* %62, i32 %61, i32 0)
%65 = load i32*, i32** %5
%66 = call i32 @sqlite3_blob_close(i32* %65)
%67 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %74
69: ; preds = %57
%70 = load i32, i32* @stderr
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i8* %72)
br label %101
74: ; preds = %57
%75 = call i32 @fwrite(i8* %62, i32 %61, i32 1, i32* %67)
%76 = icmp eq i32 %75, 1
br i1 %76, label %82, label %77
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = load i32, i32* @errno
%80 = call i8* @strerror(i32 %79)
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %80)
br label %101
82: ; preds = %74
%83 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8* %23)
%84 = call i32 @fclose(i32* %67)
%85 = load i32*, i32** %4
%86 = call i32 @sqlite3_finalize(i32* %85)
%87 = load i32, i32* @SQLITE_OK
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0))
br label %91
91: ; preds = %89, %82
%92 = load i32*, i32** %3
%93 = call i32 @sqlite3_close_v2(i32* %92)
%94 = load i32, i32* @SQLITE_OK
%95 = icmp eq i32 %93, %94
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0))
br label %98
98: ; preds = %96, %91
%99 = call i32 (...) @sqlite3_shutdown()
%100 = load i32, i32* @EXIT_SUCCESS
br label %101
101: ; preds = %98, %77, %69
%102 = phi i32 [ 1, %69 ], [ 1, %77 ], [ %100, %98 ]
ret i32 %102
}