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

/* Variables and functions */
int SQLITE_DONE;
int SQLITE_OK;
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_prepare_v2(int /*<<< orphan*/ *, char const *, int,
                                      int /*<<< orphan*/ **,
                                      int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int db_transaction(sqlite3 *db, const char *sql) {
  sqlite3_stmt *stmt;
  sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
  int err = sqlite3_step(stmt);
  sqlite3_finalize(stmt);
  return (err == SQLITE_DONE) ? SQLITE_OK : err;
}


x86 assembly (clang, -O0):
<db_transaction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <sqlite3_prepare_v2@plt>
mov    -0x18(%rbp),%rdi
call   1030 <sqlite3_step@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sqlite3_finalize@plt>
mov    -0x1c(%rbp),%eax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%eax
jne    1193 <db_transaction+0x63>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    1199 <db_transaction+0x69>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_transaction>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1050 <sqlite3_prepare_v2@plt>
mov    0x8(%rsp),%rdi
call   1030 <sqlite3_step@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1040 <sqlite3_finalize@plt>
mov    0x2e74(%rip),%rax
cmp    (%rax),%ebx
jne    1171 <db_transaction+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SQLITE_DONE = global i32 0
@SQLITE_OK = global i32 0
define i32 @db_transaction(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i32*, i32** %3
%8 = load i8*, i8** %4
%9 = call i32 @sqlite3_prepare_v2(i32* %7, i8* %8, i32 -1, i32** %5, i32* null)
%10 = load i32*, i32** %5
%11 = call i32 @sqlite3_step(i32* %10)
store i32 %11, i32* %6
%12 = load i32*, i32** %5
%13 = call i32 @sqlite3_finalize(i32* %12)
%14 = load i32, i32* %6
%15 = load i32, i32* @SQLITE_DONE
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* @SQLITE_OK
br label %21
19: ; preds = %2
%20 = load i32, i32* %6
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
ret i32 %22
}

LLVM IR (-O2):
@SQLITE_DONE = global i32 0
@SQLITE_OK = global i32 0
define i32 @db_transaction(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
%5 = call i32 @sqlite3_prepare_v2(i32* %0, i8* %1, i32 -1, i32** %3, i32* null)
%6 = load i32*, i32** %3
%7 = call i32 @sqlite3_step(i32* %6)
%8 = load i32*, i32** %3
%9 = call i32 @sqlite3_finalize(i32* %8)
%10 = load i32, i32* @SQLITE_DONE
%11 = icmp eq i32 %7, %10
%12 = load i32, i32* @SQLITE_OK
%13 = select i1 %11, i32 %12, i32 %7
ret i32 %13
}