#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 */
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ SQLITE_STATIC;
int /*<<< orphan*/ assert(int);
int sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *, int,
                      int /*<<< orphan*/);
scalar_t__ sqlite3_column_int(int /*<<< orphan*/ *, 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*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
int db_nickname_is_forbidden(sqlite3 *db, const char nickname[((9) + 1)]) {
  static sqlite3_stmt *stmt;
  static const char query[] =
      "SELECT COUNT(*) FROM forbidden_nick WHERE nickname = ?;";
  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);
  ret = sqlite3_bind_text(stmt, 1, nickname, -1, SQLITE_STATIC);
  assert(ret == SQLITE_OK);
  ret = sqlite3_step(stmt);
  assert(ret == SQLITE_ROW);
  return sqlite3_column_int(stmt, 0) > 0;
}


x86 assembly (clang, -O0):
<db_nickname_is_forbidden>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11cc <db_nickname_is_forbidden+0x4c>
cmpq   $0x0,0x2ec5(%rip)
je     11c0 <db_nickname_is_forbidden+0x40>
mov    0x2eb8(%rip),%rdi
call   1090 <sqlite3_finalize@plt>
movq   $0x0,0x2ea8(%rip)
movl   $0x0,-0x4(%rbp)
jmp    12c8 <db_nickname_is_forbidden+0x148>
jmp    11d1 <db_nickname_is_forbidden+0x51>
jmp    11d6 <db_nickname_is_forbidden+0x56>
cmpq   $0x0,0x2e8a(%rip)
jne    1232 <db_nickname_is_forbidden+0xb2>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe0d(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xdfb(%rip),%rsi
lea    0x2e5c(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2dc5(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    1237 <db_nickname_is_forbidden+0xb7>
mov    0x2e2a(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e1e(%rip),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2d83(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d74(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2dde(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2db6(%rip),%rdi
xor    %esi,%esi
call   1050 <sqlite3_column_int@plt>
cmp    $0x0,%rax
setg   %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_nickname_is_forbidden>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2ed9(%rip),%rdi
test   %rbx,%rbx
je     1255 <db_nickname_is_forbidden+0xd5>
mov    %rsi,%r14
test   %rdi,%rdi
jne    11e1 <db_nickname_is_forbidden+0x61>
lea    0xe59(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x2eb2(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    0x2e1b(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e87(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    0x2e7b(%rip),%rdi
mov    0x2de4(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    0x2dd8(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e44(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2da0(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e24(%rip),%rdi
xor    %esi,%esi
call   1050 <sqlite3_column_int@plt>
xor    %ebx,%ebx
test   %rax,%rax
setg   %bl
jmp    126c <db_nickname_is_forbidden+0xec>
xor    %ebx,%ebx
test   %rdi,%rdi
je     126c <db_nickname_is_forbidden+0xec>
call   1090 <sqlite3_finalize@plt>
movq   $0x0,0x2dfc(%rip)
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@db_nickname_is_forbidden.stmt = internal global i32* null
@db_nickname_is_forbidden.query = internal constant [56 x i8] c"SELECT COUNT(*) FROM forbidden_nick WHERE nickname = ?;\00"
@SQLITE_OK = global i32 0
@SQLITE_STATIC = global i32 0
@SQLITE_ROW = global i32 0
define i32 @db_nickname_is_forbidden(i32* %0, i8* %1) {
%3 = icmp eq i32* %0, null
%4 = load i32*, i32** @db_nickname_is_forbidden.stmt
%5 = icmp eq i32* %4, null
br i1 %3, label %6, label %9
6: ; preds = %2
br i1 %5, label %38, label %7
7: ; preds = %6
%8 = tail call i32 @sqlite3_finalize(i32* %4)
store i32* null, i32** @db_nickname_is_forbidden.stmt
br label %38
9: ; preds = %2
br i1 %5, label %10, label %18
10: ; preds = %9
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @db_nickname_is_forbidden.query, i64 0, i64 0))
%12 = tail call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @db_nickname_is_forbidden.query, i64 0, i64 0), i32 %11, i32** @db_nickname_is_forbidden.stmt, i32* null)
%13 = load i32, i32* @SQLITE_OK
%14 = icmp eq i32 %12, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = load i32*, i32** @db_nickname_is_forbidden.stmt
br label %18
18: ; preds = %10, %9
%19 = phi i32* [ %17, %10 ], [ %4, %9 ]
%20 = tail call i32 @sqlite3_reset(i32* %19)
%21 = load i32*, i32** @db_nickname_is_forbidden.stmt
%22 = load i32, i32* @SQLITE_STATIC
%23 = tail call i32 @sqlite3_bind_text(i32* %21, i32 1, i8* %1, i32 -1, i32 %22)
%24 = load i32, i32* @SQLITE_OK
%25 = icmp eq i32 %23, %24
%26 = zext i1 %25 to i32
%27 = tail call i32 @assert(i32 %26)
%28 = load i32*, i32** @db_nickname_is_forbidden.stmt
%29 = tail call i32 @sqlite3_step(i32* %28)
%30 = load i32, i32* @SQLITE_ROW
%31 = icmp eq i32 %29, %30
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = load i32*, i32** @db_nickname_is_forbidden.stmt
%35 = tail call i64 @sqlite3_column_int(i32* %34, i32 0)
%36 = icmp sgt i64 %35, 0
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %6, %7, %18
%39 = phi i32 [ %37, %18 ], [ 0, %7 ], [ 0, %6 ]
ret i32 %39
}