#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*/ SQLITE_STATIC;
int /*<<< orphan*/ assert(int);
int sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
int sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *, int,
                      int /*<<< orphan*/);
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_add_expiring_forbidden_nick(sqlite3 *db, const char *nickname,
                                   int seconds) {
  static sqlite3_stmt *stmt;
  static const char query[] = "INSERT INTO forbidden_nick (nickname, expiry) "
                              "VALUES (?, strftime('%s') + ?);";
  int ret;
  do {
    if (db == NULL) {
      if (stmt != NULL) {
        sqlite3_finalize(stmt);
        stmt = NULL;
      }
      return 0;
    }
  } while (0);
  if (seconds < 0)
    return 1;
  do {
    if (stmt == NULL) {
      ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
      assert(ret == SQLITE_OK);
    }
  } while (0);
  sqlite3_reset(stmt);
  ret = sqlite3_bind_text(stmt, 1, nickname, -1, SQLITE_STATIC);
  assert(ret == SQLITE_OK);
  ret = sqlite3_bind_int(stmt, 2, seconds);
  assert(ret == SQLITE_OK);
  return (sqlite3_step(stmt) != SQLITE_DONE);
}


x86 assembly (clang, -O0):
<db_add_expiring_forbidden_nick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11cf <db_add_expiring_forbidden_nick+0x4f>
cmpq   $0x0,0x2ec2(%rip)
je     11c3 <db_add_expiring_forbidden_nick+0x43>
mov    0x2eb5(%rip),%rdi
call   1090 <sqlite3_finalize@plt>
movq   $0x0,0x2ea5(%rip)
movl   $0x0,-0x4(%rbp)
jmp    12ed <db_add_expiring_forbidden_nick+0x16d>
jmp    11d4 <db_add_expiring_forbidden_nick+0x54>
cmpl   $0x0,-0x1c(%rbp)
jge    11ea <db_add_expiring_forbidden_nick+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    12ed <db_add_expiring_forbidden_nick+0x16d>
jmp    11ef <db_add_expiring_forbidden_nick+0x6f>
cmpq   $0x0,0x2e71(%rip)
jne    124b <db_add_expiring_forbidden_nick+0xcb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xdf4(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xde2(%rip),%rsi
lea    0x2e43(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2dac(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    1250 <db_add_expiring_forbidden_nick+0xd0>
mov    0x2e11(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e05(%rip),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2d6a(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2d5b(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2dc5(%rip),%rdi
mov    -0x1c(%rbp),%edx
mov    $0x2,%esi
call   1040 <sqlite3_bind_int@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2d2b(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2d95(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2cf1(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_add_expiring_forbidden_nick>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1266 <db_add_expiring_forbidden_nick+0xe6>
mov    %edx,%ebp
test   %edx,%edx
js     1286 <db_add_expiring_forbidden_nick+0x106>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ec1(%rip),%rdi
test   %rdi,%rdi
jne    11ed <db_add_expiring_forbidden_nick+0x6d>
lea    0xe4d(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x2ea6(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    0x2e0f(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e7b(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e6f(%rip),%rdi
mov    0x2dd8(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    0x2dcc(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e38(%rip),%rdi
mov    $0x2,%esi
mov    %ebp,%edx
call   1040 <sqlite3_bind_int@plt>
xor    %edi,%edi
cmp    (%rbx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e18(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2d74(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
setne  %bl
jmp    128b <db_add_expiring_forbidden_nick+0x10b>
mov    0x2dfb(%rip),%rdi
xor    %ebx,%ebx
test   %rdi,%rdi
je     128b <db_add_expiring_forbidden_nick+0x10b>
call   1090 <sqlite3_finalize@plt>
movq   $0x0,0x2de4(%rip)
jmp    128b <db_add_expiring_forbidden_nick+0x10b>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@db_add_expiring_forbidden_nick.stmt = internal global i32* null
@db_add_expiring_forbidden_nick.query = internal constant [78 x i8] c"INSERT INTO forbidden_nick (nickname, expiry) VALUES (?, strftime('%s') + ?);\00"
@SQLITE_OK = global i32 0
@SQLITE_STATIC = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_add_expiring_forbidden_nick(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
br label %9
9: ; preds = %3
%10 = load i32*, i32** %5
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%17 = call i32 @sqlite3_finalize(i32* %16)
store i32* null, i32** @db_add_expiring_forbidden_nick.stmt
br label %18
18: ; preds = %15, %12
store i32 0, i32* %4
br label %63
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %4
br label %63
24: ; preds = %20
br label %25
25: ; preds = %24
%26 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32*, i32** %5
%30 = call i32 @strlen(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @db_add_expiring_forbidden_nick.query, i64 0, i64 0))
%31 = call i32 @sqlite3_prepare_v2(i32* %29, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @db_add_expiring_forbidden_nick.query, i64 0, i64 0), i32 %30, i32** @db_add_expiring_forbidden_nick.stmt, i32* null)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = load i32, i32* @SQLITE_OK
%34 = icmp eq i32 %32, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %37
37: ; preds = %28, %25
br label %38
38: ; preds = %37
%39 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%40 = call i32 @sqlite3_reset(i32* %39)
%41 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%42 = load i8*, i8** %6
%43 = load i32, i32* @SQLITE_STATIC
%44 = call i32 @sqlite3_bind_text(i32* %41, i32 1, i8* %42, i32 -1, i32 %43)
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = load i32, i32* @SQLITE_OK
%47 = icmp eq i32 %45, %46
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%51 = load i32, i32* %7
%52 = call i32 @sqlite3_bind_int(i32* %50, i32 2, i32 %51)
store i32 %52, i32* %8
%53 = load i32, i32* %8
%54 = load i32, i32* @SQLITE_OK
%55 = icmp eq i32 %53, %54
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%59 = call i64 @sqlite3_step(i32* %58)
%60 = load i64, i64* @SQLITE_DONE
%61 = icmp ne i64 %59, %60
%62 = zext i1 %61 to i32
store i32 %62, i32* %4
br label %63
63: ; preds = %38, %23, %18
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
@db_add_expiring_forbidden_nick.stmt = internal global i32* null
@db_add_expiring_forbidden_nick.query = internal constant [78 x i8] c"INSERT INTO forbidden_nick (nickname, expiry) VALUES (?, strftime('%s') + ?);\00"
@SQLITE_OK = global i32 0
@SQLITE_STATIC = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_add_expiring_forbidden_nick(i32* %0, i8* %1, i32 %2) {
%4 = icmp eq i32* %0, null
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%7 = icmp eq i32* %6, null
br i1 %7, label %44, label %8
8: ; preds = %5
%9 = tail call i32 @sqlite3_finalize(i32* %6)
store i32* null, i32** @db_add_expiring_forbidden_nick.stmt
br label %44
10: ; preds = %3
%11 = icmp slt i32 %2, 0
br i1 %11, label %44, label %12
12: ; preds = %10
%13 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @db_add_expiring_forbidden_nick.query, i64 0, i64 0))
%17 = tail call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @db_add_expiring_forbidden_nick.query, i64 0, i64 0), i32 %16, i32** @db_add_expiring_forbidden_nick.stmt, i32* null)
%18 = load i32, i32* @SQLITE_OK
%19 = icmp eq i32 %17, %18
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
br label %23
23: ; preds = %15, %12
%24 = phi i32* [ %22, %15 ], [ %13, %12 ]
%25 = tail call i32 @sqlite3_reset(i32* %24)
%26 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%27 = load i32, i32* @SQLITE_STATIC
%28 = tail call i32 @sqlite3_bind_text(i32* %26, i32 1, i8* %1, i32 -1, i32 %27)
%29 = load i32, i32* @SQLITE_OK
%30 = icmp eq i32 %28, %29
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%34 = tail call i32 @sqlite3_bind_int(i32* %33, i32 2, i32 %2)
%35 = load i32, i32* @SQLITE_OK
%36 = icmp eq i32 %34, %35
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = load i32*, i32** @db_add_expiring_forbidden_nick.stmt
%40 = tail call i64 @sqlite3_step(i32* %39)
%41 = load i64, i64* @SQLITE_DONE
%42 = icmp ne i64 %40, %41
%43 = zext i1 %42 to i32
br label %44
44: ; preds = %10, %5, %8, %23
%45 = phi i32 [ %43, %23 ], [ 0, %8 ], [ 0, %5 ], [ 1, %10 ]
ret i32 %45
}