#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*/ free(char *);
int /*<<< orphan*/ *getcwd(char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_int(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 *, int,
                                      int /*<<< orphan*/ **,
                                      int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ syslog(int, char *, char *, int /*<<< orphan*/);
int sqlite_get_black_ip_list_all(char *dst, size_t sz_dst, const char *db_loc) {
  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");
    }
  }
  sqlite3 *db;
  sqlite3_stmt *stmt;
  int rc;
  char *final_set;
  final_set = (char *)malloc(5242880);
  char *l_buf;
  l_buf = (char *)malloc(60);
  char *sql;
  sql = (char *)malloc(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_black_ip_list_all]: %s",
           DB_LOCATION, sqlite3_errmsg(db));
    free(l_buf);
    free(sql);
    free(final_set);
    return 1;
  }
  snprintf(sql, 512, "SELECT * FROM %s", "black_ip_list");
  sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
  *final_set = 0;
  while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
    snprintf(l_buf, 60, "%d:%d:%d>", sqlite3_column_int(stmt, 0),
             sqlite3_column_int(stmt, 1), sqlite3_column_int(stmt, 2));
    strncat(final_set, l_buf, 5242880 - strlen(final_set) - 1);
  }
  size_t final_set_len = strlen(final_set);
  final_set[final_set_len] = '\0';
  sqlite3_finalize(stmt);
  sqlite3_close(db);
  if (final_set_len + 1 > sz_dst) {
    free(l_buf);
    free(sql);
    free(final_set);
    return 1;
  }
  memcpy(dst, final_set, final_set_len + 1);
  free(l_buf);
  free(sql);
  free(final_set);
  return 0;
}


