#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_value;
typedef int /*<<< orphan*/ sqlite3_context;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sqlite3_result_int(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sqlite3_value_text(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ verify_essid(char *);
void sql_verify_essid(sqlite3_context *context, int argc,
                      sqlite3_value **values) {
  char *essid = (char *)sqlite3_value_text(values[0]);
  if (argc != 1 || essid == 0) {
    fprintf(stderr, "SQL function VERIFY_ESSID called with invalid arguments");
    return;
  }
  sqlite3_result_int(context, verify_essid(essid));
}


x86 assembly (clang, -O0):
<sql_verify_essid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1060 <sqlite3_value_text@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1178 <sql_verify_essid+0x38>
cmpq   $0x0,-0x20(%rbp)
jne    1192 <sql_verify_essid+0x52>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ae <sql_verify_essid+0x6e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <verify_essid@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <sqlite3_result_int@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sql_verify_essid>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdx),%rdi
call   1060 <sqlite3_value_text@plt>
cmp    $0x1,%ebp
jne    1172 <sql_verify_essid+0x32>
test   %rax,%rax
je     1172 <sql_verify_essid+0x32>
mov    %rax,%rdi
call   1030 <verify_essid@plt>
mov    %rbx,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <sqlite3_result_int@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [56 x i8] c"SQL function VERIFY_ESSID called with invalid arguments\00"
define void @sql_verify_essid(i32* %0, i32 %1, i32** %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32** %2, i32*** %6
%8 = load i32**, i32*** %6
%9 = getelementptr inbounds i32*, i32** %8, i64 0
%10 = load i32*, i32** %9
%11 = call i64 @sqlite3_value_text(i32* %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %7
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15, %3
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %26
21: ; preds = %15
%22 = load i32*, i32** %4
%23 = load i8*, i8** %7
%24 = call i32 @verify_essid(i8* %23)
%25 = call i32 @sqlite3_result_int(i32* %22, i32 %24)
br label %26
26: ; preds = %21, %18
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [56 x i8] c"SQL function VERIFY_ESSID called with invalid arguments\00"
define void @sql_verify_essid(i32* %0, i32 %1, i32** nocapture %2) {
%4 = load i32*, i32** %2
%5 = tail call i64 @sqlite3_value_text(i32* %4)
%6 = icmp ne i32 %1, 1
%7 = icmp eq i64 %5, 0
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %16
12: ; preds = %3
%13 = inttoptr i64 %5 to i8*
%14 = tail call i32 @verify_essid(i8* %13)
%15 = tail call i32 @sqlite3_result_int(i32* %0, i32 %14)
br label %16
16: ; preds = %12, %9
ret void
}