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

/* Variables and functions */
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_ERR;
int SQLITE_DONE;
int SQLITE_OK;
int SQLITE_ROW;
int evaluate_stmt_string(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *,
                           char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_errmsg(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       char const **);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *, ...);
int check_entry_string(char *number, int priority, int listflag) {
  char *listname = (0x02 == listflag) ? "whitelist" : "blacklist";
  sqlite3 *db;
  char stmt[1024];
  sqlite3_stmt *pp_stmt = 0;
  const char **p_tail = 0;
  int rc;
  int found_flag = 0;
  rc = sqlite3_open("db/phonefirewall.db", &db);
  if (rc) {
    syslog(LOG_ERR, "[%s] Can't open database: %s", "phone-firewall",
           sqlite3_errmsg(db));
    sqlite3_close(db);
    return -1;
  }
  sprintf(
      stmt,
      "SELECT %1$s, %2$s, %3$s, %4$s FROM %5$s ORDER BY %1$s, %2$s, %3$s, %4$s",
      "priority", "countrycode", "areacode", "number", listname);
  rc = sqlite3_prepare_v2(db, stmt, sizeof(stmt), &pp_stmt, p_tail);
  if (rc != SQLITE_OK) {
    syslog(LOG_ERR, "[%s] SQL error: %s", "phone-firewall", sqlite3_errmsg(db));
    sqlite3_close(db);
    return -1;
  }
  while (rc != SQLITE_DONE) {
    rc = sqlite3_step(pp_stmt);
    if (SQLITE_ROW == rc) {
      found_flag = evaluate_stmt_string(pp_stmt, number, priority);
      if (found_flag == 1) {
        switch (listflag) {
        case 0x02:
          syslog(LOG_DEBUG, "[%s] Number \"%s\" accepted successfully.",
                 "phone-firewall", number);
          break;
        case 0x01:
          syslog(LOG_DEBUG, "[%s] Number \"%s\" blocked successfully.",
                 "phone-firewall", number);
          break;
        default:
          syslog(LOG_CRIT, "[%s] Stuff is no blacklist nor a whitelist.",
                 "phone-firewall");
        }
        break;
      }
    }
  }
  sqlite3_finalize(pp_stmt);
  sqlite3_close(db);
  return found_flag;
}


