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

/* Variables and functions */
int SQLITE_ROW;
int /*<<< orphan*/ SQLITE_STATIC;
int /*<<< orphan*/ *sql_prepare(char *);
int /*<<< orphan*/ sqlite3_bind_text(int /*<<< orphan*/ *, int, char const *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
bool user_in_access_list(const char *user) {
  int status;
  sqlite3_stmt *stmt;
  stmt = sql_prepare("SELECT user_id FROM users WHERE name = ?1");
  if (!stmt)
    return false;
  sqlite3_bind_text(stmt, 1, user, strlen(user), SQLITE_STATIC);
  status = sqlite3_step(stmt);
  sqlite3_finalize(stmt);
  return status == SQLITE_ROW;
}


x86 assembly (clang, -O0):
<user_in_access_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe9d(%rip),%rdi
call   1050 <sql_prepare@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1183 <user_in_access_list+0x33>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <user_in_access_list+0x96>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e33(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1060 <sqlite3_bind_text@plt>
mov    -0x20(%rbp),%rdi
call   1040 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <sqlite3_finalize@plt>
mov    -0x14(%rbp),%eax
mov    0x2dff(%rip),%rcx
cmp    (%rcx),%eax
sete   %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):
<user_in_access_list>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea2(%rip),%rdi
call   1050 <sql_prepare@plt>
test   %rax,%rax
je     11b1 <user_in_access_list+0x61>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    0x2e66(%rip),%rcx
mov    (%rcx),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <sqlite3_bind_text@plt>
mov    %rbx,%rdi
call   1040 <sqlite3_step@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <sqlite3_finalize@plt>
mov    0x2e30(%rip),%rcx
xor    %eax,%eax
cmp    (%rcx),%ebp
sete   %al
jmp    11b3 <user_in_access_list+0x63>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"SELECT user_id FROM users WHERE name = ?1\00"
@SQLITE_STATIC = global i32 0
@SQLITE_ROW = global i32 0
define i32 @user_in_access_list(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
%6 = call i32* @sql_prepare(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 0, i32* %2
br label %25
10: ; preds = %1
%11 = load i32*, i32** %5
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = load i32, i32* @SQLITE_STATIC
%16 = call i32 @sqlite3_bind_text(i32* %11, i32 1, i8* %12, i32 %14, i32 %15)
%17 = load i32*, i32** %5
%18 = call i32 @sqlite3_step(i32* %17)
store i32 %18, i32* %4
%19 = load i32*, i32** %5
%20 = call i32 @sqlite3_finalize(i32* %19)
%21 = load i32, i32* %4
%22 = load i32, i32* @SQLITE_ROW
%23 = icmp eq i32 %21, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %2
br label %25
25: ; preds = %10, %9
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [42 x i8] c"SELECT user_id FROM users WHERE name = ?1\00"
@SQLITE_STATIC = global i32 0
@SQLITE_ROW = global i32 0
define i32 @user_in_access_list(i8* %0) {
%2 = tail call i32* @sql_prepare(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = load i32, i32* @SQLITE_STATIC
%7 = tail call i32 @sqlite3_bind_text(i32* %2, i32 1, i8* %0, i32 %5, i32 %6)
%8 = tail call i32 @sqlite3_step(i32* %2)
%9 = tail call i32 @sqlite3_finalize(i32* %2)
%10 = load i32, i32* @SQLITE_ROW
%11 = icmp eq i32 %8, %10
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %1, %4
%14 = phi i32 [ %12, %4 ], [ 0, %1 ]
ret i32 %14
}