#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_membership(sqlite3 *db, sqlite3_int64 id_channel,
                         sqlite3_int64 id_client) {
  static sqlite3_stmt *stmt;
  static const char query[] =
      "DELETE FROM membership WHERE id_channel = ? AND 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_channel);
  assert(ret == SQLITE_OK);
  ret = sqlite3_bind_int64(stmt, 2, id_client);
  assert(ret == SQLITE_OK);
  return (sqlite3_step(stmt) != SQLITE_DONE);
}


x86 assembly (clang, -O0):
<db_delete_membership>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11be <db_delete_membership+0x4e>
cmpq   $0x0,0x2ecb(%rip)
je     11b2 <db_delete_membership+0x42>
mov    0x2ebe(%rip),%rdi
call   1080 <sqlite3_finalize@plt>
movq   $0x0,0x2eae(%rip)
movl   $0x0,-0x4(%rbp)
jmp    12b6 <db_delete_membership+0x146>
jmp    11c3 <db_delete_membership+0x53>
jmp    11c8 <db_delete_membership+0x58>
cmpq   $0x0,0x2e90(%rip)
jne    1224 <db_delete_membership+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe1b(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe09(%rip),%rsi
lea    0x2e62(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    1229 <db_delete_membership+0xb9>
mov    0x2e30(%rip),%rdi
call   1040 <sqlite3_reset@plt>
mov    0x2e24(%rip),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1030 <sqlite3_bind_int64@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d92(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2df4(%rip),%rdi
mov    -0x18(%rbp),%edx
mov    $0x2,%esi
call   1030 <sqlite3_bind_int64@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d62(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2dc4(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2d30(%rip),%rcx
cmp    (%rcx),%rax
setne  %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):
<db_delete_membership>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2edf(%rip),%rdi
test   %rbx,%rbx
je     123f <db_delete_membership+0xcf>
mov    %edx,%r14d
mov    %esi,%ebp
test   %rdi,%rdi
jne    11d5 <db_delete_membership+0x65>
lea    0xe65(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x2eb6(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %r8d,%r8d
call   1090 <sqlite3_prepare_v2@plt>
mov    0x2e27(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e8b(%rip),%rdi
call   1040 <sqlite3_reset@plt>
mov    0x2e7f(%rip),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <sqlite3_bind_int64@plt>
mov    0x2df4(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e58(%rip),%rdi
mov    $0x2,%esi
mov    %r14d,%edx
call   1030 <sqlite3_bind_int64@plt>
xor    %edi,%edi
cmp    (%rbx),%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e37(%rip),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2da3(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
setne  %bl
jmp    1256 <db_delete_membership+0xe6>
xor    %ebx,%ebx
test   %rdi,%rdi
je     1256 <db_delete_membership+0xe6>
call   1080 <sqlite3_finalize@plt>
movq   $0x0,0x2e0a(%rip)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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