#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(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_open(int /*<<< orphan*/ *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
sqlite3 *connect_sqlite() {
  sqlite3 *db;
  int rc = 0;
  rc = sqlite3_open(NULL, &db);
  if (rc) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    exit(0);
  } else {
    fprintf(stderr, "Start Load SQLite3 database : Successfully\n");
  }
  return db;
}


x86 assembly (clang, -O0):
<connect_sqlite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1199 <connect_sqlite+0x59>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <sqlite3_errmsg@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_sqlite>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1030 <sqlite3_open@plt>
mov    0x2e88(%rip),%rcx
mov    (%rcx),%ebx
test   %eax,%eax
jne    1179 <connect_sqlite+0x39>
lea    0xeb4(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%rdi
call   1040 <sqlite3_errmsg@plt>
lea    0xe76(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Can't open database: %s\0A\00"
@.str.1 = [44 x i8] c"Start Load SQLite3 database : Successfully\0A\00"
define i32* @connect_sqlite() {
%1 = alloca i32*
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 @sqlite3_open(i32* null, i32** %1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32*, i32** %1
%9 = call i8* @sqlite3_errmsg(i32* %8)
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %12
%16 = load i32*, i32** %1
ret i32* %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Can't open database: %s\0A\00"
@.str.1 = [44 x i8] c"Start Load SQLite3 database : Successfully\0A\00"
define i32* @connect_sqlite() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
%3 = call i32 @sqlite3_open(i32* null, i32** %1)
%4 = icmp eq i32 %3, 0
%5 = load i32, i32* @stderr
br i1 %4, label %11, label %6
6: ; preds = %0
%7 = load i32*, i32** %1
%8 = call i8* @sqlite3_errmsg(i32* %7)
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %0
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32*, i32** %1
ret i32* %13
}