#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;
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int LOG_INFO;
int LOG_LOCAL6;
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_int(int /*<<< orphan*/ *, int);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sqlite3_errmsg(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, size_t,
                                      int /*<<< orphan*/ **,
                                      int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
size_t strlen(char *);
int /*<<< orphan*/ syslog(int, char *, char *, int /*<<< orphan*/);
int sqlite_get_host_all_by_ix(int the_ix, char *dst, size_t sz_dst,
                              const char *db_loc) {
  sqlite3 *db;
  sqlite3_stmt *stmt;
  int rc;
  char cwd[512 / 2];
  char DB_LOCATION[512 + 1];
  if (db_loc) {
    snprintf(DB_LOCATION, 512, "%s", db_loc);
  } else {
    if (getcwd(cwd, sizeof(cwd)) == NULL) {
      return 1;
    } else {
      snprintf(DB_LOCATION, 512, "%s%s", cwd, "/db/gargoyle_attack_detect.db");
    }
  }
  char dest[60];
  char sql[512];
  rc = sqlite3_open(DB_LOCATION, &db);
  if (rc != SQLITE_OK) {
    syslog(LOG_INFO | LOG_LOCAL6,
           "ERROR opening SQLite DB '%s' from function "
           "[sqlite_get_host_all_by_ix]: %s",
           DB_LOCATION, sqlite3_errmsg(db));
    return 1;
  }
  snprintf(sql, 512, "SELECT * FROM %s WHERE ix = ?1", "hosts_table");
  sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
  sqlite3_bind_int(stmt, 1, the_ix);
  *dest = 0;
  while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
    snprintf(dest, 60, "%d:%s:%d:%d", sqlite3_column_int(stmt, 0),
             sqlite3_column_text(stmt, 1), sqlite3_column_int(stmt, 2),
             sqlite3_column_int(stmt, 3));
  }
  size_t dest_set_len = strlen(dest);
  dest[dest_set_len] = '\0';
  sqlite3_finalize(stmt);
  sqlite3_close(db);
  if (dest_set_len + 1 > sz_dst) {
    return 1;
  }
  memcpy(dst, dest, dest_set_len + 1);
  return 0;
}


