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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           char *);
int sqlite3_exec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ stderr;
void database_sql_exec(sqlite3 *db, const char *sql, sqlite3_callback callback,
                       int this_too) {
  int result;
  char *errmsg;
  result = sqlite3_exec(db, sql, callback, NULL, &errmsg);
  if ((result != 0) && (result != this_too)) {
    fprintf(stderr, "sqlite3_exec(\"%s\"): (%d) %s\n", sql, result, errmsg);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<database_sql_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x28(%rbp),%r8
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11a5 <database_sql_exec+0x75>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11a5 <database_sql_exec+0x75>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_sql_exec>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %rsp,%r8
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
test   %eax,%eax
je     114a <database_sql_exec+0x1a>
cmp    %ebp,%eax
jne    1151 <database_sql_exec+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e88(%rip),%rcx
mov    (%rcx),%edi
mov    (%rsp),%r8
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"sqlite3_exec(\22%s\22): (%d) %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @database_sql_exec(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32*, i32** %5
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @sqlite3_exec(i32* %11, i8* %12, i32 %13, i32* null, i8** %10)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %4
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %6
%24 = load i32, i32* %9
%25 = load i8*, i8** %10
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %24, i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %17, %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"sqlite3_exec(\22%s\22): (%d) %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @database_sql_exec(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i32 @sqlite3_exec(i32* %0, i8* %1, i32 %2, i32* null, i8** %5)
%8 = icmp eq i32 %7, 0
%9 = icmp eq i32 %7, %3
%10 = or i1 %8, %9
br i1 %10, label %17, label %11
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %5
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %7, i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %4
ret void
}