#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 /*<<< orphan*/ last_quote_modifiable(int *);
int /*<<< orphan*/ *sql_prepare(char *);
char *sql_step_single_row(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
char *get_quote(int quote_id) {
  sqlite3_stmt *stmt;
  if (quote_id == -1) {
    last_quote_modifiable(&quote_id);
    if (!quote_id)
      return NULL;
  }
  stmt = sql_prepare("SELECT quote FROM quotes WHERE quote_id = ?1");
  if (!stmt)
    return NULL;
  sqlite3_bind_int(stmt, 1, quote_id);
  return sql_step_single_row(stmt);
}


x86 assembly (clang, -O0):
<get_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    117a <get_quote+0x3a>
lea    -0xc(%rbp),%rdi
call   1030 <last_quote_modifiable@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1175 <get_quote+0x35>
movq   $0x0,-0x8(%rbp)
jmp    11c0 <get_quote+0x80>
jmp    117a <get_quote+0x3a>
lea    0xe7f(%rip),%rdi
call   1050 <sql_prepare@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a2 <get_quote+0x62>
movq   $0x0,-0x8(%rbp)
jmp    11c0 <get_quote+0x80>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1040 <sqlite3_bind_int@plt>
mov    -0x18(%rbp),%rdi
call   1060 <sql_step_single_row@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_quote>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
cmp    $0xffffffff,%edi
jne    115f <get_quote+0x1f>
lea    0xc(%rsp),%rdi
call   1030 <last_quote_modifiable@plt>
cmpl   $0x0,0xc(%rsp)
je     118e <get_quote+0x4e>
lea    0xe9a(%rip),%rdi
call   1050 <sql_prepare@plt>
test   %rax,%rax
je     118e <get_quote+0x4e>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
mov    %rax,%rdi
mov    $0x1,%esi
call   1040 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1060 <sql_step_single_row@plt>
jmp    1190 <get_quote+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"SELECT quote FROM quotes WHERE quote_id = ?1\00"
define i8* @get_quote(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = call i32 @last_quote_modifiable(i32* %3)
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
store i8* null, i8** %2
br label %24
12: ; preds = %7
br label %13
13: ; preds = %12, %1
%14 = call i32* @sql_prepare(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %4
%15 = load i32*, i32** %4
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* null, i8** %2
br label %24
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = load i32, i32* %3
%21 = call i32 @sqlite3_bind_int(i32* %19, i32 1, i32 %20)
%22 = load i32*, i32** %4
%23 = call i8* @sql_step_single_row(i32* %22)
store i8* %23, i8** %2
br label %24
24: ; preds = %18, %17, %11
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [45 x i8] c"SELECT quote FROM quotes WHERE quote_id = ?1\00"
define i8* @get_quote(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = icmp eq i32 %0, -1
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = call i32 @last_quote_modifiable(i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %4, %1
%9 = call i32* @sql_prepare(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* %2
%13 = call i32 @sqlite3_bind_int(i32* %9, i32 1, i32 %12)
%14 = call i8* @sql_step_single_row(i32* %9)
br label %15
15: ; preds = %8, %4, %11
%16 = phi i8* [ %14, %11 ], [ null, %4 ], [ null, %8 ]
ret i8* %16
}