#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_int64;
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
scalar_t__ SQLITE_DONE;
int SQLITE_OK;
int /*<<< orphan*/ assert(int);
int sqlite3_bind_int64(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                       int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_reset(int /*<<< orphan*/ *);
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
int db_delete_client_memberships(sqlite3 *db, sqlite3_int64 id_client) {
  static sqlite3_stmt *stmt;
  static const char query[] = "DELETE FROM membership WHERE id_client = ?;";
  int ret;
  do {
    if (db == NULL) {
      if (stmt != NULL) {
        sqlite3_finalize(stmt);
        stmt = NULL;
      }
      return 0;
    }
  } while (0);
  do {
    if (stmt == NULL) {
      ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
      assert(ret == SQLITE_OK);
    }
  } while (0);
  sqlite3_reset(stmt);
  ret = sqlite3_bind_int64(stmt, 1, id_client);
  assert(ret == SQLITE_OK);
  return (sqlite3_step(stmt) != SQLITE_DONE);
}


x86 assembly (clang, -O0):
<db_delete_client_memberships>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bb <db_delete_client_memberships+0x4b>
cmpq   $0x0,0x2ece(%rip)
je     11af <db_delete_client_memberships+0x3f>
mov    0x2ec1(%rip),%rdi
call   1080 <sqlite3_finalize@plt>
movq   $0x0,0x2eb1(%rip)
movl   $0x0,-0x4(%rbp)
jmp    1283 <db_delete_client_memberships+0x113>
jmp    11c0 <db_delete_client_memberships+0x50>
jmp    11c5 <db_delete_client_memberships+0x55>
cmpq   $0x0,0x2e93(%rip)
jne    1221 <db_delete_client_memberships+0xb1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe1e(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe0c(%rip),%rsi
lea    0x2e65(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2dd6(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    1226 <db_delete_client_memberships+0xb6>
mov    0x2e33(%rip),%rdi
call   1040 <sqlite3_reset@plt>
mov    0x2e27(%rip),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1030 <sqlite3_bind_int64@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2d95(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2df7(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2d63(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_delete_client_memberships>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2ee2(%rip),%rdi
test   %rbx,%rbx
je     1218 <db_delete_client_memberships+0xa8>
mov    %esi,%ebp
test   %rdi,%rdi
jne    11cf <db_delete_client_memberships+0x5f>
lea    0xe6b(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x2ebc(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    0x2e2d(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e91(%rip),%rdi
call   1040 <sqlite3_reset@plt>
mov    0x2e85(%rip),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <sqlite3_bind_int64@plt>
mov    0x2dfa(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e5e(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2dca(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
setne  %bl
jmp    122f <db_delete_client_memberships+0xbf>
xor    %ebx,%ebx
test   %rdi,%rdi
je     122f <db_delete_client_memberships+0xbf>
call   1080 <sqlite3_finalize@plt>
movq   $0x0,0x2e31(%rip)
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@db_delete_client_memberships.stmt = internal global i32* null
@db_delete_client_memberships.query = internal constant [44 x i8] c"DELETE FROM membership WHERE id_client = ?;\00"
@SQLITE_OK = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_delete_client_memberships(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
br label %7
7: ; preds = %2
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32*, i32** @db_delete_client_memberships.stmt
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32*, i32** @db_delete_client_memberships.stmt
%15 = call i32 @sqlite3_finalize(i32* %14)
store i32* null, i32** @db_delete_client_memberships.stmt
br label %16
16: ; preds = %13, %10
store i32 0, i32* %3
br label %48
17: ; preds = %7
br label %18
18: ; preds = %17
br label %19
19: ; preds = %18
%20 = load i32*, i32** @db_delete_client_memberships.stmt
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32*, i32** %4
%24 = call i32 @strlen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @db_delete_client_memberships.query, i64 0, i64 0))
%25 = call i32 @sqlite3_prepare_v2(i32* %23, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @db_delete_client_memberships.query, i64 0, i64 0), i32 %24, i32** @db_delete_client_memberships.stmt, i32* null)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32, i32* @SQLITE_OK
%28 = icmp eq i32 %26, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
br label %31
31: ; preds = %22, %19
br label %32
32: ; preds = %31
%33 = load i32*, i32** @db_delete_client_memberships.stmt
%34 = call i32 @sqlite3_reset(i32* %33)
%35 = load i32*, i32** @db_delete_client_memberships.stmt
%36 = load i32, i32* %5
%37 = call i32 @sqlite3_bind_int64(i32* %35, i32 1, i32 %36)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = load i32, i32* @SQLITE_OK
%40 = icmp eq i32 %38, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32*, i32** @db_delete_client_memberships.stmt
%44 = call i64 @sqlite3_step(i32* %43)
%45 = load i64, i64* @SQLITE_DONE
%46 = icmp ne i64 %44, %45
%47 = zext i1 %46 to i32
store i32 %47, i32* %3
br label %48
48: ; preds = %32, %16
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@db_delete_client_memberships.stmt = internal global i32* null
@db_delete_client_memberships.query = internal constant [44 x i8] c"DELETE FROM membership WHERE id_client = ?;\00"
@SQLITE_OK = global i32 0
@SQLITE_DONE = global i64 0
define i32 @db_delete_client_memberships(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
%4 = load i32*, i32** @db_delete_client_memberships.stmt
%5 = icmp eq i32* %4, null
br i1 %3, label %6, label %9
6: ; preds = %2
br i1 %5, label %32, label %7
7: ; preds = %6
%8 = tail call i32 @sqlite3_finalize(i32* %4)
store i32* null, i32** @db_delete_client_memberships.stmt
br label %32
9: ; preds = %2
br i1 %5, label %10, label %18
10: ; preds = %9
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @db_delete_client_memberships.query, i64 0, i64 0))
%12 = tail call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @db_delete_client_memberships.query, i64 0, i64 0), i32 %11, i32** @db_delete_client_memberships.stmt, i32* null)
%13 = load i32, i32* @SQLITE_OK
%14 = icmp eq i32 %12, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = load i32*, i32** @db_delete_client_memberships.stmt
br label %18
18: ; preds = %10, %9
%19 = phi i32* [ %17, %10 ], [ %4, %9 ]
%20 = tail call i32 @sqlite3_reset(i32* %19)
%21 = load i32*, i32** @db_delete_client_memberships.stmt
%22 = tail call i32 @sqlite3_bind_int64(i32* %21, i32 1, i32 %1)
%23 = load i32, i32* @SQLITE_OK
%24 = icmp eq i32 %22, %23
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = load i32*, i32** @db_delete_client_memberships.stmt
%28 = tail call i64 @sqlite3_step(i32* %27)
%29 = load i64, i64* @SQLITE_DONE
%30 = icmp ne i64 %28, %29
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %6, %7, %18
%33 = phi i32 [ %31, %18 ], [ 0, %7 ], [ 0, %6 ]
ret i32 %33
}