#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_ERROR;
int SQLITE_READONLY;
int /*<<< orphan*/ SQLITE_STATIC;
int /*<<< orphan*/ last_quote_modifiable(int *);
int /*<<< orphan*/ *sql_prepare(char *);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
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 *);
int modify_last_quote(const char *quote) {
  int status, quote_id;
  sqlite3_stmt *stmt;
  if (!last_quote_modifiable(&quote_id))
    return SQLITE_READONLY;
  stmt = sql_prepare("UPDATE quotes SET quote = ?1 WHERE quote_id = ?2");
  if (!stmt)
    return SQLITE_ERROR;
  sqlite3_bind_text(stmt, 1, quote, strlen(quote), SQLITE_STATIC);
  sqlite3_bind_int(stmt, 2, quote_id);
  status = sqlite3_step(stmt);
  sqlite3_finalize(stmt);
  return status;
}


x86 assembly (clang, -O0):
<modify_last_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <last_quote_modifiable@plt>
cmp    $0x0,%eax
jne    119f <modify_last_quote+0x2f>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    122e <modify_last_quote+0xbe>
lea    0xe5a(%rip),%rdi
call   1070 <sql_prepare@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11cb <modify_last_quote+0x5b>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    122e <modify_last_quote+0xbe>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    0x2ddb(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1080 <sqlite3_bind_text@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    $0x2,%esi
call   1040 <sqlite3_bind_int@plt>
mov    -0x20(%rbp),%rdi
call   1060 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <sqlite3_finalize@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modify_last_quote>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rdi
call   1030 <last_quote_modifiable@plt>
test   %eax,%eax
je     11e6 <modify_last_quote+0x76>
lea    0xe70(%rip),%rdi
call   1070 <sql_prepare@plt>
test   %rax,%rax
je     11ef <modify_last_quote+0x7f>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    0x2e24(%rip),%rcx
mov    (%rcx),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1080 <sqlite3_bind_text@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1060 <sqlite3_step@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1090 <sqlite3_finalize@plt>
jmp    11f8 <modify_last_quote+0x88>
mov    0x2dfb(%rip),%rax
jmp    11f6 <modify_last_quote+0x86>
mov    0x2de2(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SQLITE_READONLY = global i32 0
@.str = [49 x i8] c"UPDATE quotes SET quote = ?1 WHERE quote_id = ?2\00"
@SQLITE_ERROR = global i32 0
@SQLITE_STATIC = global i32 0
define i32 @modify_last_quote(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %3
%7 = call i32 @last_quote_modifiable(i32* %5)
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = load i32, i32* @SQLITE_READONLY
store i32 %10, i32* %2
br label %32
11: ; preds = %1
%12 = call i32* @sql_prepare(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = load i32, i32* @SQLITE_ERROR
store i32 %16, i32* %2
br label %32
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = load i32, i32* @SQLITE_STATIC
%23 = call i32 @sqlite3_bind_text(i32* %18, i32 1, i8* %19, i32 %21, i32 %22)
%24 = load i32*, i32** %6
%25 = load i32, i32* %5
%26 = call i32 @sqlite3_bind_int(i32* %24, i32 2, i32 %25)
%27 = load i32*, i32** %6
%28 = call i32 @sqlite3_step(i32* %27)
store i32 %28, i32* %4
%29 = load i32*, i32** %6
%30 = call i32 @sqlite3_finalize(i32* %29)
%31 = load i32, i32* %4
store i32 %31, i32* %2
br label %32
32: ; preds = %17, %15, %9
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@SQLITE_READONLY = global i32 0
@.str = [49 x i8] c"UPDATE quotes SET quote = ?1 WHERE quote_id = ?2\00"
@SQLITE_ERROR = global i32 0
@SQLITE_STATIC = global i32 0
define i32 @modify_last_quote(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @last_quote_modifiable(i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32, i32* @SQLITE_READONLY
br label %21
8: ; preds = %1
%9 = call i32* @sql_prepare(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32, i32* @SQLITE_ERROR
br label %21
13: ; preds = %8
%14 = call i32 @strlen(i8* %0)
%15 = load i32, i32* @SQLITE_STATIC
%16 = call i32 @sqlite3_bind_text(i32* %9, i32 1, i8* %0, i32 %14, i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @sqlite3_bind_int(i32* %9, i32 2, i32 %17)
%19 = call i32 @sqlite3_step(i32* %9)
%20 = call i32 @sqlite3_finalize(i32* %9)
br label %21
21: ; preds = %13, %11, %6
%22 = phi i32 [ %19, %13 ], [ %12, %11 ], [ %7, %6 ]
ret i32 %22
}