#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 */
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ logs_to_file(char *, char *, int);
scalar_t__ sqlite3_close(int /*<<< orphan*/ *);
void db_close(sqlite3 *db_handle) {
  if (!db_handle) {
    logs_to_file(
        "[WARN] "
        "Trying to close un-initialized database."
        " (%s:%d)",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/Verii/tetris/refs/heads/master/src/db.c",
        46);
    return;
  }
  if (sqlite3_close(db_handle) != SQLITE_OK)
    logs_to_file(
        "[WARN] "
        "Database closed improperly."
        " (%s:%d)",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/Verii/tetris/refs/heads/master/src/db.c",
        51);
}


x86 assembly (clang, -O0):
<db_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1154 <db_close+0x34>
lea    0xec2(%rip),%rdi
lea    0xef3(%rip),%rsi
mov    $0x2e,%edx
call   1040 <logs_to_file@plt>
jmp    1185 <db_close+0x65>
mov    -0x8(%rbp),%rdi
call   1030 <sqlite3_close@plt>
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%rax
je     1185 <db_close+0x65>
lea    0xf46(%rip),%rdi
lea    0xebd(%rip),%rsi
mov    $0x33,%edx
call   1040 <logs_to_file@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_close>:
test   %rdi,%rdi
je     113d <db_close+0x1d>
push   %rax
call   1030 <sqlite3_close@plt>
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%rax
lea    0x8(%rsp),%rsp
jne    1155 <db_close+0x35>
ret
lea    0xebc(%rip),%rdi
lea    0xeed(%rip),%rsi
mov    $0x2e,%edx
jmp    1040 <logs_to_file@plt>
lea    0xf5e(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0x33,%edx
jmp    1040 <logs_to_file@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"[WARN] Trying to close un-initialized database. (%s:%d)\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Verii/tetris/refs/heads/master/src/db.c\00"
@SQLITE_OK = global i64 0
@.str.2 = [43 x i8] c"[WARN] Database closed improperly. (%s:%d)\00"
define void @db_close(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = icmp ne i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = call i32 @logs_to_file(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 46)
br label %14
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = call i64 @sqlite3_close(i32* %8)
%10 = load i64, i64* @SQLITE_OK
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @logs_to_file(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 51)
br label %14
14: ; preds = %5, %12, %7
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"[WARN] Trying to close un-initialized database. (%s:%d)\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Verii/tetris/refs/heads/master/src/db.c\00"
@SQLITE_OK = global i64 0
@.str.2 = [43 x i8] c"[WARN] Database closed improperly. (%s:%d)\00"
define void @db_close(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @logs_to_file(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 46)
br label %11
5: ; preds = %1
%6 = tail call i64 @sqlite3_close(i32* %0)
%7 = load i64, i64* @SQLITE_OK
%8 = icmp eq i64 %6, %7
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @logs_to_file(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 51)
br label %11
11: ; preds = %3, %9, %5
ret void
}