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

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int SQLITE_OK;
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, int, char *, int,
                           char *, unsigned long long);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/, char **);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *,
                          int /*<<< orphan*/);
int rm_entry(int country_code, int area_code, unsigned long long number,
             int listflag) {
  char *listname = (0x02 == listflag) ? "whitelist" : "blacklist";
  sqlite3 *db;
  char *errMsg = 0;
  char stmt[1024];
  int rc;
  rc = sqlite3_open("db/phonefirewall.db", &db);
  if (rc) {
    syslog(LOG_ERR, "[%s] Cant't open database: %s", "phone-firewall",
           sqlite3_errmsg(db));
    sqlite3_close(db);
    return -1;
  }
  sprintf(stmt, "DELETE FROM %s WHERE %s = %d AND %s = %d AND %s = %lld",
          listname, "countrycode", country_code, "areacode", area_code,
          "number", number);
  rc = sqlite3_exec(db, stmt, NULL, 0, &errMsg);
  if (SQLITE_OK != rc) {
    syslog(LOG_ERR, "[%s] SQL error: %s", "phone-firewall", sqlite3_errmsg(db));
    sqlite3_close(db);
    return -1;
  }
  sqlite3_close(db);
  return 0;
}


x86 assembly (clang, -O0):
<rm_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    $0x2,%edx
lea    0xe83(%rip),%rax
lea    0xe72(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe6d(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x444(%rbp)
cmpl   $0x0,-0x444(%rbp)
je     120b <rm_entry+0xab>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x448(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x448(%rbp),%edi
mov    %eax,%ecx
lea    0xe3e(%rip),%rsi
lea    0xe55(%rip),%rdx
call   1070 <syslog@plt>
mov    -0x30(%rbp),%rdi
call   1060 <sqlite3_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12de <rm_entry+0x17e>
lea    -0x440(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r11d
mov    -0x18(%rbp),%rax
lea    0xe2c(%rip),%rsi
lea    0xe5c(%rip),%rcx
lea    0xe61(%rip),%r9
lea    0xe63(%rip),%r10
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1080 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x440(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r8
call   1030 <sqlite3_exec@plt>
mov    %eax,-0x444(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
cmp    -0x444(%rbp),%eax
je     12ce <rm_entry+0x16e>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44c(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <sqlite3_errmsg@plt>
mov    -0x44c(%rbp),%edi
mov    %eax,%ecx
lea    0xdfb(%rip),%rsi
lea    0xd92(%rip),%rdx
call   1070 <syslog@plt>
mov    -0x30(%rbp),%rdi
call   1060 <sqlite3_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12de <rm_entry+0x17e>
mov    -0x30(%rbp),%rdi
call   1060 <sqlite3_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rm_entry>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
lea    0xe8b(%rip),%rdi
mov    %rsp,%rsi
call   1040 <sqlite3_open@plt>
test   %eax,%eax
je     11b3 <rm_entry+0x53>
mov    0x2e34(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xe7a(%rip),%rsi
jmp    123c <rm_entry+0xdc>
cmp    $0x2,%ebx
lea    0xe43(%rip),%rax
lea    0xe46(%rip),%rdx
cmove  %rax,%rdx
sub    $0x8,%rsp
lea    0xece(%rip),%rax
lea    0xe7b(%rip),%rsi
lea    0xeab(%rip),%rcx
lea    0xeb0(%rip),%r9
lea    0x18(%rsp),%r12
mov    %r12,%rdi
mov    %ebp,%r8d
push   %r15
push   %rax
push   %r14
call   1080 <sprintf@plt>
add    $0x20,%rsp
mov    (%rsp),%rdi
xor    %ebx,%ebx
lea    0x8(%rsp),%r8
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    0x2dc9(%rip),%rcx
cmp    %eax,(%rcx)
je     1251 <rm_entry+0xf1>
mov    0x2da6(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rdi
call   1050 <sqlite3_errmsg@plt>
lea    0xe6c(%rip),%rsi
lea    0xe03(%rip),%rdx
mov    %ebx,%edi
mov    %eax,%ecx
call   1070 <syslog@plt>
mov    $0xffffffff,%ebx
mov    (%rsp),%rdi
call   1060 <sqlite3_close@plt>
mov    %ebx,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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 = [30 x i8] c"[%s] Cant't open database: %s\00"
@.str.4 = [15 x i8] c"phone-firewall\00"
@.str.5 = [55 x i8] c"DELETE FROM %s WHERE %s = %d AND %s = %d AND %s = %lld\00"
@.str.6 = [12 x i8] c"countrycode\00"
@.str.7 = [9 x i8] c"areacode\00"
@.str.8 = [7 x i8] c"number\00"
@SQLITE_OK = global i32 0
@.str.9 = [19 x i8] c"[%s] SQL error: %s\00"
define i32 @rm_entry(i32 %0, i32 %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca [1024 x i8]
%14 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%15 = load i32, i32* %9
%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** %10
store i8* null, i8** %12
%19 = call i32 @sqlite3_open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32** %11)
store i32 %19, i32* %14
%20 = load i32, i32* %14
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %4
%23 = load i32, i32* @LOG_ERR
%24 = load i32*, i32** %11
%25 = call i32 @sqlite3_errmsg(i32* %24)
%26 = call i32 @syslog(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 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** %11
%28 = call i32 @sqlite3_close(i32* %27)
store i32 -1, i32* %5
br label %52
29: ; preds = %4
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%31 = load i8*, i8** %10
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i64, i64* %8
%35 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i64 %34)
%36 = load i32*, i32** %11
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%38 = call i32 @sqlite3_exec(i32* %36, i8* %37, i32* null, i32 0, i8** %12)
store i32 %38, i32* %14
%39 = load i32, i32* @SQLITE_OK
%40 = load i32, i32* %14
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %29
%43 = load i32, i32* @LOG_ERR
%44 = load i32*, i32** %11
%45 = call i32 @sqlite3_errmsg(i32* %44)
%46 = call i32 @syslog(i32 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %45)
%47 = load i32*, i32** %11
%48 = call i32 @sqlite3_close(i32* %47)
store i32 -1, i32* %5
br label %52
49: ; preds = %29
%50 = load i32*, i32** %11
%51 = call i32 @sqlite3_close(i32* %50)
store i32 0, i32* %5
br label %52
52: ; preds = %49, %42, %22
%53 = load i32, i32* %5
ret i32 %53
}

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 = [30 x i8] c"[%s] Cant't open database: %s\00"
@.str.4 = [15 x i8] c"phone-firewall\00"
@.str.5 = [55 x i8] c"DELETE FROM %s WHERE %s = %d AND %s = %d AND %s = %lld\00"
@.str.6 = [12 x i8] c"countrycode\00"
@.str.7 = [9 x i8] c"areacode\00"
@.str.8 = [7 x i8] c"number\00"
@SQLITE_OK = global i32 0
@.str.9 = [19 x i8] c"[%s] SQL error: %s\00"
define i32 @rm_entry(i32 %0, i32 %1, i64 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = bitcast i32** %5 to i8*
%9 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%11 = call i32 @sqlite3_open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32** %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %4
%14 = load i32, i32* @LOG_ERR
%15 = load i32*, i32** %5
%16 = call i32 @sqlite3_errmsg(i32* %15)
%17 = call i32 @syslog(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %31
18: ; preds = %4
%19 = icmp eq i32 %3, 2
%20 = select i1 %19, 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)
%21 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i64 %2)
%22 = load i32*, i32** %5
%23 = call i32 @sqlite3_exec(i32* %22, i8* %10, i32* null, i32 0, i8** %6)
%24 = load i32, i32* @SQLITE_OK
%25 = icmp eq i32 %24, %23
br i1 %25, label %31, label %26
26: ; preds = %18
%27 = load i32, i32* @LOG_ERR
%28 = load i32*, i32** %5
%29 = call i32 @sqlite3_errmsg(i32* %28)
%30 = call i32 @syslog(i32 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %18, %26, %13
%32 = phi i32 [ -1, %13 ], [ -1, %26 ], [ 0, %18 ]
%33 = load i32*, i32** %5
%34 = call i32 @sqlite3_close(i32* %33)
ret i32 %32
}