#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;

/* Variables and functions */
int SQLITE_DONE;
int /*<<< orphan*/ finishedStmt(int /*<<< orphan*/ *);
int /*<<< orphan*/ *getStmt(char *);
int /*<<< orphan*/ logMsg(int, char *, int);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
int sqlite3_step(int /*<<< orphan*/ *);
int addAlertInterval(int alertId, int intervalId) {
  sqlite3_stmt *stmtInsertAlertInterval = getStmt(
      "INSERT INTO alert_interval (alert_id, interval_id) VALUES (?,?);");
  sqlite3_bind_int(stmtInsertAlertInterval, 1, alertId);
  sqlite3_bind_int(stmtInsertAlertInterval, 2, intervalId);
  int rc = sqlite3_step(stmtInsertAlertInterval);
  finishedStmt(stmtInsertAlertInterval);
  if (rc != SQLITE_DONE) {
    logMsg(4, "stmtInsertAlertInterval failed: %d", rc);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<addAlertInterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe9b(%rip),%rdi
call   1060 <getStmt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1030 <sqlite3_bind_int@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x2,%esi
call   1030 <sqlite3_bind_int@plt>
mov    -0x18(%rbp),%rdi
call   1050 <sqlite3_step@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <finishedStmt@plt>
mov    -0x1c(%rbp),%eax
mov    0x2e31(%rip),%rcx
cmp    (%rcx),%eax
je     11d7 <addAlertInterval+0x87>
mov    -0x1c(%rbp),%edx
mov    $0x4,%edi
lea    0xe7b(%rip),%rsi
call   1040 <logMsg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11de <addAlertInterval+0x8e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addAlertInterval>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
lea    0xe9d(%rip),%rdi
call   1060 <getStmt@plt>
mov    %rax,%rbx
mov    $0x1,%r14d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r15d,%edx
call   1030 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1050 <sqlite3_step@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <finishedStmt@plt>
mov    0x2e37(%rip),%rax
cmp    (%rax),%ebp
je     11c3 <addAlertInterval+0x73>
lea    0xe8d(%rip),%rsi
mov    $0x4,%edi
mov    %ebp,%edx
call   1040 <logMsg@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"INSERT INTO alert_interval (alert_id, interval_id) VALUES (?,?);\00"
@SQLITE_DONE = global i32 0
@.str.1 = [35 x i8] c"stmtInsertAlertInterval failed: %d\00"
define i32 @addAlertInterval(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = call i32* @getStmt(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = load i32, i32* %4
%11 = call i32 @sqlite3_bind_int(i32* %9, i32 1, i32 %10)
%12 = load i32*, i32** %6
%13 = load i32, i32* %5
%14 = call i32 @sqlite3_bind_int(i32* %12, i32 2, i32 %13)
%15 = load i32*, i32** %6
%16 = call i32 @sqlite3_step(i32* %15)
store i32 %16, i32* %7
%17 = load i32*, i32** %6
%18 = call i32 @finishedStmt(i32* %17)
%19 = load i32, i32* %7
%20 = load i32, i32* @SQLITE_DONE
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* %7
%24 = call i32 @logMsg(i32 4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 0, i32* %3
br label %26
25: ; preds = %2
store i32 1, i32* %3
br label %26
26: ; preds = %25, %22
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [65 x i8] c"INSERT INTO alert_interval (alert_id, interval_id) VALUES (?,?);\00"
@SQLITE_DONE = global i32 0
@.str.1 = [35 x i8] c"stmtInsertAlertInterval failed: %d\00"
define i32 @addAlertInterval(i32 %0, i32 %1) {
%3 = tail call i32* @getStmt(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @sqlite3_bind_int(i32* %3, i32 1, i32 %0)
%5 = tail call i32 @sqlite3_bind_int(i32* %3, i32 2, i32 %1)
%6 = tail call i32 @sqlite3_step(i32* %3)
%7 = tail call i32 @finishedStmt(i32* %3)
%8 = load i32, i32* @SQLITE_DONE
%9 = icmp eq i32 %6, %8
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @logMsg(i32 4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %12
12: ; preds = %2, %10
%13 = phi i32 [ 0, %10 ], [ 1, %2 ]
ret i32 %13
}