x86 assembly (clang, -O0):
<sqlite_get_host_all_by_ix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5e0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1228 <sqlite_get_host_all_by_ix+0x48>
lea    -0x350(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
lea    0xe4f(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    127c <sqlite_get_host_all_by_ix+0x9c>
lea    -0x140(%rbp),%rdi
mov    $0x100,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
jne    124f <sqlite_get_host_all_by_ix+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    1492 <sqlite_get_host_all_by_ix+0x2b2>
lea    -0x350(%rbp),%rdi
lea    -0x140(%rbp),%rcx
mov    $0x200,%esi
lea    0xd97(%rip),%rdx
lea    0xd95(%rip),%r8
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    127c <sqlite_get_host_all_by_ix+0x9c>
lea    -0x350(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2d47(%rip),%rcx
cmp    (%rcx),%eax
je     12f7 <sqlite_get_host_all_by_ix+0x117>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
mov    0x2d37(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x5a4(%rbp)
lea    -0x350(%rbp),%rax
mov    %rax,-0x5a0(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <sqlite3_errmsg@plt>
mov    -0x5a4(%rbp),%edi
mov    -0x5a0(%rbp),%rdx
mov    %eax,%ecx
lea    0xd3d(%rip),%rsi
call   10e0 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1492 <sqlite_get_host_all_by_ix+0x2b2>
lea    -0x590(%rbp),%rdi
mov    $0x200,%esi
lea    0xd64(%rip),%rdx
lea    0xd7c(%rip),%rcx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x5b8(%rbp)
lea    -0x590(%rbp),%rax
mov    %rax,-0x5b0(%rbp)
lea    -0x590(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x5b8(%rbp),%rdi
mov    -0x5b0(%rbp),%rsi
mov    %rax,%rdx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1100 <sqlite3_prepare_v2@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1040 <sqlite3_bind_int@plt>
movb   $0x0,-0x390(%rbp)
mov    -0x30(%rbp),%rdi
call   10a0 <sqlite3_step@plt>
mov    %eax,-0x34(%rbp)
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%eax
jne    141b <sqlite_get_host_all_by_ix+0x23b>
lea    -0x390(%rbp),%rax
mov    %rax,-0x5d8(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,-0x5cc(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <sqlite3_column_text@plt>
mov    %rax,-0x5c8(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x2,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,-0x5bc(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1080 <sqlite3_column_int@plt>
mov    -0x5d8(%rbp),%rdi
mov    -0x5cc(%rbp),%ecx
mov    -0x5c8(%rbp),%r8
mov    -0x5bc(%rbp),%r9d
mov    $0x3c,%esi
lea    0xc8d(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1374 <sqlite_get_host_all_by_ix+0x194>
lea    -0x390(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x598(%rbp)
mov    -0x598(%rbp),%rax
movb   $0x0,-0x390(%rbp,%rax,1)
mov    -0x30(%rbp),%rdi
call   10f0 <sqlite3_finalize@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <sqlite3_close@plt>
mov    -0x598(%rbp),%rax
add    $0x1,%rax
cmp    -0x18(%rbp),%rax
jbe    1470 <sqlite_get_host_all_by_ix+0x290>
movl   $0x1,-0x4(%rbp)
jmp    1492 <sqlite_get_host_all_by_ix+0x2b2>
mov    -0x10(%rbp),%rdi
lea    -0x390(%rbp),%rsi
mov    -0x598(%rbp),%rdx
add    $0x1,%rdx
call   10b0 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite_get_host_all_by_ix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x588,%rsp
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %edi,%r13d
test   %rcx,%rcx
je     121c <sqlite_get_host_all_by_ix+0x3c>
lea    0xe65(%rip),%rdx
lea    0x170(%rsp),%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    125b <sqlite_get_host_all_by_ix+0x7b>
lea    0x70(%rsp),%rdi
mov    $0x100,%esi
call   1070 <getcwd@plt>
test   %rax,%rax
je     13fe <sqlite_get_host_all_by_ix+0x21e>
lea    0xdc5(%rip),%rdx
lea    0xdc3(%rip),%r8
lea    0x170(%rsp),%rdi
lea    0x70(%rsp),%rcx
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
lea    0x170(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <sqlite3_open@plt>
mov    0x2d6c(%rip),%rcx
cmp    (%rcx),%eax
jne    13ca <sqlite_get_host_all_by_ix+0x1ea>
mov    %rbp,0x28(%rsp)
mov    %rbx,0x20(%rsp)
lea    0xde1(%rip),%rdx
lea    0xdf9(%rip),%rcx
lea    0x380(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    0x18(%rsp),%rbx
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x10(%rsp),%rcx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %r8d,%r8d
call   1100 <sqlite3_prepare_v2@plt>
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    %r13d,%edx
call   1040 <sqlite3_bind_int@plt>
movb   $0x0,0x30(%rsp)
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_step@plt>
mov    0x2cda(%rip),%r12
cmp    (%r12),%eax
jne    137e <sqlite_get_host_all_by_ix+0x19e>
lea    0xd92(%rip),%r13
lea    0x30(%rsp),%rbp
nopl   0x0(%rax)
mov    0x10(%rsp),%rdi
xor    %esi,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
call   10d0 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    0x10(%rsp),%rdi
mov    $0x2,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,%r15d
mov    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1080 <sqlite3_column_int@plt>
mov    %eax,(%rsp)
mov    %rbp,%rdi
mov    $0x3c,%esi
mov    %r13,%rdx
mov    %ebx,%ecx
mov    %r14,%r8
mov    %r15d,%r9d
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_step@plt>
cmp    (%r12),%eax
je     1310 <sqlite_get_host_all_by_ix+0x130>
lea    0x30(%rsp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
movb   $0x0,0x30(%rsp,%rax,1)
mov    0x10(%rsp),%rdi
call   10f0 <sqlite3_finalize@plt>
mov    0x18(%rsp),%rdi
call   10c0 <sqlite3_close@plt>
add    $0x1,%rbx
cmp    0x28(%rsp),%rbx
mov    $0x1,%eax
ja     1403 <sqlite_get_host_all_by_ix+0x223>
lea    0x30(%rsp),%rsi
mov    0x20(%rsp),%rdi
mov    %rbx,%rdx
call   10b0 <memcpy@plt>
xor    %eax,%eax
jmp    1403 <sqlite_get_host_all_by_ix+0x223>
mov    0x2bf7(%rip),%rax
mov    0x2c10(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    0x18(%rsp),%rdi
call   1090 <sqlite3_errmsg@plt>
lea    0xc36(%rip),%rsi
lea    0x170(%rsp),%rdx
mov    %ebx,%edi
mov    %eax,%ecx
call   10e0 <syslog@plt>
mov    $0x1,%eax
add    $0x588,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [30 x i8] c"/db/gargoyle_attack_detect.db\00"
@SQLITE_OK = global i32 0
@LOG_INFO = global i32 0
@LOG_LOCAL6 = global i32 0
@.str.3 = [75 x i8] c"ERROR opening SQLite DB '%s' from function [sqlite_get_host_all_by_ix]: %s\00"
@.str.4 = [31 x i8] c"SELECT * FROM %s WHERE ix = ?1\00"
@.str.5 = [12 x i8] c"hosts_table\00"
@SQLITE_ROW = global i32 0
@.str.6 = [12 x i8] c"%d:%s:%d:%d\00"
define i32 @sqlite_get_host_all_by_ix(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca [513 x i8]
%15 = alloca [60 x i8]
%16 = alloca [512 x i8]
%17 = alloca i64
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %4
%21 = getelementptr inbounds [513 x i8], [513 x i8]* %14, i64 0, i64 0
%22 = load i8*, i8** %9
%23 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %21, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %34
24: ; preds = %4
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%26 = call i32* @getcwd(i8* %25, i32 256)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %5
br label %96
29: ; preds = %24
%30 = getelementptr inbounds [513 x i8], [513 x i8]* %14, i64 0, i64 0
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %30, i32 512, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %29
br label %34
34: ; preds = %33, %20
%35 = getelementptr inbounds [513 x i8], [513 x i8]* %14, i64 0, i64 0
%36 = call i32 @sqlite3_open(i8* %35, i32** %10)
store i32 %36, i32* %12
%37 = load i32, i32* %12
%38 = load i32, i32* @SQLITE_OK
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %48
40: ; preds = %34
%41 = load i32, i32* @LOG_INFO
%42 = load i32, i32* @LOG_LOCAL6
%43 = or i32 %41, %42
%44 = getelementptr inbounds [513 x i8], [513 x i8]* %14, i64 0, i64 0
%45 = load i32*, i32** %10
%46 = call i32 @sqlite3_errmsg(i32* %45)
%47 = call i32 @syslog(i32 %43, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %44, i32 %46)
store i32 1, i32* %5
br label %96
48: ; preds = %34
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%50 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %49, i32 512, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32*, i32** %10
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%54 = call i64 @strlen(i8* %53)
%55 = call i32 @sqlite3_prepare_v2(i32* %51, i8* %52, i64 %54, i32** %11, i32* null)
%56 = load i32*, i32** %11
%57 = load i32, i32* %6
%58 = call i32 @sqlite3_bind_int(i32* %56, i32 1, i32 %57)
%59 = getelementptr inbounds [60 x i8], [60 x i8]* %15, i64 0, i64 0
store i8 0, i8* %59
br label %60
60: ; preds = %65, %48
%61 = load i32*, i32** %11
%62 = call i32 @sqlite3_step(i32* %61)
store i32 %62, i32* %12
%63 = load i32, i32* @SQLITE_ROW
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %76
65: ; preds = %60
%66 = getelementptr inbounds [60 x i8], [60 x i8]* %15, i64 0, i64 0
%67 = load i32*, i32** %11
%68 = call i32 @sqlite3_column_int(i32* %67, i32 0)
%69 = load i32*, i32** %11
%70 = call i8* @sqlite3_column_text(i32* %69, i32 1)
%71 = load i32*, i32** %11
%72 = call i32 @sqlite3_column_int(i32* %71, i32 2)
%73 = load i32*, i32** %11
%74 = call i32 @sqlite3_column_int(i32* %73, i32 3)
%75 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %66, i32 60, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %68, i8* %70, i32 %72, i32 %74)
br label %60
76: ; preds = %60
%77 = getelementptr inbounds [60 x i8], [60 x i8]* %15, i64 0, i64 0
%78 = call i64 @strlen(i8* %77)
store i64 %78, i64* %17
%79 = load i64, i64* %17
%80 = getelementptr inbounds [60 x i8], [60 x i8]* %15, i64 0, i64 %79
store i8 0, i8* %80
%81 = load i32*, i32** %11
%82 = call i32 @sqlite3_finalize(i32* %81)
%83 = load i32*, i32** %10
%84 = call i32 @sqlite3_close(i32* %83)
%85 = load i64, i64* %17
%86 = add i64 %85, 1
%87 = load i64, i64* %8
%88 = icmp ugt i64 %86, %87
br i1 %88, label %89, label %90
89: ; preds = %76
store i32 1, i32* %5
br label %96
90: ; preds = %76
%91 = load i8*, i8** %7
%92 = getelementptr inbounds [60 x i8], [60 x i8]* %15, i64 0, i64 0
%93 = load i64, i64* %17
%94 = add i64 %93, 1
%95 = call i32 @memcpy(i8* %91, i8* %92, i64 %94)
store i32 0, i32* %5
br label %96
96: ; preds = %90, %89, %40, %28
%97 = load i32, i32* %5
ret i32 %97
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [30 x i8] c"/db/gargoyle_attack_detect.db\00"
@SQLITE_OK = global i32 0
@LOG_INFO = global i32 0
@LOG_LOCAL6 = global i32 0
@.str.3 = [75 x i8] c"ERROR opening SQLite DB '%s' from function [sqlite_get_host_all_by_ix]: %s\00"
@.str.4 = [31 x i8] c"SELECT * FROM %s WHERE ix = ?1\00"
@.str.5 = [12 x i8] c"hosts_table\00"
@SQLITE_ROW = global i32 0
@.str.6 = [12 x i8] c"%d:%s:%d:%d\00"
define i32 @sqlite_get_host_all_by_ix(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca [513 x i8]
%9 = alloca [60 x i8]
%10 = alloca [512 x i8]
%11 = bitcast i32** %5 to i8*
%12 = bitcast i32** %6 to i8*
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [513 x i8], [513 x i8]* %8, i64 0, i64 0
%15 = icmp eq i8* %3, null
br i1 %15, label %18, label %16
16: ; preds = %4
%17 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %23
18: ; preds = %4
%19 = call i32* @getcwd(i8* %13, i32 256)
%20 = icmp eq i32* %19, null
br i1 %20, label %74, label %21
21: ; preds = %18
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 512, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = getelementptr inbounds [60 x i8], [60 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%26 = call i32 @sqlite3_open(i8* %14, i32** %5)
%27 = load i32, i32* @SQLITE_OK
%28 = icmp eq i32 %26, %27
br i1 %28, label %36, label %29
29: ; preds = %23
%30 = load i32, i32* @LOG_INFO
%31 = load i32, i32* @LOG_LOCAL6
%32 = or i32 %31, %30
%33 = load i32*, i32** %5
%34 = call i32 @sqlite3_errmsg(i32* %33)
%35 = call i32 @syslog(i32 %32, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %14, i32 %34)
br label %72
36: ; preds = %23
%37 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %25, i32 512, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32*, i32** %5
%39 = call i64 @strlen(i8* %25)
%40 = call i32 @sqlite3_prepare_v2(i32* %38, i8* %25, i64 %39, i32** %6, i32* null)
%41 = load i32*, i32** %6
%42 = call i32 @sqlite3_bind_int(i32* %41, i32 1, i32 %0)
store i8 0, i8* %24
%43 = load i32*, i32** %6
%44 = call i32 @sqlite3_step(i32* %43)
%45 = load i32, i32* @SQLITE_ROW
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %61
47: ; preds = %36, %47
%48 = load i32*, i32** %6
%49 = call i32 @sqlite3_column_int(i32* %48, i32 0)
%50 = load i32*, i32** %6
%51 = call i8* @sqlite3_column_text(i32* %50, i32 1)
%52 = load i32*, i32** %6
%53 = call i32 @sqlite3_column_int(i32* %52, i32 2)
%54 = load i32*, i32** %6
%55 = call i32 @sqlite3_column_int(i32* %54, i32 3)
%56 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 60, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %49, i8* %51, i32 %53, i32 %55)
%57 = load i32*, i32** %6
%58 = call i32 @sqlite3_step(i32* %57)
%59 = load i32, i32* @SQLITE_ROW
%60 = icmp eq i32 %58, %59
br i1 %60, label %47, label %61
61: ; preds = %47, %36
%62 = call i64 @strlen(i8* %24)
%63 = getelementptr inbounds [60 x i8], [60 x i8]* %9, i64 0, i64 %62
store i8 0, i8* %63
%64 = load i32*, i32** %6
%65 = call i32 @sqlite3_finalize(i32* %64)
%66 = load i32*, i32** %5
%67 = call i32 @sqlite3_close(i32* %66)
%68 = add i64 %62, 1
%69 = icmp ugt i64 %68, %2
br i1 %69, label %72, label %70
70: ; preds = %61
%71 = call i32 @memcpy(i8* %1, i8* %24, i64 %68)
br label %72
72: ; preds = %70, %61, %29
%73 = phi i32 [ 1, %29 ], [ 0, %70 ], [ 1, %61 ]
br label %74
74: ; preds = %18, %72
%75 = phi i32 [ %73, %72 ], [ 1, %18 ]
ret i32 %75
}