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

/* Variables and functions */
int EXIT_FAILURE;
int SQLITE_OK;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ load_words(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_open(char const *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
int main(int argc, const char *argv[]) {
  int ret = 0;
  sqlite3 *db;
  FILE *fp;
  if (argc < 3) {
    fprintf(stderr, "Usage : %s <db> <dict>\n", argv[0]);
    ret = EXIT_FAILURE;
    goto exit;
  }
  ret = sqlite3_open(argv[1], &db);
  if (ret != SQLITE_OK) {
    fprintf(stderr, "Sqlite database open %s fail : %s\n", argv[1],
            sqlite3_errmsg(db));
    ret = EXIT_FAILURE;
    goto exit;
  }
  fp = fopen(argv[2], "r");
  if (NULL == fp) {
    perror("Fail to fopen");
    ret = EXIT_FAILURE;
    goto exit;
  }
  load_words(db, fp);
exit:
  fclose(fp);
  sqlite3_close(db);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d6 <main+0x56>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1294 <main+0x114>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2df4(%rip),%rcx
cmp    (%rcx),%eax
je     1246 <main+0xc6>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1294 <main+0x114>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde6(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    1287 <main+0x107>
lea    0xdcc(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1294 <main+0x114>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <load_words@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1070 <sqlite3_close@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    11f9 <main+0x79>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,%ebp
mov    0x2e48(%rip),%rax
cmp    (%rax),%ebp
jne    1213 <main+0x93>
mov    0x10(%rbx),%rdi
lea    0xe8c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11e2 <main+0x62>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1080 <load_words@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rdi
call   1070 <sqlite3_close@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe54(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%ebp
jmp    11c8 <main+0x48>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf4(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    (%rsp),%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xde8(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage : %s <db> <dict>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.1 = [35 x i8] c"Sqlite database open %s fail : %s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [14 x i8] c"Fail to fopen\00"
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 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %6
br label %49
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @sqlite3_open(i8* %21, i32** %7)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = load i32, i32* @SQLITE_OK
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %18
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i32*, i32** %7
%32 = call i8* @sqlite3_errmsg(i32* %31)
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %6
br label %49
35: ; preds = %18
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %39, i32** %8
%40 = load i32*, i32** %8
%41 = icmp eq i32* null, %40
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
store i32 %44, i32* %6
br label %49
45: ; preds = %35
%46 = load i32*, i32** %7
%47 = load i32*, i32** %8
%48 = call i32 @load_words(i32* %46, i32* %47)
br label %49
49: ; preds = %45, %42, %26, %11
%50 = load i32*, i32** %8
%51 = call i32 @fclose(i32* %50)
%52 = load i32*, i32** %7
%53 = call i32 @sqlite3_close(i32* %52)
%54 = load i32, i32* %6
ret i32 %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage : %s <db> <dict>\0A\00"
@EXIT_FAILURE = global i32 0
@SQLITE_OK = global i32 0
@.str.1 = [35 x i8] c"Sqlite database open %s fail : %s\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [14 x i8] c"Fail to fopen\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sqlite3_open(i8* %12, i32** %3)
%14 = load i32, i32* @SQLITE_OK
%15 = icmp eq i32 %13, %14
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %11
%19 = load i32*, i32** %3
%20 = call i8* @sqlite3_errmsg(i32* %19)
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20)
unreachable
22: ; preds = %10
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
br label %33
30: ; preds = %22
%31 = load i32*, i32** %3
%32 = call i32 @load_words(i32* %31, i32* %25)
br label %33
33: ; preds = %30, %27
%34 = phi i32 [ %29, %27 ], [ %13, %30 ]
%35 = call i32 @fclose(i32* %25)
%36 = load i32*, i32** %3
%37 = call i32 @sqlite3_close(i32* %36)
ret i32 %34
}