#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*/ SQLITE_STATIC;
int sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *, int,
                      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 beholddb_set_param(sqlite3 *db, const char *param, const char *value) {
  int rc;
  sqlite3_stmt *stmt;
  const char *sql = "insert into config ( param, value ) values ( ?, ? )";
  (rc = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL)) ||
      (rc = sqlite3_bind_text(stmt, 1, param, -1, SQLITE_STATIC)) ||
      (rc = sqlite3_bind_text(stmt, 2, value, -1, SQLITE_STATIC)) ||
      (rc = sqlite3_step(stmt));
  sqlite3_finalize(stmt);
  return rc ? -1 : 0;
}


x86 assembly (clang, -O0):
<beholddb_set_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x28(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <sqlite3_prepare_v2@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    120a <beholddb_set_param+0xca>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    0x2e44(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    $0xffffffff,%ecx
call   1040 <sqlite3_bind_text@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    120a <beholddb_set_param+0xca>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2e10(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
mov    $0xffffffff,%ecx
call   1040 <sqlite3_bind_text@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    120a <beholddb_set_param+0xca>
mov    -0x28(%rbp),%rdi
call   1030 <sqlite3_step@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
mov    -0x28(%rbp),%rdi
call   1050 <sqlite3_finalize@plt>
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beholddb_set_param>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xeac(%rip),%rsi
mov    %rsp,%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1060 <sqlite3_prepare_v2@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11ba <beholddb_set_param+0x7a>
mov    (%rsp),%rdi
mov    0x2e6b(%rip),%r15
mov    (%r15),%r8d
mov    $0x1,%esi
mov    %rbx,%rdx
mov    $0xffffffff,%ecx
call   1040 <sqlite3_bind_text@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11ba <beholddb_set_param+0x7a>
mov    (%rsp),%rdi
mov    (%r15),%r8d
mov    $0x2,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1040 <sqlite3_bind_text@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    11ba <beholddb_set_param+0x7a>
mov    (%rsp),%rdi
call   1030 <sqlite3_step@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1050 <sqlite3_finalize@plt>
neg    %ebp
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"insert into config ( param, value ) values ( ?, ? )\00"
@SQLITE_STATIC = global i32 0
define i32 @beholddb_set_param(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i32*, i32** %4
%11 = load i8*, i8** %9
%12 = call i32 @sqlite3_prepare_v2(i32* %10, i8* %11, i32 -1, i32** %8, i32* null)
store i32 %12, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %3
%15 = load i32*, i32** %8
%16 = load i8*, i8** %5
%17 = load i32, i32* @SQLITE_STATIC
%18 = call i32 @sqlite3_bind_text(i32* %15, i32 1, i8* %16, i32 -1, i32 %17)
store i32 %18, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %14
%21 = load i32*, i32** %8
%22 = load i8*, i8** %6
%23 = load i32, i32* @SQLITE_STATIC
%24 = call i32 @sqlite3_bind_text(i32* %21, i32 2, i8* %22, i32 -1, i32 %23)
store i32 %24, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = load i32*, i32** %8
%28 = call i32 @sqlite3_step(i32* %27)
store i32 %28, i32* %7
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %26, %20, %14, %3
%31 = phi i1 [ true, %20 ], [ true, %14 ], [ true, %3 ], [ %29, %26 ]
%32 = zext i1 %31 to i32
%33 = load i32*, i32** %8
%34 = call i32 @sqlite3_finalize(i32* %33)
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 -1, i32 0
ret i32 %38
}

LLVM IR (-O2):
@.str = [52 x i8] c"insert into config ( param, value ) values ( ?, ? )\00"
@SQLITE_STATIC = global i32 0
define i32 @beholddb_set_param(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = bitcast i32** %4 to i8*
%6 = call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %21
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* %1, i32 -1, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i32*, i32** %4
%15 = load i32, i32* @SQLITE_STATIC
%16 = call i32 @sqlite3_bind_text(i32* %14, i32 2, i8* %2, i32 -1, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = call i32 @sqlite3_step(i32* %19)
br label %21
21: ; preds = %18, %13, %8, %3
%22 = phi i32 [ %6, %3 ], [ %11, %8 ], [ %16, %13 ], [ %20, %18 ]
%23 = load i32*, i32** %4
%24 = call i32 @sqlite3_finalize(i32* %23)
%25 = icmp ne i32 %22, 0
%26 = sext i1 %25 to i32
ret i32 %26
}