#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
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 /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_close_v2(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_initialize();
char *sqlite3_libversion();
int sqlite3_open_v2(char *, int /*<<< orphan*/ **, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_shutdown();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  sqlite3 *db = NULL;
  int res = 0;
  int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
  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));
    sqlite3_close(db);
    exit(EXIT_FAILURE);
  }
  printf("Library \'%s\' successfully initialized..\n", sqlite3_libversion());
  printf("Database \'%s\' successfully created.\n", argv[1]);
  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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    0x2e0b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1220 <main+0x70>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1030 <sqlite3_initialize@plt>
mov    0x2db2(%rip),%rcx
cmp    (%rcx),%eax
je     125b <main+0xab>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%edx
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10b0 <sqlite3_open_v2@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d60(%rip),%rcx
cmp    (%rcx),%eax
je     12c8 <main+0x118>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1040 <sqlite3_libversion@plt>
mov    %rax,%rsi
lea    0xd8a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd9f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <sqlite3_close_v2@plt>
mov    0x2cde(%rip),%rcx
cmp    (%rcx),%eax
jne    1316 <main+0x166>
lea    0xda0(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1070 <sqlite3_shutdown@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    126b <main+0xbb>
mov    0x2e04(%rip),%rax
mov    0x2e15(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
xor    %eax,%eax
call   1030 <sqlite3_initialize@plt>
mov    0x2df3(%rip),%r14
cmp    (%r14),%eax
jne    1287 <main+0xd7>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   10b0 <sqlite3_open_v2@plt>
cmp    (%r14),%eax
jne    12a0 <main+0xf0>
xor    %eax,%eax
call   1040 <sqlite3_libversion@plt>
lea    0xe44(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe5a(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   10d0 <sqlite3_close_v2@plt>
cmp    (%r14),%eax
jne    1252 <main+0xa2>
lea    0xe64(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <sqlite3_shutdown@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd82(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12d0 <main+0x120>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12d0 <main+0x120>
mov    0x2d21(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xd89(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   10a0 <sqlite3_close@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@SQLITE_OPEN_CREATE = global i32 0
@SQLITE_OPEN_READWRITE = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s <database name>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.1 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.2 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.3 = [41 x i8] c"Library '%s' successfully initialized..\0A\00"
@.str.4 = [37 x i8] c"Database '%s' successfully created.\0A\00"
@.str.5 = [27 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 0, i32* %7
%9 = load i32, i32* @SQLITE_OPEN_CREATE
%10 = load i32, i32* @SQLITE_OPEN_READWRITE
%11 = or i32 %9, %10
store i32 %11, i32* %8
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = call i32 (...) @sqlite3_initialize()
%24 = load i32, i32* @SQLITE_OK
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* %8
%36 = call i32 @sqlite3_open_v2(i8* %34, i32** %6, i32 %35, i32* null)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = load i32, i32* @SQLITE_OK
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %49
40: ; preds = %31
%41 = load i32, i32* @stderr
%42 = load i32*, i32** %6
%43 = call i8* @sqlite3_errmsg(i32* %42)
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %6
%46 = call i32 @sqlite3_close(i32* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %31
%50 = call i8* (...) @sqlite3_libversion()
%51 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %50)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%56 = load i32*, i32** %6
%57 = call i32 @sqlite3_close_v2(i32* %56)
%58 = load i32, i32* @SQLITE_OK
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %49
%61 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %49
%63 = call i32 (...) @sqlite3_shutdown()
%64 = load i32, i32* @EXIT_SUCCESS
ret i32 %64
}

LLVM IR (-O2):
@SQLITE_OPEN_CREATE = global i32 0
@SQLITE_OPEN_READWRITE = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s <database name>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.1 = [40 x i8] c"Err. Unable to initialize the library.\0A\00"
@.str.2 = [32 x i8] c"Err. can't create database: %s\0A\00"
@.str.3 = [41 x i8] c"Library '%s' successfully initialized..\0A\00"
@.str.4 = [37 x i8] c"Database '%s' successfully created.\0A\00"
@.str.5 = [27 x i8] c"Closed database connection\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%5 = load i32, i32* @SQLITE_OPEN_CREATE
%6 = load i32, i32* @SQLITE_OPEN_READWRITE
%7 = or i32 %6, %5
%8 = icmp eq i32 %0, 2
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = tail call i32 (...) @sqlite3_initialize()
%17 = load i32, i32* @SQLITE_OK
%18 = icmp eq i32 %16, %17
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @sqlite3_open_v2(i8* %26, i32** %3, i32 %7, i32* null)
%28 = load i32, i32* @SQLITE_OK
%29 = icmp eq i32 %27, %28
br i1 %29, label %39, label %30
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = load i32*, i32** %3
%33 = call i8* @sqlite3_errmsg(i32* %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32*, i32** %3
%36 = call i32 @sqlite3_close(i32* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %24
%40 = call i8* (...) @sqlite3_libversion()
%41 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %25
%43 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = load i32*, i32** %3
%45 = call i32 @sqlite3_close_v2(i32* %44)
%46 = load i32, i32* @SQLITE_OK
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %39
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %39
%51 = call i32 (...) @sqlite3_shutdown()
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}