#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*/ db_insert(int *, int /*<<< orphan*/ **, char *, char *, int);
int /*<<< orphan*/ db_open_database(int *, int /*<<< orphan*/ **);
int /*<<< orphan*/ db_print_query(int *, int /*<<< orphan*/ **);
int /*<<< orphan*/ db_select(int *, int /*<<< orphan*/ **,
                             int /*<<< orphan*/ **);
int /*<<< orphan*/ db_table_create(int *, int /*<<< orphan*/ **);
char **malloc(int);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int main(int argc, char **args) {
  int retval;
  int q_cnt = 5, q_size = 200, idx = 0;
  char **queries = malloc(sizeof(char) * q_cnt * q_size);
  sqlite3_stmt *stmt;
  sqlite3 *handle;
  db_open_database(&retval, &handle);
  db_table_create(&retval, &handle);
  db_insert(&retval, &handle, "user1", "user1pass", 1);
  db_insert(&retval, &handle, "user2", "user2pass", 1);
  db_select(&retval, &stmt, &handle);
  db_print_query(&retval, &stmt);
  sqlite3_close(handle);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x18(%rbp)
movl   $0xc8,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
movslq -0x1c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <db_open_database@plt>
lea    -0x14(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1090 <db_table_create@plt>
lea    -0x14(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    0xe21(%rip),%rdx
lea    0xe20(%rip),%rcx
mov    $0x1,%r8d
call   1070 <db_insert@plt>
lea    -0x14(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    0xe10(%rip),%rdx
lea    0xe0f(%rip),%rcx
mov    $0x1,%r8d
call   1070 <db_insert@plt>
lea    -0x14(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <db_select@plt>
lea    -0x14(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <db_print_query@plt>
mov    -0x38(%rbp),%rdi
call   1050 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x3e8,%edi
call   1060 <malloc@plt>
lea    0x14(%rsp),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <db_open_database@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <db_table_create@plt>
lea    0xe56(%rip),%rdx
lea    0xe55(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%r8d
call   1070 <db_insert@plt>
lea    0xe47(%rip),%rdx
lea    0xe46(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%r8d
call   1070 <db_insert@plt>
lea    0x18(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <db_select@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <db_print_query@plt>
mov    0x8(%rsp),%rdi
call   1050 <sqlite3_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"user1\00"
@.str.1 = [10 x i8] c"user1pass\00"
@.str.2 = [6 x i8] c"user2\00"
@.str.3 = [10 x i8] c"user2pass\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5, i32* %7
store i32 200, i32* %8
store i32 0, i32* %9
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = mul i64 1, %14
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = mul i64 %15, %17
%19 = trunc i64 %18 to i32
%20 = call i8** @malloc(i32 %19)
store i8** %20, i8*** %10
%21 = call i32 @db_open_database(i32* %6, i32** %12)
%22 = call i32 @db_table_create(i32* %6, i32** %12)
%23 = call i32 @db_insert(i32* %6, i32** %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = call i32 @db_insert(i32* %6, i32** %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 1)
%25 = call i32 @db_select(i32* %6, i32** %11, i32** %12)
%26 = call i32 @db_print_query(i32* %6, i32** %11)
%27 = load i32*, i32** %12
%28 = call i32 @sqlite3_close(i32* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"user1\00"
@.str.1 = [10 x i8] c"user1pass\00"
@.str.2 = [6 x i8] c"user2\00"
@.str.3 = [10 x i8] c"user2pass\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = bitcast i32* %3 to i8*
%7 = tail call i8** @malloc(i32 1000)
%8 = bitcast i32** %4 to i8*
%9 = bitcast i32** %5 to i8*
%10 = call i32 @db_open_database(i32* %3, i32** %5)
%11 = call i32 @db_table_create(i32* %3, i32** %5)
%12 = call i32 @db_insert(i32* %3, i32** %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = call i32 @db_insert(i32* %3, i32** %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 1)
%14 = call i32 @db_select(i32* %3, i32** %4, i32** %5)
%15 = call i32 @db_print_query(i32* %3, i32** %4)
%16 = load i32*, i32** %5
%17 = call i32 @sqlite3_close(i32* %16)
ret i32 0
}