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

/* Variables and functions */
scalar_t__ SQLITE_DONE;
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ SQLITE_STATIC;
int /*<<< orphan*/ *database_prepare(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ logprintf(int, char *, ...);
int /*<<< orphan*/ printf(char *);
scalar_t__ sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *, int,
                             int /*<<< orphan*/);
int sqlite3_changes(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_errmsg(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
int sqlite_delete_msa(sqlite3 *db, const char *user) {
  char *sql = "DELETE FROM smtpd WHERE smtpd_user = ?;";
  sqlite3_stmt *stmt = database_prepare(db, sql);
  if (!stmt) {
    return 2;
  }
  if (sqlite3_bind_text(stmt, 1, user, -1, SQLITE_STATIC) != SQLITE_OK) {
    logprintf(1, "Failed to bind a statement parameter\n");
    sqlite3_finalize(stmt);
    return 3;
  }
  if (sqlite3_step(stmt) != SQLITE_DONE) {
    logprintf(0, "%s\n", sqlite3_errmsg(db));
    sqlite3_finalize(stmt);
    return 5;
  }
  if (sqlite3_changes(db) < 1) {
    printf("No entry found, none modified\n");
  }
  sqlite3_finalize(stmt);
  return 0;
}


x86 assembly (clang, -O0):
<sqlite_delete_msa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe69(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <database_prepare@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c3 <sqlite_delete_msa+0x43>
movl   $0x2,-0x4(%rbp)
jmp    1293 <sqlite_delete_msa+0x113>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2e06(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    0x2dfd(%rip),%rcx
cmp    (%rcx),%rax
je     121c <sqlite_delete_msa+0x9c>
mov    $0x1,%edi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   10a0 <logprintf@plt>
mov    -0x28(%rbp),%rdi
call   1090 <sqlite3_finalize@plt>
movl   $0x3,-0x4(%rbp)
jmp    1293 <sqlite_delete_msa+0x113>
mov    -0x28(%rbp),%rdi
call   1050 <sqlite3_step@plt>
mov    0x2da4(%rip),%rcx
cmp    (%rcx),%rax
je     1265 <sqlite_delete_msa+0xe5>
mov    -0x10(%rbp),%rdi
call   1040 <sqlite3_errmsg@plt>
mov    %eax,%edx
xor    %edi,%edi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   10a0 <logprintf@plt>
mov    -0x28(%rbp),%rdi
call   1090 <sqlite3_finalize@plt>
movl   $0x5,-0x4(%rbp)
jmp    1293 <sqlite_delete_msa+0x113>
mov    -0x10(%rbp),%rdi
call   1070 <sqlite3_changes@plt>
cmp    $0x1,%eax
jge    1283 <sqlite_delete_msa+0x103>
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1090 <sqlite3_finalize@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite_delete_msa>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe6e(%rip),%rsi
call   1060 <database_prepare@plt>
test   %rax,%rax
je     11fa <sqlite_delete_msa+0x7a>
mov    %rax,%r14
mov    0x2e32(%rip),%rax
mov    (%rax),%r8d
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    0x2e23(%rip),%rcx
cmp    (%rcx),%rax
jne    1201 <sqlite_delete_msa+0x81>
mov    %r14,%rdi
call   1050 <sqlite3_step@plt>
mov    0x2df7(%rip),%rcx
cmp    (%rcx),%rax
jne    121b <sqlite_delete_msa+0x9b>
mov    %r15,%rdi
call   1070 <sqlite3_changes@plt>
xor    %ebx,%ebx
test   %eax,%eax
jg     123a <sqlite_delete_msa+0xba>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
jmp    123a <sqlite_delete_msa+0xba>
mov    $0x2,%ebx
jmp    1242 <sqlite_delete_msa+0xc2>
lea    0xe20(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <logprintf@plt>
mov    $0x3,%ebx
jmp    123a <sqlite_delete_msa+0xba>
mov    %r15,%rdi
call   1040 <sqlite3_errmsg@plt>
lea    0xe24(%rip),%rsi
xor    %edi,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <logprintf@plt>
mov    $0x5,%ebx
mov    %r14,%rdi
call   1090 <sqlite3_finalize@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [40 x i8] c"DELETE FROM smtpd WHERE smtpd_user = ?;\00"
@SQLITE_STATIC = global i32 0
@SQLITE_OK = global i64 0
@.str.1 = [38 x i8] c"Failed to bind a statement parameter\0A\00"
@SQLITE_DONE = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [31 x i8] c"No entry found, none modified\0A\00"
define i32 @sqlite_delete_msa(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8** %6
%8 = load i32*, i32** %4
%9 = load i8*, i8** %6
%10 = call i32* @database_prepare(i32* %8, i8* %9)
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 2, i32* %3
br label %45
14: ; preds = %2
%15 = load i32*, i32** %7
%16 = load i8*, i8** %5
%17 = load i32, i32* @SQLITE_STATIC
%18 = call i64 @sqlite3_bind_text(i32* %15, i32 1, i8* %16, i32 -1, i32 %17)
%19 = load i64, i64* @SQLITE_OK
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = call i32 (i32, i8*, ...) @logprintf(i32 1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32*, i32** %7
%24 = call i32 @sqlite3_finalize(i32* %23)
store i32 3, i32* %3
br label %45
25: ; preds = %14
%26 = load i32*, i32** %7
%27 = call i64 @sqlite3_step(i32* %26)
%28 = load i64, i64* @SQLITE_DONE
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i32*, i32** %4
%32 = call i32 @sqlite3_errmsg(i32* %31)
%33 = call i32 (i32, i8*, ...) @logprintf(i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %7
%35 = call i32 @sqlite3_finalize(i32* %34)
store i32 5, i32* %3
br label %45
36: ; preds = %25
%37 = load i32*, i32** %4
%38 = call i32 @sqlite3_changes(i32* %37)
%39 = icmp slt i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = load i32*, i32** %7
%44 = call i32 @sqlite3_finalize(i32* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %42, %30, %21, %13
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [40 x i8] c"DELETE FROM smtpd WHERE smtpd_user = ?;\00"
@SQLITE_STATIC = global i32 0
@SQLITE_OK = global i64 0
@.str.1 = [38 x i8] c"Failed to bind a statement parameter\0A\00"
@SQLITE_DONE = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
@str = [30 x i8] c"No entry found, none modified\00"
define i32 @sqlite_delete_msa(i32* %0, i8* %1) {
%3 = tail call i32* @database_prepare(i32* %0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %27, label %5
5: ; preds = %2
%6 = load i32, i32* @SQLITE_STATIC
%7 = tail call i64 @sqlite3_bind_text(i32* %3, i32 1, i8* %1, i32 -1, i32 %6)
%8 = load i64, i64* @SQLITE_OK
%9 = icmp eq i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 (i32, i8*, ...) @logprintf(i32 1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %24
12: ; preds = %5
%13 = tail call i64 @sqlite3_step(i32* %3)
%14 = load i64, i64* @SQLITE_DONE
%15 = icmp eq i64 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i32 @sqlite3_errmsg(i32* %0)
%18 = tail call i32 (i32, i8*, ...) @logprintf(i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %12
%20 = tail call i32 @sqlite3_changes(i32* %0)
%21 = icmp slt i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %19, %22, %10, %16
%25 = phi i32 [ 5, %16 ], [ 3, %10 ], [ 0, %22 ], [ 0, %19 ]
%26 = tail call i32 @sqlite3_finalize(i32* %3)
br label %27
27: ; preds = %24, %2
%28 = phi i32 [ 2, %2 ], [ %25, %24 ]
ret i32 %28
}