#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*/ printf(char *, int, char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errstr(int);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int main(int argc, char *argv[]) {
  sqlite3 *db = NULL;
  int rc = sqlite3_open("MyFirstSQLiteDB.db", &db);
  if (rc != 0) {
    printf("Error creating database handle (return code: %d, %s)\n", rc,
           sqlite3_errstr(rc));
  }
  sqlite3_close(db);
  return 0;
}


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)
movq   $0x0,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     119b <main+0x5b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <sqlite3_errstr@plt>
mov    -0x20(%rbp),%esi
mov    %rax,%rdx
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeab(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <sqlite3_open@plt>
test   %eax,%eax
je     117d <main+0x3d>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <sqlite3_errstr@plt>
lea    0xea0(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1050 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"MyFirstSQLiteDB.db\00"
@.str.1 = [54 x i8] c"Error creating database handle (return code: %d, %s)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%8 = call i32 @sqlite3_open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32** %6)
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* %7
%13 = load i32, i32* %7
%14 = call i8* @sqlite3_errstr(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %14)
br label %16
16: ; preds = %11, %2
%17 = load i32*, i32** %6
%18 = call i32 @sqlite3_close(i32* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"MyFirstSQLiteDB.db\00"
@.str.1 = [54 x i8] c"Error creating database handle (return code: %d, %s)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%5 = call i32 @sqlite3_open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32** %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i8* @sqlite3_errstr(i32 %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %5, i8* %8)
br label %10
10: ; preds = %7, %2
%11 = load i32*, i32** %3
%12 = call i32 @sqlite3_close(i32* %11)
ret i32 0
}