#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ update(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                          int /*<<< orphan*/, int /*<<< orphan*/ *);
int main() {
  sqlite3 *db = NULL;
  sqlite3_stmt *stmt = NULL;
  int res = sqlite3_open("test.db", &db);
  if (res != SQLITE_OK) {
    fprintf(stderr, "open error %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return -1;
  }
  printf("open test.db success\n");
  update(db, stmt, "zhangrxiang", 0, NULL);
  if (db) {
    sqlite3_close(db);
    printf("sqlite3_close success\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe7a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%eax
je     11e0 <main+0x80>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sqlite3_errmsg@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe42(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <main+0xce>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe32(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <update@plt>
cmpq   $0x0,-0x10(%rbp)
je     1227 <main+0xc7>
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_close@plt>
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xe8b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <sqlite3_open@plt>
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%eax
jne    11cd <main+0x6d>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
lea    0xe75(%rip),%rdx
xor    %ebx,%ebx
xor    %esi,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <update@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1200 <main+0xa0>
call   1080 <sqlite3_close@plt>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
jmp    1200 <main+0xa0>
mov    0x2e04(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_errmsg@plt>
lea    0xe21(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_close@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"test.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"open error %s\0A\00"
@.str.2 = [22 x i8] c"open test.db success\0A\00"
@.str.3 = [12 x i8] c"zhangrxiang\00"
@.str.4 = [23 x i8] c"sqlite3_close success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
store i32* null, i32** %3
%5 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32** %2)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* @SQLITE_OK
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i32*, i32** %2
%12 = call i8* @sqlite3_errmsg(i32* %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32*, i32** %2
%15 = call i32 @sqlite3_close(i32* %14)
store i32 -1, i32* %1
br label %28
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32*, i32** %2
%19 = load i32*, i32** %3
%20 = call i32 @update(i32* %18, i32* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
%21 = load i32*, i32** %2
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = load i32*, i32** %2
%25 = call i32 @sqlite3_close(i32* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %23, %16
store i32 0, i32* %1
br label %28
28: ; preds = %27, %9
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [8 x i8] c"test.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"open error %s\0A\00"
@.str.3 = [12 x i8] c"zhangrxiang\00"
@str = [21 x i8] c"open test.db success\00"
@str.5 = [22 x i8] c"sqlite3_close success\00"
define i32 @main() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
store i32* null, i32** %1
%3 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32** %1)
%4 = load i32, i32* @SQLITE_OK
%5 = icmp eq i32 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32*, i32** %1
%9 = call i8* @sqlite3_errmsg(i32* %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i32*, i32** %1
%12 = call i32 @sqlite3_close(i32* %11)
br label %22
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%15 = load i32*, i32** %1
%16 = call i32 @update(i32* %15, i32* null, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null)
%17 = load i32*, i32** %1
%18 = icmp eq i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = call i32 @sqlite3_close(i32* %17)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
br label %22
22: ; preds = %13, %19, %6
%23 = phi i32 [ -1, %6 ], [ 0, %19 ], [ 0, %13 ]
ret i32 %23
}