#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 SQLITE_OPEN_CREATE;
int SQLITE_OPEN_READWRITE;
int /*<<< orphan*/ executeSqlFile(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ executeSqlStmt(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printStatistics(int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_demovfs();
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_open_v2(char *, int /*<<< orphan*/ **, int, char *);
int /*<<< orphan*/ sqlite3_scmvfs();
int /*<<< orphan*/ sqlite3_vfs_register(int /*<<< orphan*/, int);
int /*<<< orphan*/ sqlite3_wrap_vfs();
int /*<<< orphan*/ startStatistics();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  sqlite3 *db;
  char vfs[256];
  if (strcmp(argv[1], "scm") == 0) {
    strcpy(vfs, "scm");
    sqlite3_vfs_register(sqlite3_scmvfs(), 1);
  } else if (strcmp(argv[1], "wrap") == 0) {
    strcpy(vfs, "wrap_vfs");
    sqlite3_vfs_register(sqlite3_wrap_vfs(), 1);
  } else {
    strcpy(vfs, "demo");
    sqlite3_vfs_register(sqlite3_demovfs(), 1);
  }
  startStatistics();
  int rc = sqlite3_open_v2(argv[1], &db,
                           SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, vfs);
  if (rc) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    exit(0);
  } else {
    fprintf(stdout, "Opened database successfully\n");
  }
  if (strcmp(argv[1], "wrap") == 0)
    executeSqlStmt(db, "PRAGMA journal_mode = OFF;\n", -1);
  executeSqlFile(db, argv[2]);
  executeSqlFile(db, argv[3]);
  executeSqlFile(db, argv[4]);
  printStatistics(stdout);
  sqlite3_close(db);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <main+0x62>
lea    -0x120(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x0,%al
call   1110 <sqlite3_scmvfs@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <sqlite3_vfs_register@plt>
jmp    12c6 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xda3(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    129b <main+0xab>
lea    -0x120(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x0,%al
call   1050 <sqlite3_wrap_vfs@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <sqlite3_vfs_register@plt>
jmp    12c1 <main+0xd1>
lea    -0x120(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x0,%al
call   1100 <sqlite3_demovfs@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <sqlite3_vfs_register@plt>
jmp    12c6 <main+0xd6>
mov    $0x0,%al
call   10a0 <startStatistics@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d14(%rip),%rax
mov    (%rax),%edx
mov    0x2cfb(%rip),%rax
or     (%rax),%edx
lea    -0x120(%rbp),%rcx
lea    -0x18(%rbp),%rsi
call   10e0 <sqlite3_open_v2@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     1340 <main+0x150>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x128(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <sqlite3_errmsg@plt>
mov    -0x128(%rbp),%edi
mov    %rax,%rdx
lea    0xce5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc9e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    138a <main+0x19a>
mov    -0x18(%rbp),%rdi
lea    0xcce(%rip),%rsi
mov    $0xffffffff,%edx
call   10c0 <executeSqlStmt@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <executeSqlFile@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <executeSqlFile@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1060 <executeSqlFile@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
call   10d0 <printStatistics@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xdf8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1241 <main+0x51>
mov    0x8(%rbx),%rdi
lea    0xde7(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     125b <main+0x6b>
lea    0xde4(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   1100 <sqlite3_demovfs@plt>
jmp    1273 <main+0x83>
lea    0xdb8(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   1110 <sqlite3_scmvfs@plt>
jmp    1273 <main+0x83>
lea    0xda7(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   1050 <sqlite3_wrap_vfs@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <sqlite3_vfs_register@plt>
xor    %eax,%eax
call   10a0 <startStatistics@plt>
mov    0x8(%rbx),%rdi
mov    0x2d5f(%rip),%rax
mov    0x2d48(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rcx
call   10e0 <sqlite3_open_v2@plt>
test   %eax,%eax
jne    133f <main+0x14f>
mov    0x2d0e(%rip),%r14
mov    (%r14),%edi
lea    0xd6c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x8(%rbx),%rdi
lea    0xd2e(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12f6 <main+0x106>
mov    0x8(%rsp),%rdi
lea    0xd62(%rip),%rsi
mov    $0xffffffff,%edx
call   10c0 <executeSqlStmt@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rbx),%rsi
call   1060 <executeSqlFile@plt>
mov    0x8(%rsp),%rdi
mov    0x18(%rbx),%rsi
call   1060 <executeSqlFile@plt>
mov    0x8(%rsp),%rdi
mov    0x20(%rbx),%rsi
call   1060 <executeSqlFile@plt>
mov    (%r14),%edi
call   10d0 <printStatistics@plt>
mov    0x8(%rsp),%rdi
call   10b0 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2c8a(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1070 <sqlite3_errmsg@plt>
lea    0xcbe(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"scm\00"
@.str.1 = [5 x i8] c"wrap\00"
@.str.2 = [9 x i8] c"wrap_vfs\00"
@.str.3 = [5 x i8] c"demo\00"
@SQLITE_OPEN_READWRITE = global i32 0
@SQLITE_OPEN_CREATE = global i32 0
@stderr = global i32 0
@.str.4 = [25 x i8] c"Can't open database: %s\0A\00"
@stdout = global i32 0
@.str.5 = [30 x i8] c"Opened database successfully\0A\00"
@.str.6 = [28 x i8] c"PRAGMA journal_mode = OFF;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @sqlite3_scmvfs()
%18 = call i32 @sqlite3_vfs_register(i32 %17, i32 1)
br label %36
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %19
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (...) @sqlite3_wrap_vfs()
%29 = call i32 @sqlite3_vfs_register(i32 %28, i32 1)
br label %35
30: ; preds = %19
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (...) @sqlite3_demovfs()
%34 = call i32 @sqlite3_vfs_register(i32 %33, i32 1)
br label %35
35: ; preds = %30, %25
br label %36
36: ; preds = %35, %14
%37 = call i32 (...) @startStatistics()
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i32, i32* @SQLITE_OPEN_READWRITE
%42 = load i32, i32* @SQLITE_OPEN_CREATE
%43 = or i32 %41, %42
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%45 = call i32 @sqlite3_open_v2(i8* %40, i32** %6, i32 %43, i8* %44)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %36
%49 = load i32, i32* @stderr
%50 = load i32*, i32** %6
%51 = call i8* @sqlite3_errmsg(i32* %50)
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %51)
%53 = call i32 @exit(i32 0)
unreachable
54: ; preds = %36
%55 = load i32, i32* @stdout
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %54
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %57
%64 = load i32*, i32** %6
%65 = call i32 @executeSqlStmt(i32* %64, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 -1)
br label %66
66: ; preds = %63, %57
%67 = load i32*, i32** %6
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 @executeSqlFile(i32* %67, i8* %70)
%72 = load i32*, i32** %6
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 3
%75 = load i8*, i8** %74
%76 = call i32 @executeSqlFile(i32* %72, i8* %75)
%77 = load i32*, i32** %6
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 4
%80 = load i8*, i8** %79
%81 = call i32 @executeSqlFile(i32* %77, i8* %80)
%82 = load i32, i32* @stdout
%83 = call i32 @printStatistics(i32 %82)
%84 = load i32*, i32** %6
%85 = call i32 @sqlite3_close(i32* %84)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"scm\00"
@.str.1 = [5 x i8] c"wrap\00"
@.str.2 = [9 x i8] c"wrap_vfs\00"
@.str.3 = [5 x i8] c"demo\00"
@SQLITE_OPEN_READWRITE = global i32 0
@SQLITE_OPEN_CREATE = global i32 0
@stderr = global i32 0
@.str.4 = [25 x i8] c"Can't open database: %s\0A\00"
@stdout = global i32 0
@.str.5 = [30 x i8] c"Opened database successfully\0A\00"
@.str.6 = [28 x i8] c"PRAGMA journal_mode = OFF;\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca [256 x i8]
%5 = bitcast i32** %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @sqlite3_scmvfs()
br label %24
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @sqlite3_wrap_vfs()
br label %24
21: ; preds = %14
%22 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (...) @sqlite3_demovfs()
br label %24
24: ; preds = %18, %21, %11
%25 = phi i32 [ %20, %18 ], [ %23, %21 ], [ %13, %11 ]
%26 = call i32 @sqlite3_vfs_register(i32 %25, i32 1)
%27 = call i32 (...) @startStatistics()
%28 = load i8*, i8** %7
%29 = load i32, i32* @SQLITE_OPEN_READWRITE
%30 = load i32, i32* @SQLITE_OPEN_CREATE
%31 = or i32 %30, %29
%32 = call i32 @sqlite3_open_v2(i8* %28, i32** %3, i32 %31, i8* %6)
%33 = icmp eq i32 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %24
%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 ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %24
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%43 = load i8*, i8** %7
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load i32*, i32** %3
%48 = call i32 @executeSqlStmt(i32* %47, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 -1)
br label %49
49: ; preds = %46, %40
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @executeSqlFile(i32* %50, i8* %52)
%54 = load i32*, i32** %3
%55 = getelementptr inbounds i8*, i8** %1, i64 3
%56 = load i8*, i8** %55
%57 = call i32 @executeSqlFile(i32* %54, i8* %56)
%58 = load i32*, i32** %3
%59 = getelementptr inbounds i8*, i8** %1, i64 4
%60 = load i8*, i8** %59
%61 = call i32 @executeSqlFile(i32* %58, i8* %60)
%62 = load i32, i32* @stdout
%63 = call i32 @printStatistics(i32 %62)
%64 = load i32*, i32** %3
%65 = call i32 @sqlite3_close(i32* %64)
ret i32 0
}