x86 assembly (clang, -O0):
<check_entry_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
lea    0xe56(%rip),%rax
lea    0xe45(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x438(%rbp)
movq   $0x0,-0x440(%rbp)
movl   $0x0,-0x448(%rbp)
lea    0xe28(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x444(%rbp)
cmpl   $0x0,-0x444(%rbp)
je     1252 <check_entry_string+0xc2>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <sqlite3_errmsg@plt>
mov    -0x44c(%rbp),%edi
mov    %eax,%ecx
lea    0xdf9(%rip),%rsi
lea    0xe0f(%rip),%rdx
mov    $0x0,%al
call   1070 <syslog@plt>
mov    -0x28(%rbp),%rdi
call   1060 <sqlite3_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <check_entry_string+0x2ac>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rax
lea    0xdf0(%rip),%rsi
lea    0xe31(%rip),%rdx
lea    0xe33(%rip),%rcx
lea    0xe38(%rip),%r8
lea    0xe3a(%rip),%r9
mov    %rax,(%rsp)
call   10b0 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    -0x440(%rbp),%r8
mov    $0x400,%edx
lea    -0x438(%rbp),%rcx
call   10a0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x444(%rbp)
mov    -0x444(%rbp),%eax
mov    0x2d21(%rip),%rcx
cmp    (%rcx),%eax
je     1311 <check_entry_string+0x181>
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x450(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <sqlite3_errmsg@plt>
mov    -0x450(%rbp),%edi
mov    %eax,%ecx
lea    0xdd3(%rip),%rsi
lea    0xd50(%rip),%rdx
mov    $0x0,%al
call   1070 <syslog@plt>
mov    -0x28(%rbp),%rdi
call   1060 <sqlite3_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143c <check_entry_string+0x2ac>
jmp    1316 <check_entry_string+0x186>
mov    -0x444(%rbp),%eax
mov    0x2cad(%rip),%rcx
cmp    (%rcx),%eax
je     141e <check_entry_string+0x28e>
mov    -0x438(%rbp),%rdi
call   1050 <sqlite3_step@plt>
mov    %eax,-0x444(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
cmp    -0x444(%rbp),%eax
jne    1419 <check_entry_string+0x289>
mov    -0x438(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <evaluate_stmt_string@plt>
mov    %eax,-0x448(%rbp)
cmpl   $0x1,-0x448(%rbp)
jne    1414 <check_entry_string+0x284>
mov    -0x18(%rbp),%eax
mov    %eax,-0x454(%rbp)
sub    $0x1,%eax
je     13ca <check_entry_string+0x23a>
jmp    138f <check_entry_string+0x1ff>
mov    -0x454(%rbp),%eax
sub    $0x2,%eax
jne    13f1 <check_entry_string+0x261>
jmp    13a3 <check_entry_string+0x213>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xd1d(%rip),%rsi
lea    0xc87(%rip),%rdx
mov    $0x0,%al
call   1070 <syslog@plt>
jmp    140f <check_entry_string+0x27f>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xd1e(%rip),%rsi
lea    0xc60(%rip),%rdx
mov    $0x0,%al
call   1070 <syslog@plt>
jmp    140f <check_entry_string+0x27f>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
lea    0xc3d(%rip),%rdx
mov    $0x0,%al
call   1070 <syslog@plt>
jmp    141e <check_entry_string+0x28e>
jmp    1419 <check_entry_string+0x289>
jmp    1316 <check_entry_string+0x186>
mov    -0x438(%rbp),%rdi
call   1090 <sqlite3_finalize@plt>
mov    -0x28(%rbp),%rdi
call   1060 <sqlite3_close@plt>
mov    -0x448(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_entry_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%r15
movq   $0x0,0x8(%rsp)
lea    0xe5b(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <sqlite3_open@plt>
test   %eax,%eax
je     11e6 <check_entry_string+0x56>
mov    0x2de2(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   1040 <sqlite3_errmsg@plt>
lea    0xe47(%rip),%rsi
jmp    128d <check_entry_string+0xfd>
cmp    $0x2,%ebp
lea    0xe10(%rip),%rax
lea    0xe13(%rip),%rcx
cmove  %rax,%rcx
mov    %rcx,(%rsp)
lea    0xe4e(%rip),%rsi
lea    0xe8f(%rip),%rdx
lea    0xe91(%rip),%rcx
lea    0xe96(%rip),%r8
lea    0xe98(%rip),%r9
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   10b0 <sprintf@plt>
mov    0x10(%rsp),%rdi
xor    %ebx,%ebx
lea    0x8(%rsp),%rcx
mov    %r14,%rsi
mov    $0x400,%edx
xor    %r8d,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    0x2d8e(%rip),%rcx
cmp    (%rcx),%eax
jne    1273 <check_entry_string+0xe3>
mov    %ebp,0x1c(%rsp)
mov    0x2d6f(%rip),%r13
cmp    0x0(%r13),%eax
jne    12c2 <check_entry_string+0x132>
mov    0x8(%rsp),%rdi
call   1090 <sqlite3_finalize@plt>
jmp    12a4 <check_entry_string+0x114>
mov    0x2d36(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   1040 <sqlite3_errmsg@plt>
lea    0xe34(%rip),%rsi
lea    0xdb1(%rip),%rdx
mov    %ebx,%edi
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    $0xffffffff,%ebx
mov    0x10(%rsp),%rdi
call   1060 <sqlite3_close@plt>
mov    %ebx,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
mov    0x2cfd(%rip),%r14
jmp    12d6 <check_entry_string+0x146>
nopl   (%rax)
cmp    0x0(%r13),%ebp
je     1267 <check_entry_string+0xd7>
mov    0x8(%rsp),%rdi
call   1050 <sqlite3_step@plt>
mov    %eax,%ebp
cmp    %eax,(%r14)
jne    12d0 <check_entry_string+0x140>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1080 <evaluate_stmt_string@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
jne    12d0 <check_entry_string+0x140>
mov    0x1c(%rsp),%eax
cmp    $0x1,%eax
je     131e <check_entry_string+0x18e>
cmp    $0x2,%eax
jne    1349 <check_entry_string+0x1b9>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
jmp    132e <check_entry_string+0x19e>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
lea    0xd10(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    $0x1,%ebx
jmp    1267 <check_entry_string+0xd7>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
lea    0xce5(%rip),%rdx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    $0x1,%ebx
jmp    1267 <check_entry_string+0xd7>

LLVM IR (-O0):
@.str = [10 x i8] c"whitelist\00"
@.str.1 = [10 x i8] c"blacklist\00"
@.str.2 = [20 x i8] c"db/phonefirewall.db\00"
@LOG_ERR = global i32 0
@.str.3 = [29 x i8] c"[%s] Can't open database: %s\00"
@.str.4 = [15 x i8] c"phone-firewall\00"
@.str.5 = [72 x i8] c"SELECT %1$s, %2$s, %3$s, %4$s FROM %5$s ORDER BY %1$s, %2$s, %3$s, %4$s\00"
@.str.6 = [9 x i8] c"priority\00"
@.str.7 = [12 x i8] c"countrycode\00"
@.str.8 = [9 x i8] c"areacode\00"
@.str.9 = [7 x i8] c"number\00"
@SQLITE_OK = global i32 0
@.str.10 = [19 x i8] c"[%s] SQL error: %s\00"
@SQLITE_DONE = global i32 0
@SQLITE_ROW = global i32 0
@LOG_DEBUG = global i32 0
@.str.11 = [40 x i8] c"[%s] Number \22%s\22 accepted successfully.\00"
@.str.12 = [39 x i8] c"[%s] Number \22%s\22 blocked successfully.\00"
@LOG_CRIT = global i32 0
@.str.13 = [44 x i8] c"[%s] Stuff is no blacklist nor a whitelist.\00"
define i32 @check_entry_string(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [1024 x i8]
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 2, %15
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
store i8* %18, i8** %8
store i32* null, i32** %11
store i8** null, i8*** %12
store i32 0, i32* %14
%19 = call i32 @sqlite3_open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32** %9)
store i32 %19, i32* %13
%20 = load i32, i32* %13
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %3
%23 = load i32, i32* @LOG_ERR
%24 = load i32*, i32** %9
%25 = call i32 @sqlite3_errmsg(i32* %24)
%26 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32*, i32** %9
%28 = call i32 @sqlite3_close(i32* %27)
store i32 -1, i32* %4
br label %87
29: ; preds = %3
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%31 = load i8*, i8** %8
%32 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %31)
%33 = load i32*, i32** %9
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%35 = load i8**, i8*** %12
%36 = call i32 @sqlite3_prepare_v2(i32* %33, i8* %34, i32 1024, i32** %11, i8** %35)
store i32 %36, i32* %13
%37 = load i32, i32* %13
%38 = load i32, i32* @SQLITE_OK
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %29
%41 = load i32, i32* @LOG_ERR
%42 = load i32*, i32** %9
%43 = call i32 @sqlite3_errmsg(i32* %42)
%44 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %41, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = load i32*, i32** %9
%46 = call i32 @sqlite3_close(i32* %45)
store i32 -1, i32* %4
br label %87
47: ; preds = %29
br label %48
48: ; preds = %80, %47
%49 = load i32, i32* %13
%50 = load i32, i32* @SQLITE_DONE
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %81
52: ; preds = %48
%53 = load i32*, i32** %11
%54 = call i32 @sqlite3_step(i32* %53)
store i32 %54, i32* %13
%55 = load i32, i32* @SQLITE_ROW
%56 = load i32, i32* %13
%57 = icmp eq i32 %55, %56
br i1 %57, label %58, label %80
58: ; preds = %52
%59 = load i32*, i32** %11
%60 = load i8*, i8** %5
%61 = load i32, i32* %6
%62 = call i32 @evaluate_stmt_string(i32* %59, i8* %60, i32 %61)
store i32 %62, i32* %14
%63 = load i32, i32* %14
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %79
65: ; preds = %58
%66 = load i32, i32* %7
switch i32 %66, label %75 [
i32 2, label %67
i32 1, label %71
]
67: ; preds = %65
%68 = load i32, i32* @LOG_DEBUG
%69 = load i8*, i8** %5
%70 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %68, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %69)
br label %78
71: ; preds = %65
%72 = load i32, i32* @LOG_DEBUG
%73 = load i8*, i8** %5
%74 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %72, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %73)
br label %78
75: ; preds = %65
%76 = load i32, i32* @LOG_CRIT
%77 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %76, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %78
78: ; preds = %75, %71, %67
br label %81
79: ; preds = %58
br label %80
80: ; preds = %79, %52
br label %48
81: ; preds = %78, %48
%82 = load i32*, i32** %11
%83 = call i32 @sqlite3_finalize(i32* %82)
%84 = load i32*, i32** %9
%85 = call i32 @sqlite3_close(i32* %84)
%86 = load i32, i32* %14
store i32 %86, i32* %4
br label %87
87: ; preds = %81, %40, %22
%88 = load i32, i32* %4
ret i32 %88
}

LLVM IR (-O2):
@.str = [10 x i8] c"whitelist\00"
@.str.1 = [10 x i8] c"blacklist\00"
@.str.2 = [20 x i8] c"db/phonefirewall.db\00"
@LOG_ERR = global i32 0
@.str.3 = [29 x i8] c"[%s] Can't open database: %s\00"
@.str.4 = [15 x i8] c"phone-firewall\00"
@.str.5 = [72 x i8] c"SELECT %1$s, %2$s, %3$s, %4$s FROM %5$s ORDER BY %1$s, %2$s, %3$s, %4$s\00"
@.str.6 = [9 x i8] c"priority\00"
@.str.7 = [12 x i8] c"countrycode\00"
@.str.8 = [9 x i8] c"areacode\00"
@.str.9 = [7 x i8] c"number\00"
@SQLITE_OK = global i32 0
@.str.10 = [19 x i8] c"[%s] SQL error: %s\00"
@SQLITE_DONE = global i32 0
@SQLITE_ROW = global i32 0
@LOG_DEBUG = global i32 0
@.str.11 = [40 x i8] c"[%s] Number \22%s\22 accepted successfully.\00"
@.str.12 = [39 x i8] c"[%s] Number \22%s\22 blocked successfully.\00"
@LOG_CRIT = global i32 0
@.str.13 = [44 x i8] c"[%s] Stuff is no blacklist nor a whitelist.\00"
define i32 @check_entry_string(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i32*
%7 = bitcast i32** %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = bitcast i32** %6 to i8*
store i32* null, i32** %6
%10 = call i32 @sqlite3_open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32** %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %3
%13 = load i32, i32* @LOG_ERR
%14 = load i32*, i32** %4
%15 = call i32 @sqlite3_errmsg(i32* %14)
%16 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %61
17: ; preds = %3
%18 = icmp eq i32 %2, 2
%19 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
%20 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %19)
%21 = load i32*, i32** %4
%22 = call i32 @sqlite3_prepare_v2(i32* %21, i8* %8, i32 1024, i32** %6, i8** null)
%23 = load i32, i32* @SQLITE_OK
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* @SQLITE_DONE
%27 = icmp eq i32 %22, %26
br i1 %27, label %57, label %33
28: ; preds = %17
%29 = load i32, i32* @LOG_ERR
%30 = load i32*, i32** %4
%31 = call i32 @sqlite3_errmsg(i32* %30)
%32 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %61
33: ; preds = %25, %53
%34 = phi i32 [ %54, %53 ], [ 0, %25 ]
%35 = load i32*, i32** %6
%36 = call i32 @sqlite3_step(i32* %35)
%37 = load i32, i32* @SQLITE_ROW
%38 = icmp eq i32 %37, %36
br i1 %38, label %39, label %53
39: ; preds = %33
%40 = load i32*, i32** %6
%41 = call i32 @evaluate_stmt_string(i32* %40, i8* %0, i32 %1)
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %53
43: ; preds = %39
switch i32 %2, label %50 [
i32 2, label %44
i32 1, label %47
]
44: ; preds = %43
%45 = load i32, i32* @LOG_DEBUG
%46 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %45, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %57
47: ; preds = %43
%48 = load i32, i32* @LOG_DEBUG
%49 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %48, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %57
50: ; preds = %43
%51 = load i32, i32* @LOG_CRIT
%52 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %51, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %57
53: ; preds = %39, %33
%54 = phi i32 [ %41, %39 ], [ %34, %33 ]
%55 = load i32, i32* @SQLITE_DONE
%56 = icmp eq i32 %36, %55
br i1 %56, label %57, label %33
57: ; preds = %53, %25, %44, %47, %50
%58 = phi i32 [ 1, %50 ], [ 1, %47 ], [ 1, %44 ], [ 0, %25 ], [ %54, %53 ]
%59 = load i32*, i32** %6
%60 = call i32 @sqlite3_finalize(i32* %59)
br label %61
61: ; preds = %57, %28, %12
%62 = phi i32 [ -1, %12 ], [ -1, %28 ], [ %58, %57 ]
%63 = load i32*, i32** %4
%64 = call i32 @sqlite3_close(i32* %63)
ret i32 %62
}