x86 assembly (clang, -O0):
<sqlite_get_black_ip_list_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3b0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1235 <sqlite_get_black_ip_list_all+0x45>
lea    -0x330(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
lea    0xe45(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1289 <sqlite_get_black_ip_list_all+0x99>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
jne    125c <sqlite_get_black_ip_list_all+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    1584 <sqlite_get_black_ip_list_all+0x394>
lea    -0x330(%rbp),%rdi
lea    -0x120(%rbp),%rcx
mov    $0x200,%esi
lea    0xd8a(%rip),%rdx
lea    0xd88(%rip),%r8
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1289 <sqlite_get_black_ip_list_all+0x99>
mov    $0x500000,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x350(%rbp)
mov    $0x3c,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x358(%rbp)
mov    $0x200,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x360(%rbp)
lea    -0x330(%rbp),%rdi
lea    -0x338(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x344(%rbp)
mov    -0x344(%rbp),%eax
mov    0x2cfe(%rip),%rcx
cmp    (%rcx),%eax
je     1367 <sqlite_get_black_ip_list_all+0x177>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    0x2cee(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x374(%rbp)
lea    -0x330(%rbp),%rax
mov    %rax,-0x370(%rbp)
mov    -0x338(%rbp),%rdi
call   10a0 <sqlite3_errmsg@plt>
mov    -0x374(%rbp),%edi
mov    -0x370(%rbp),%rdx
mov    %eax,%ecx
lea    0xcf1(%rip),%rsi
call   10f0 <syslog@plt>
mov    -0x358(%rbp),%rdi
call   1030 <free@plt>
mov    -0x360(%rbp),%rdi
call   1030 <free@plt>
mov    -0x350(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1584 <sqlite_get_black_ip_list_all+0x394>
mov    -0x360(%rbp),%rdi
mov    $0x200,%esi
lea    0xcf7(%rip),%rdx
lea    0xd01(%rip),%rcx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x338(%rbp),%rax
mov    %rax,-0x388(%rbp)
mov    -0x360(%rbp),%rax
mov    %rax,-0x380(%rbp)
mov    -0x360(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x388(%rbp),%rdi
mov    -0x380(%rbp),%rsi
mov    %eax,%edx
lea    -0x340(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1110 <sqlite3_prepare_v2@plt>
mov    -0x350(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x340(%rbp),%rdi
call   10b0 <sqlite3_step@plt>
mov    %eax,-0x344(%rbp)
mov    0x2bdc(%rip),%rcx
cmp    (%rcx),%eax
jne    14ba <sqlite_get_black_ip_list_all+0x2ca>
mov    -0x358(%rbp),%rax
mov    %rax,-0x3a8(%rbp)
mov    -0x340(%rbp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_int@plt>
mov    %eax,-0x3a0(%rbp)
mov    -0x340(%rbp),%rdi
mov    $0x1,%esi
call   1090 <sqlite3_column_int@plt>
mov    %eax,-0x39c(%rbp)
mov    -0x340(%rbp),%rdi
mov    $0x2,%esi
call   1090 <sqlite3_column_int@plt>
mov    -0x3a8(%rbp),%rdi
mov    -0x3a0(%rbp),%ecx
mov    -0x39c(%rbp),%r8d
mov    %eax,%r9d
mov    $0x3c,%esi
lea    0xc27(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x350(%rbp),%rax
mov    %rax,-0x398(%rbp)
mov    -0x358(%rbp),%rax
mov    %rax,-0x390(%rbp)
mov    -0x350(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x398(%rbp),%rdi
mov    -0x390(%rbp),%rsi
mov    $0x500000,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1080 <strncat@plt>
jmp    13db <sqlite_get_black_ip_list_all+0x1eb>
mov    -0x350(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x368(%rbp)
mov    -0x350(%rbp),%rax
mov    -0x368(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x340(%rbp),%rdi
call   1100 <sqlite3_finalize@plt>
mov    -0x338(%rbp),%rdi
call   10d0 <sqlite3_close@plt>
mov    -0x368(%rbp),%rax
add    $0x1,%rax
cmp    -0x18(%rbp),%rax
jbe    153e <sqlite_get_black_ip_list_all+0x34e>
mov    -0x358(%rbp),%rdi
call   1030 <free@plt>
mov    -0x360(%rbp),%rdi
call   1030 <free@plt>
mov    -0x350(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1584 <sqlite_get_black_ip_list_all+0x394>
mov    -0x10(%rbp),%rdi
mov    -0x350(%rbp),%rsi
mov    -0x368(%rbp),%rdx
add    $0x1,%rdx
call   10c0 <memcpy@plt>
mov    -0x358(%rbp),%rdi
call   1030 <free@plt>
mov    -0x360(%rbp),%rdi
call   1030 <free@plt>
mov    -0x350(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite_get_black_ip_list_all>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x338,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
test   %rdx,%rdx
je     122c <sqlite_get_black_ip_list_all+0x3c>
mov    %rdx,%rcx
lea    0xe58(%rip),%rdx
lea    0x130(%rsp),%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    126b <sqlite_get_black_ip_list_all+0x7b>
lea    0x30(%rsp),%rdi
mov    $0x100,%esi
call   1070 <getcwd@plt>
test   %rax,%rax
je     1430 <sqlite_get_black_ip_list_all+0x240>
lea    0xdb5(%rip),%rdx
lea    0xdb3(%rip),%r8
lea    0x130(%rsp),%rdi
lea    0x30(%rsp),%rcx
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    $0x500000,%edi
call   10e0 <malloc@plt>
mov    %rax,%r13
mov    $0x3c,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
mov    $0x200,%edi
call   10e0 <malloc@plt>
mov    %rax,%r15
lea    0x130(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <sqlite3_open@plt>
mov    0x2d35(%rip),%rcx
cmp    (%rcx),%eax
jne    13e4 <sqlite_get_black_ip_list_all+0x1f4>
mov    %r14,0x28(%rsp)
mov    %rbp,0x20(%rsp)
lea    0xdad(%rip),%rdx
lea    0xdb7(%rip),%rcx
mov    %r15,%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    0x10(%rsp),%rbp
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x8(%rsp),%rcx
mov    %rbp,%rdi
mov    %r15,0x18(%rsp)
mov    %r15,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   1110 <sqlite3_prepare_v2@plt>
movb   $0x0,0x0(%r13)
mov    0x8(%rsp),%rdi
call   10b0 <sqlite3_step@plt>
mov    0x2cb9(%rip),%r12
cmp    (%r12),%eax
jne    13a5 <sqlite_get_black_ip_list_all+0x1b5>
lea    0xd68(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_int@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1090 <sqlite3_column_int@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1090 <sqlite3_column_int@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    $0x4fffff,%edx
sub    %eax,%edx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <strncat@plt>
mov    0x8(%rsp),%rdi
call   10b0 <sqlite3_step@plt>
cmp    (%r12),%eax
je     1330 <sqlite_get_black_ip_list_all+0x140>
mov    %r13,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbp
movb   $0x0,0x0(%r13,%rbp,1)
mov    0x8(%rsp),%rdi
call   1100 <sqlite3_finalize@plt>
mov    0x10(%rsp),%rdi
call   10d0 <sqlite3_close@plt>
add    $0x1,%rbp
cmp    0x28(%rsp),%rbp
jbe    1437 <sqlite_get_black_ip_list_all+0x247>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
jmp    1423 <sqlite_get_black_ip_list_all+0x233>
mov    0x2bdd(%rip),%rax
mov    0x2bf6(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
mov    0x10(%rsp),%rdi
call   10a0 <sqlite3_errmsg@plt>
lea    0xc1c(%rip),%rsi
lea    0x130(%rsp),%rdx
mov    %ebp,%edi
mov    %eax,%ecx
call   10f0 <syslog@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
jmp    1463 <sqlite_get_black_ip_list_all+0x273>
mov    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   10c0 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x338,%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 = [78 x i8] c"ERROR opening SQLite DB '%s' from function [sqlite_get_black_ip_list_all]: %s\00"
@.str.4 = [17 x i8] c"SELECT * FROM %s\00"
@.str.5 = [14 x i8] c"black_ip_list\00"
@SQLITE_ROW = global i32 0
@.str.6 = [10 x i8] c"%d:%d:%d>\00"
define i32 @sqlite_get_black_ip_list_all(i8* %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca [256 x i8]
%9 = alloca [513 x i8]
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %3
%20 = getelementptr inbounds [513 x i8], [513 x i8]* %9, i64 0, i64 0
%21 = load i8*, i8** %7
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %20, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %33
23: ; preds = %3
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%25 = call i32* @getcwd(i8* %24, i32 256)
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %4
br label %123
28: ; preds = %23
%29 = getelementptr inbounds [513 x i8], [513 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%31 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %29, i32 512, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %28
br label %33
33: ; preds = %32, %19
%34 = call i64 @malloc(i32 5242880)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %13
%36 = call i64 @malloc(i32 60)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %14
%38 = call i64 @malloc(i32 512)
%39 = inttoptr i64 %38 to i8*
store i8* %39, i8** %15
%40 = getelementptr inbounds [513 x i8], [513 x i8]* %9, i64 0, i64 0
%41 = call i32 @sqlite3_open(i8* %40, i32** %10)
store i32 %41, i32* %12
%42 = load i32, i32* %12
%43 = load i32, i32* @SQLITE_OK
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %33
%46 = load i32, i32* @LOG_INFO
%47 = load i32, i32* @LOG_LOCAL6
%48 = or i32 %46, %47
%49 = getelementptr inbounds [513 x i8], [513 x i8]* %9, i64 0, i64 0
%50 = load i32*, i32** %10
%51 = call i32 @sqlite3_errmsg(i32* %50)
%52 = call i32 @syslog(i32 %48, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %49, i32 %51)
%53 = load i8*, i8** %14
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %15
%56 = call i32 @free(i8* %55)
%57 = load i8*, i8** %13
%58 = call i32 @free(i8* %57)
store i32 1, i32* %4
br label %123
59: ; preds = %33
%60 = load i8*, i8** %15
%61 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %60, i32 512, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%62 = load i32*, i32** %10
%63 = load i8*, i8** %15
%64 = load i8*, i8** %15
%65 = call i32 @strlen(i8* %64)
%66 = call i32 @sqlite3_prepare_v2(i32* %62, i8* %63, i32 %65, i32** %11, i32* null)
%67 = load i8*, i8** %13
store i8 0, i8* %67
br label %68
68: ; preds = %73, %59
%69 = load i32*, i32** %11
%70 = call i32 @sqlite3_step(i32* %69)
store i32 %70, i32* %12
%71 = load i32, i32* @SQLITE_ROW
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %89
73: ; preds = %68
%74 = load i8*, i8** %14
%75 = load i32*, i32** %11
%76 = call i32 @sqlite3_column_int(i32* %75, i32 0)
%77 = load i32*, i32** %11
%78 = call i32 @sqlite3_column_int(i32* %77, i32 1)
%79 = load i32*, i32** %11
%80 = call i32 @sqlite3_column_int(i32* %79, i32 2)
%81 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %74, i32 60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %76, i32 %78, i32 %80)
%82 = load i8*, i8** %13
%83 = load i8*, i8** %14
%84 = load i8*, i8** %13
%85 = call i32 @strlen(i8* %84)
%86 = sub nsw i32 5242880, %85
%87 = sub nsw i32 %86, 1
%88 = call i32 @strncat(i8* %82, i8* %83, i32 %87)
br label %68
89: ; preds = %68
%90 = load i8*, i8** %13
%91 = call i32 @strlen(i8* %90)
%92 = sext i32 %91 to i64
store i64 %92, i64* %16
%93 = load i8*, i8** %13
%94 = load i64, i64* %16
%95 = getelementptr inbounds i8, i8* %93, i64 %94
store i8 0, i8* %95
%96 = load i32*, i32** %11
%97 = call i32 @sqlite3_finalize(i32* %96)
%98 = load i32*, i32** %10
%99 = call i32 @sqlite3_close(i32* %98)
%100 = load i64, i64* %16
%101 = add i64 %100, 1
%102 = load i64, i64* %6
%103 = icmp ugt i64 %101, %102
br i1 %103, label %104, label %111
104: ; preds = %89
%105 = load i8*, i8** %14
%106 = call i32 @free(i8* %105)
%107 = load i8*, i8** %15
%108 = call i32 @free(i8* %107)
%109 = load i8*, i8** %13
%110 = call i32 @free(i8* %109)
store i32 1, i32* %4
br label %123
111: ; preds = %89
%112 = load i8*, i8** %5
%113 = load i8*, i8** %13
%114 = load i64, i64* %16
%115 = add i64 %114, 1
%116 = call i32 @memcpy(i8* %112, i8* %113, i64 %115)
%117 = load i8*, i8** %14
%118 = call i32 @free(i8* %117)
%119 = load i8*, i8** %15
%120 = call i32 @free(i8* %119)
%121 = load i8*, i8** %13
%122 = call i32 @free(i8* %121)
store i32 0, i32* %4
br label %123
123: ; preds = %111, %104, %45, %27
%124 = load i32, i32* %4
ret i32 %124
}

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 = [78 x i8] c"ERROR opening SQLite DB '%s' from function [sqlite_get_black_ip_list_all]: %s\00"
@.str.4 = [17 x i8] c"SELECT * FROM %s\00"
@.str.5 = [14 x i8] c"black_ip_list\00"
@SQLITE_ROW = global i32 0
@.str.6 = [10 x i8] c"%d:%d:%d>\00"
define i32 @sqlite_get_black_ip_list_all(i8* %0, i64 %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca [513 x i8]
%6 = alloca i32*
%7 = alloca i32*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [513 x i8], [513 x i8]* %5, i64 0, i64 0
%10 = icmp eq i8* %2, null
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %18
13: ; preds = %3
%14 = call i32* @getcwd(i8* %8, i32 256)
%15 = icmp eq i32* %14, null
br i1 %15, label %85, label %16
16: ; preds = %13
%17 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 512, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = bitcast i32** %6 to i8*
%20 = bitcast i32** %7 to i8*
%21 = call i64 @malloc(i32 5242880)
%22 = inttoptr i64 %21 to i8*
%23 = call i64 @malloc(i32 60)
%24 = inttoptr i64 %23 to i8*
%25 = call i64 @malloc(i32 512)
%26 = inttoptr i64 %25 to i8*
%27 = call i32 @sqlite3_open(i8* %9, i32** %6)
%28 = load i32, i32* @SQLITE_OK
%29 = icmp eq i32 %27, %28
br i1 %29, label %40, label %30
30: ; preds = %18
%31 = load i32, i32* @LOG_INFO
%32 = load i32, i32* @LOG_LOCAL6
%33 = or i32 %32, %31
%34 = load i32*, i32** %6
%35 = call i32 @sqlite3_errmsg(i32* %34)
%36 = call i32 @syslog(i32 %33, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %35)
%37 = call i32 @free(i8* %24)
%38 = call i32 @free(i8* %26)
%39 = call i32 @free(i8* %22)
br label %83
40: ; preds = %18
%41 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 512, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%42 = load i32*, i32** %6
%43 = call i32 @strlen(i8* %26)
%44 = call i32 @sqlite3_prepare_v2(i32* %42, i8* %26, i32 %43, i32** %7, i32* null)
store i8 0, i8* %22
%45 = load i32*, i32** %7
%46 = call i32 @sqlite3_step(i32* %45)
%47 = load i32, i32* @SQLITE_ROW
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %64
49: ; preds = %40, %49
%50 = load i32*, i32** %7
%51 = call i32 @sqlite3_column_int(i32* %50, i32 0)
%52 = load i32*, i32** %7
%53 = call i32 @sqlite3_column_int(i32* %52, i32 1)
%54 = load i32*, i32** %7
%55 = call i32 @sqlite3_column_int(i32* %54, i32 2)
%56 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %51, i32 %53, i32 %55)
%57 = call i32 @strlen(i8* %22)
%58 = sub i32 5242879, %57
%59 = call i32 @strncat(i8* %22, i8* %24, i32 %58)
%60 = load i32*, i32** %7
%61 = call i32 @sqlite3_step(i32* %60)
%62 = load i32, i32* @SQLITE_ROW
%63 = icmp eq i32 %61, %62
br i1 %63, label %49, label %64
64: ; preds = %49, %40
%65 = call i32 @strlen(i8* %22)
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %22, i64 %66
store i8 0, i8* %67
%68 = load i32*, i32** %7
%69 = call i32 @sqlite3_finalize(i32* %68)
%70 = load i32*, i32** %6
%71 = call i32 @sqlite3_close(i32* %70)
%72 = add nsw i64 %66, 1
%73 = icmp ugt i64 %72, %1
br i1 %73, label %74, label %78
74: ; preds = %64
%75 = call i32 @free(i8* %24)
%76 = call i32 @free(i8* %26)
%77 = call i32 @free(i8* %22)
br label %83
78: ; preds = %64
%79 = call i32 @memcpy(i8* %0, i8* %22, i64 %72)
%80 = call i32 @free(i8* %24)
%81 = call i32 @free(i8* %26)
%82 = call i32 @free(i8* %22)
br label %83
83: ; preds = %74, %78, %30
%84 = phi i32 [ 1, %30 ], [ 1, %74 ], [ 0, %78 ]
br label %85
85: ; preds = %13, %83
%86 = phi i32 [ %84, %83 ], [ 1, %13 ]
ret i32 %86
}