#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 */
struct db_query {
  int dummy;
};
typedef int /*<<< orphan*/ sqlite3_stmt;

/* Variables and functions */
void *sqlite3_column_blob(int /*<<< orphan*/ *, int);
int sqlite3_column_bytes(int /*<<< orphan*/ *, int);
int db_column_blob(struct db_query *query, int i, const void **blob) {
  if (query == NULL || blob == NULL)
    return -1;
  *blob = sqlite3_column_blob((sqlite3_stmt *)query, i);
  return sqlite3_column_bytes((sqlite3_stmt *)query, i);
  ;
}


x86 assembly (clang, -O0):
<db_column_blob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1149 <db_column_blob+0x29>
cmpq   $0x0,-0x20(%rbp)
jne    1155 <db_column_blob+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    117a <db_column_blob+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sqlite3_column_blob@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <sqlite3_column_bytes@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_column_blob>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     114e <db_column_blob+0x2e>
mov    %rdx,%rbx
test   %rdx,%rdx
je     114e <db_column_blob+0x2e>
mov    %esi,%r14d
mov    %rdi,%rbp
call   1030 <sqlite3_column_blob@plt>
mov    %rax,(%rbx)
mov    %rbp,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <sqlite3_column_bytes@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.db_query = type { i32 }
define i32 @db_column_blob(%struct.db_query* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.db_query*
%6 = alloca i32
%7 = alloca i8**
store %struct.db_query* %0, %struct.db_query** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%8 = load %struct.db_query*, %struct.db_query** %5
%9 = icmp eq %struct.db_query* %8, null
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i8**, i8*** %7
%12 = icmp eq i8** %11, null
br i1 %12, label %13, label %14
13: ; preds = %10, %3
store i32 -1, i32* %4
br label %24
14: ; preds = %10
%15 = load %struct.db_query*, %struct.db_query** %5
%16 = bitcast %struct.db_query* %15 to i32*
%17 = load i32, i32* %6
%18 = call i8* @sqlite3_column_blob(i32* %16, i32 %17)
%19 = load i8**, i8*** %7
store i8* %18, i8** %19
%20 = load %struct.db_query*, %struct.db_query** %5
%21 = bitcast %struct.db_query* %20 to i32*
%22 = load i32, i32* %6
%23 = call i32 @sqlite3_column_bytes(i32* %21, i32 %22)
store i32 %23, i32* %4
br label %24
24: ; preds = %14, %13
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
%struct.db_query = type { i32 }
define i32 @db_column_blob(%struct.db_query* %0, i32 %1, i8** writeonly %2) {
%4 = icmp eq %struct.db_query* %0, null
%5 = icmp eq i8** %2, null
%6 = or i1 %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = getelementptr %struct.db_query, %struct.db_query* %0, i64 0, i32 0
%9 = tail call i8* @sqlite3_column_blob(i32* %8, i32 %1)
store i8* %9, i8** %2
%10 = tail call i32 @sqlite3_column_bytes(i32* %8, i32 %1)
br label %11
11: ; preds = %3, %7
%12 = phi i32 [ %10, %7 ], [ -1, %3 ]
ret i32 %12
}