#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 /*<<< orphan*/ LOG_DEBUG;
int SQLITE_DONE;
int SQLITE_OK;
int /*<<< orphan*/ SQLITE_STATIC;
int sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *, int,
                      int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_errmsg(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char const *, int,
                       int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *,
                          char const *, int, int /*<<< orphan*/);
int beholddb_exec_bind_text(sqlite3 *db, const char *sql, const char *text) {
  sqlite3_stmt *stmt;
  int rc;
  (rc = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL)) ||
      (rc = sqlite3_bind_text(stmt, 1, text, -1, SQLITE_STATIC)) ||
      SQLITE_DONE != (rc = sqlite3_step(stmt)) || (rc = SQLITE_OK);
  syslog(LOG_DEBUG, "beholddb_exec_bind_text: sql=%s, text=%s, rc=%d, err=%s",
         sql, text, rc, sqlite3_errmsg(db));
  sqlite3_finalize(stmt);
  return rc;
}


x86 assembly (clang, -O0):
<beholddb_exec_bind_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1080 <sqlite3_prepare_v2@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
jne    1215 <beholddb_exec_bind_text+0xb5>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2e27(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    $0xffffffff,%ecx
call   1060 <sqlite3_bind_text@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
jne    1215 <beholddb_exec_bind_text+0xb5>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <sqlite3_step@plt>
mov    -0x2c(%rbp),%ecx
mov    %eax,%edx
mov    %edx,-0x24(%rbp)
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x25(%rbp)
jne    1215 <beholddb_exec_bind_text+0xb5>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <sqlite3_errmsg@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8d
mov    %eax,%r9d
lea    0xda4(%rip),%rsi
call   1050 <syslog@plt>
mov    -0x20(%rbp),%rdi
call   1070 <sqlite3_finalize@plt>
mov    -0x24(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beholddb_exec_bind_text>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1080 <sqlite3_prepare_v2@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11d6 <beholddb_exec_bind_text+0x76>
mov    0x8(%rsp),%rdi
mov    0x2e3f(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1060 <sqlite3_bind_text@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11d6 <beholddb_exec_bind_text+0x76>
mov    0x2e15(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1040 <sqlite3_step@plt>
mov    %eax,%ebp
cmp    %eax,%ebx
jne    11d6 <beholddb_exec_bind_text+0x76>
mov    0x2e14(%rip),%rax
mov    (%rax),%ebp
mov    0x2deb(%rip),%rax
mov    (%rax),%ebx
mov    %r12,%rdi
call   1030 <sqlite3_errmsg@plt>
lea    0xe12(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1050 <syslog@plt>
mov    0x8(%rsp),%rdi
call   1070 <sqlite3_finalize@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SQLITE_STATIC = global i32 0
@SQLITE_DONE = global i32 0
@SQLITE_OK = global i32 0
@LOG_DEBUG = global i32 0
@.str = [56 x i8] c"beholddb_exec_bind_text: sql=%s, text=%s, rc=%d, err=%s\00"
define i32 @beholddb_exec_bind_text(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i32*, i32** %4
%10 = load i8*, i8** %5
%11 = call i32 @sqlite3_prepare_v2(i32* %9, i8* %10, i32 -1, i32** %7, i32* null)
store i32 %11, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %3
%14 = load i32*, i32** %7
%15 = load i8*, i8** %6
%16 = load i32, i32* @SQLITE_STATIC
%17 = call i32 @sqlite3_bind_text(i32* %14, i32 1, i8* %15, i32 -1, i32 %16)
store i32 %17, i32* %8
%18 = icmp ne i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %13
%20 = load i32, i32* @SQLITE_DONE
%21 = load i32*, i32** %7
%22 = call i32 @sqlite3_step(i32* %21)
store i32 %22, i32* %8
%23 = icmp ne i32 %20, %22
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = load i32, i32* @SQLITE_OK
store i32 %25, i32* %8
%26 = icmp ne i32 %25, 0
br label %27
27: ; preds = %24, %19, %13, %3
%28 = phi i1 [ true, %19 ], [ true, %13 ], [ true, %3 ], [ %26, %24 ]
%29 = zext i1 %28 to i32
%30 = load i32, i32* @LOG_DEBUG
%31 = load i8*, i8** %5
%32 = load i8*, i8** %6
%33 = load i32, i32* %8
%34 = load i32*, i32** %4
%35 = call i32 @sqlite3_errmsg(i32* %34)
%36 = call i32 @syslog(i32 %30, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %32, i32 %33, i32 %35)
%37 = load i32*, i32** %7
%38 = call i32 @sqlite3_finalize(i32* %37)
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
@SQLITE_STATIC = global i32 0
@SQLITE_DONE = global i32 0
@SQLITE_OK = global i32 0
@LOG_DEBUG = global i32 0
@.str = [56 x i8] c"beholddb_exec_bind_text: sql=%s, text=%s, rc=%d, err=%s\00"
define i32 @beholddb_exec_bind_text(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = bitcast i32** %4 to i8*
%6 = call i32 @sqlite3_prepare_v2(i32* %0, i8* %1, i32 -1, i32** %4, i32* null)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = load i32*, i32** %4
%10 = load i32, i32* @SQLITE_STATIC
%11 = call i32 @sqlite3_bind_text(i32* %9, i32 1, i8* %2, i32 -1, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* @SQLITE_DONE
%15 = load i32*, i32** %4
%16 = call i32 @sqlite3_step(i32* %15)
%17 = icmp eq i32 %14, %16
%18 = load i32, i32* @SQLITE_OK
%19 = select i1 %17, i32 %18, i32 %16
br label %20
20: ; preds = %13, %8, %3
%21 = phi i32 [ %6, %3 ], [ %11, %8 ], [ %19, %13 ]
%22 = load i32, i32* @LOG_DEBUG
%23 = call i32 @sqlite3_errmsg(i32* %0)
%24 = call i32 @syslog(i32 %22, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32 %21, i32 %23)
%25 = load i32*, i32** %4
%26 = call i32 @sqlite3_finalize(i32* %25)
ret i32 %21
}