#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 /*<<< orphan*/ printf(char *);
int sprintf(char *, char *);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/);
int db_select(int *retval, sqlite3_stmt **stmt, sqlite3 **handle) {
  char buffr[300];
  int qc;
  qc = sprintf(buffr, "select * from users");
  if (*retval = sqlite3_prepare_v2(*handle, buffr, -1, stmt, 0)) {
    printf("Selecting from database faile \n");
    return -1;
  }
}


x86 assembly (clang, -O0):
<db_select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x150(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <sprintf@plt>
mov    %eax,-0x154(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    -0x150(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1040 <sqlite3_prepare_v2@plt>
mov    -0x10(%rbp),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
je     11a1 <db_select+0x71>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_select>:
push   %rbx
sub    $0x130,%rsp
mov    %rsi,%rcx
mov    %rdi,%rbx
movups 0xecb(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x737265,0x10(%rsp)
mov    (%rdx),%rdi
mov    %rsp,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1040 <sqlite3_prepare_v2@plt>
mov    %eax,(%rbx)
test   %eax,%eax
je     1166 <db_select+0x46>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x130,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"select * from users\00"
@.str.1 = [32 x i8] c"Selecting from database faile \0A\00"
define i32 @db_select(i32* %0, i32** %1, i32** %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32**
%7 = alloca i32**
%8 = alloca [300 x i8]
%9 = alloca i32
store i32* %0, i32** %5
store i32** %1, i32*** %6
store i32** %2, i32*** %7
%10 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %9
%12 = load i32**, i32*** %7
%13 = load i32*, i32** %12
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%15 = load i32**, i32*** %6
%16 = call i32 @sqlite3_prepare_v2(i32* %13, i8* %14, i32 -1, i32** %15, i32 0)
%17 = load i32*, i32** %5
store i32 %16, i32* %17
%18 = icmp ne i32 %16, 0
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %21
21: ; preds = %19, %3
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [20 x i8] c"select * from users\00"
@str = [31 x i8] c"Selecting from database faile \00"
define i32 @db_select(i32* nocapture writeonly %0, i32** %1, i32** nocapture %2) {
%4 = alloca [300 x i8]
%5 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%6 = load i32*, i32** %2
%7 = call i32 @sqlite3_prepare_v2(i32* %6, i8* %5, i32 -1, i32** %1, i32 0)
store i32 %7, i32* %0
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %3, %9
ret i32 -1
}