#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;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ close_database(int /*<<< orphan*/ *);
int /*<<< orphan*/ create_table(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ delete_records(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ insert_records(int /*<<< orphan*/ *, char *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ open_database(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ select_records(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ update_records(int /*<<< orphan*/ *, char *, char *);
int main(int argc, char *argv[]) {
  sqlite3 *db;
  char *sql;
  char *data = "Callback function called";
  char *path = "test.db";
  open_database(db, path);
  sql = "CREATE TABLE COMPANY("
        "ID INT PRIMARY KEY  NOT NULL,"
        "NAME           TXT  NOT NULL,"
        "AGE            INT  NOT NULL,"
        "ADDRESS        CHAR(50),"
        "SALARY         REAL);";
  create_table(db, sql);
  sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "
        "VALUES (1, 'Paul', 32, 'California', 20000.00 ); "
        "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "
        "VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); "
        "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)"
        "VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );"
        "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)"
        "VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );";
  insert_records(db, sql, NULL);
  sql = "SELECT * from COMPANY";
  select_records(db, sql, data);
  sql = "UPDATE COMPANY set SALARY = 25000.00 where ID=1; "
        "SELECT * from COMPANY";
  update_records(db, sql, data);
  sql = "DELETE from COMPANY where ID=2; "
        "SELECT * from COMPANY";
  delete_records(db, sql, data);
  close_database(db);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe81(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <open_database@plt>
lea    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <create_table@plt>
lea    0xef3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <insert_records@plt>
lea    0x1086(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <select_records@plt>
lea    0x1039(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <update_records@plt>
lea    0x1064(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <delete_records@plt>
mov    -0x18(%rbp),%rdi
call   1050 <close_database@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea1(%rip),%rsi
call   1090 <open_database@plt>
lea    0xe9d(%rip),%rsi
call   1040 <create_table@plt>
lea    0xf2b(%rip),%rsi
xor    %edx,%edx
call   1080 <insert_records@plt>
lea    0x10cc(%rip),%rsi
lea    0xe5b(%rip),%rbx
mov    %rbx,%rdx
call   1060 <select_records@plt>
lea    0x1085(%rip),%rsi
mov    %rbx,%rdx
call   1030 <update_records@plt>
lea    0x10bd(%rip),%rsi
mov    %rbx,%rdx
call   1070 <delete_records@plt>
call   1050 <close_database@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Callback function called\00"
@.str.1 = [8 x i8] c"test.db\00"
@.str.2 = [154 x i8] c"CREATE TABLE COMPANY(ID INT PRIMARY KEY NOT NULL,NAME TXT NOT NULL,AGE INT NOT NULL,ADDRESS CHAR(50),SALARY REAL);\00"
@.str.3 = [382 x i8] c"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (1, 'Paul', 32, 'California', 20000.00 ); INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );\00"
@.str.4 = [22 x i8] c"SELECT * from COMPANY\00"
@.str.5 = [71 x i8] c"UPDATE COMPANY set SALARY = 25000.00 where ID=1; SELECT * from COMPANY\00"
@.str.6 = [54 x i8] c"DELETE from COMPANY where ID=2; SELECT * from COMPANY\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = load i32*, i32** %6
%11 = load i8*, i8** %9
%12 = call i32 @open_database(i32* %10, i8* %11)
store i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i8** %7
%13 = load i32*, i32** %6
%14 = load i8*, i8** %7
%15 = call i32 @create_table(i32* %13, i8* %14)
store i8* getelementptr inbounds ([382 x i8], [382 x i8]* @.str.3, i64 0, i64 0), i8** %7
%16 = load i32*, i32** %6
%17 = load i8*, i8** %7
%18 = call i32 @insert_records(i32* %16, i8* %17, i32* null)
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8** %7
%19 = load i32*, i32** %6
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i32 @select_records(i32* %19, i8* %20, i8* %21)
store i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i8** %7
%23 = load i32*, i32** %6
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32 @update_records(i32* %23, i8* %24, i8* %25)
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8** %7
%27 = load i32*, i32** %6
%28 = load i8*, i8** %7
%29 = load i8*, i8** %8
%30 = call i32 @delete_records(i32* %27, i8* %28, i8* %29)
%31 = load i32*, i32** %6
%32 = call i32 @close_database(i32* %31)
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}

LLVM IR (-O2):
@.str = [25 x i8] c"Callback function called\00"
@.str.1 = [8 x i8] c"test.db\00"
@.str.2 = [154 x i8] c"CREATE TABLE COMPANY(ID INT PRIMARY KEY NOT NULL,NAME TXT NOT NULL,AGE INT NOT NULL,ADDRESS CHAR(50),SALARY REAL);\00"
@.str.3 = [382 x i8] c"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (1, 'Paul', 32, 'California', 20000.00 ); INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );\00"
@.str.4 = [22 x i8] c"SELECT * from COMPANY\00"
@.str.5 = [71 x i8] c"UPDATE COMPANY set SALARY = 25000.00 where ID=1; SELECT * from COMPANY\00"
@.str.6 = [54 x i8] c"DELETE from COMPANY where ID=2; SELECT * from COMPANY\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @open_database(i32* undef, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @create_table(i32* undef, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @insert_records(i32* undef, i8* getelementptr inbounds ([382 x i8], [382 x i8]* @.str.3, i64 0, i64 0), i32* null)
%6 = tail call i32 @select_records(i32* undef, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @update_records(i32* undef, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @delete_records(i32* undef, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @close_database(i32* undef)
%10 = load i32, i32* @EXIT_SUCCESS
ret i32 %10
}