#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ app_loop(int /*<<< orphan*/ *);
int /*<<< orphan*/ close_db(int /*<<< orphan*/ *);
int /*<<< orphan*/ configure_db(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *init_db(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  sqlite3 *db;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s db_filename", argv[0]);
    return EXIT_FAILURE;
  }
  if ((db = init_db(argv[1])) == NULL) {
    return EXIT_FAILURE;
  }
  configure_db(db);
  app_loop(db);
  close_db(db);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119d <main+0x4d>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f0 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <init_db@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c9 <main+0x79>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f0 <main+0xa0>
mov    -0x18(%rbp),%rdi
call   1040 <configure_db@plt>
mov    -0x18(%rbp),%rdi
call   1060 <app_loop@plt>
mov    -0x18(%rbp),%rdi
call   1070 <close_db@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1188 <main+0x38>
mov    0x8(%rsi),%rdi
call   1050 <init_db@plt>
test   %rax,%rax
je     11a0 <main+0x50>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <configure_db@plt>
mov    %rbx,%rdi
call   1060 <app_loop@plt>
mov    %rbx,%rdi
call   1070 <close_db@plt>
mov    0x2e4a(%rip),%rax
jmp    11a7 <main+0x57>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe65(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s db_filename\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @init_db(i8* %19)
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %32
24: ; preds = %16
%25 = load i32*, i32** %6
%26 = call i32 @configure_db(i32* %25)
%27 = load i32*, i32** %6
%28 = call i32 @app_loop(i32* %27)
%29 = load i32*, i32** %6
%30 = call i32 @close_db(i32* %29)
%31 = load i32, i32* @EXIT_SUCCESS
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %22, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s db_filename\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %17
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @init_db(i8* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call i32 @configure_db(i32* %11)
%15 = tail call i32 @app_loop(i32* %11)
%16 = tail call i32 @close_db(i32* %11)
br label %17
17: ; preds = %8, %13, %4
%18 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %13 ], [ @EXIT_FAILURE, %8 ]
%19 = load i32, i32* %18
ret i32 %19
}