#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;
int SQLITE_OK;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                       int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_reset(int /*<<< orphan*/ *);
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
int db_del_expired_forbidden_nicks(sqlite3 *db) {
  static sqlite3_stmt *stmt;
  static const char query[] = "DELETE FROM forbidden_nick WHERE expiry != 0 "
                              "AND strftime('%s') + 0 >= expiry;";
  int ret;
  do {
    if (db == NULL) {
      if (stmt != NULL) {
        sqlite3_finalize(stmt);
        stmt = NULL;
      }
      return 0;
    }
  } while (0);
  do {
    if (stmt == NULL) {
      ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
      assert(ret == SQLITE_OK);
    }
  } while (0);
  sqlite3_reset(stmt);
  return (sqlite3_step(stmt) != SQLITE_DONE);
}


x86 assembly (clang, -O0):
<db_del_expired_forbidden_nicks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a8 <db_del_expired_forbidden_nicks+0x48>
cmpq   $0x0,0x2ed9(%rip)
je     119c <db_del_expired_forbidden_nicks+0x3c>
mov    0x2ecc(%rip),%rdi
call   1070 <sqlite3_finalize@plt>
movq   $0x0,0x2ebc(%rip)
movl   $0x0,-0x4(%rbp)
jmp    1240 <db_del_expired_forbidden_nicks+0xe0>
jmp    11ad <db_del_expired_forbidden_nicks+0x4d>
jmp    11b2 <db_del_expired_forbidden_nicks+0x52>
cmpq   $0x0,0x2e9e(%rip)
jne    120e <db_del_expired_forbidden_nicks+0xae>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe31(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe1f(%rip),%rsi
lea    0x2e70(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1080 <sqlite3_prepare_v2@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2de9(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    1213 <db_del_expired_forbidden_nicks+0xb3>
mov    0x2e3e(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e32(%rip),%rdi
call   1060 <sqlite3_step@plt>
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_del_expired_forbidden_nicks>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eea(%rip),%rdi
test   %rbx,%rbx
je     11db <db_del_expired_forbidden_nicks+0x7b>
test   %rdi,%rdi
jne    11b9 <db_del_expired_forbidden_nicks+0x59>
lea    0xe81(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x2eca(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   1080 <sqlite3_prepare_v2@plt>
mov    0x2e43(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1050 <assert@plt>
mov    0x2e9f(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e93(%rip),%rdi
call   1060 <sqlite3_step@plt>
mov    0x2e07(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
setne  %bl
jmp    11f2 <db_del_expired_forbidden_nicks+0x92>
xor    %ebx,%ebx
test   %rdi,%rdi
je     11f2 <db_del_expired_forbidden_nicks+0x92>
call   1070 <sqlite3_finalize@plt>
movq   $0x0,0x2e66(%rip)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@db_del_expired_forbidden_nicks.stmt = internal global i32* null
@db_del_expired_forbidden_nicks.query = internal constant [79 x i8] c"DELETE FROM forbidden_nick WHERE expiry != 0 AND strftime('%s') + 0 >= expiry;\00"
@SQLITE_OK = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_del_expired_forbidden_nicks(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
br label %5
5: ; preds = %1
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%13 = call i32 @sqlite3_finalize(i32* %12)
store i32* null, i32** @db_del_expired_forbidden_nicks.stmt
br label %14
14: ; preds = %11, %8
store i32 0, i32* %2
br label %38
15: ; preds = %5
br label %16
16: ; preds = %15
br label %17
17: ; preds = %16
%18 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32*, i32** %3
%22 = call i32 @strlen(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @db_del_expired_forbidden_nicks.query, i64 0, i64 0))
%23 = call i32 @sqlite3_prepare_v2(i32* %21, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @db_del_expired_forbidden_nicks.query, i64 0, i64 0), i32 %22, i32** @db_del_expired_forbidden_nicks.stmt, i32* null)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = load i32, i32* @SQLITE_OK
%26 = icmp eq i32 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
br label %29
29: ; preds = %20, %17
br label %30
30: ; preds = %29
%31 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%32 = call i32 @sqlite3_reset(i32* %31)
%33 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%34 = call i64 @sqlite3_step(i32* %33)
%35 = load i64, i64* @SQLITE_DONE
%36 = icmp ne i64 %34, %35
%37 = zext i1 %36 to i32
store i32 %37, i32* %2
br label %38
38: ; preds = %30, %14
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@db_del_expired_forbidden_nicks.stmt = internal global i32* null
@db_del_expired_forbidden_nicks.query = internal constant [79 x i8] c"DELETE FROM forbidden_nick WHERE expiry != 0 AND strftime('%s') + 0 >= expiry;\00"
@SQLITE_OK = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_del_expired_forbidden_nicks(i32* %0) {
%2 = icmp eq i32* %0, null
%3 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%4 = icmp eq i32* %3, null
br i1 %2, label %5, label %8
5: ; preds = %1
br i1 %4, label %25, label %6
6: ; preds = %5
%7 = tail call i32 @sqlite3_finalize(i32* %3)
store i32* null, i32** @db_del_expired_forbidden_nicks.stmt
br label %25
8: ; preds = %1
br i1 %4, label %9, label %17
9: ; preds = %8
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @db_del_expired_forbidden_nicks.query, i64 0, i64 0))
%11 = tail call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @db_del_expired_forbidden_nicks.query, i64 0, i64 0), i32 %10, i32** @db_del_expired_forbidden_nicks.stmt, i32* null)
%12 = load i32, i32* @SQLITE_OK
%13 = icmp eq i32 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
br label %17
17: ; preds = %9, %8
%18 = phi i32* [ %16, %9 ], [ %3, %8 ]
%19 = tail call i32 @sqlite3_reset(i32* %18)
%20 = load i32*, i32** @db_del_expired_forbidden_nicks.stmt
%21 = tail call i64 @sqlite3_step(i32* %20)
%22 = load i64, i64* @SQLITE_DONE
%23 = icmp ne i64 %21, %22
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %5, %6, %17
%26 = phi i32 [ %24, %17 ], [ 0, %6 ], [ 0, %5 ]
ret i32 %26
}