#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*/ LOG_DEBUG;
int sqlite3_exec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ sqlite3_free(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *, int,
                          char *);
int beholddb_exec(sqlite3 *db, const char *sql) {
  char *err;
  int rc = sqlite3_exec(db, sql, NULL, NULL, &err);
  syslog(LOG_DEBUG, "beholddb_exec: sql=%s, rc=%d, err=%s", sql, rc,
         err ? err : "ok");
  sqlite3_free(err);
  return rc;
}


x86 assembly (clang, -O0):
<beholddb_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rdx
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118d <beholddb_exec+0x5d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    119d <beholddb_exec+0x6d>
lea    0xe91(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    119d <beholddb_exec+0x6d>
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%r8
lea    0xe4e(%rip),%rsi
call   1040 <syslog@plt>
mov    -0x18(%rbp),%rdi
call   1050 <sqlite3_free@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beholddb_exec>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rsp,%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    %eax,%ebp
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
test   %rax,%rax
lea    0xeca(%rip),%r8
cmovne %rax,%r8
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1040 <syslog@plt>
mov    (%rsp),%rdi
call   1050 <sqlite3_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@LOG_DEBUG = global i32 0
@.str = [37 x i8] c"beholddb_exec: sql=%s, rc=%d, err=%s\00"
@.str.1 = [3 x i8] c"ok\00"
define i32 @beholddb_exec(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%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_exec(i32* %7, i8* %8, i32* null, i32* null, i8** %5)
store i32 %9, i32* %6
%10 = load i32, i32* @LOG_DEBUG
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i8*, i8** %5
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %15
%19 = phi i8* [ %16, %15 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %17 ]
%20 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12, i8* %19)
%21 = load i8*, i8** %5
%22 = call i32 @sqlite3_free(i8* %21)
%23 = load i32, i32* %6
ret i32 %23
}

LLVM IR (-O2):
@LOG_DEBUG = global i32 0
@.str = [37 x i8] c"beholddb_exec: sql=%s, rc=%d, err=%s\00"
@.str.1 = [3 x i8] c"ok\00"
define i32 @beholddb_exec(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @sqlite3_exec(i32* %0, i8* %1, i32* null, i32* null, i8** %3)
%6 = load i32, i32* @LOG_DEBUG
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
%9 = select i1 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7
%10 = call i32 @syslog(i32 %6, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %5, i8* %9)
%11 = load i8*, i8** %3
%12 = call i32 @sqlite3_free(i8* %11)
ret i32 %5
}