#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sql_exec(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ sql_stdout(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
void vacuum(sqlite3 *db, int deep) {
  printf("Deleting invalid ESSIDs and passwords...\n");
  sql_exec(db, "DELETE FROM essid WHERE VERIFY_ESSID(essid) != 0;");
  sql_exec(db, "DELETE FROM passwd WHERE VERIFY_PASSWD(passwd) != 0");
  printf("Deleting unreferenced PMKs...\n");
  sql_exec(
      db, "DELETE FROM pmk WHERE essid_id NOT IN (SELECT essid_id FROM essid)");
  sql_exec(
      db,
      "DELETE FROM pmk WHERE passwd_id NOT IN (SELECT passwd_id FROM passwd)");
  printf("Analysing index structure...\n");
  sql_exec(db, "ANALYZE;");
  if (deep != 0) {
    printf("Vacuum-cleaning the database. This could take a while...\n");
    sql_exec(db, "VACUUM;");
    printf("Checking database integrity...\n");
    sql_stdout(db, "PRAGMA integrity_check;", 0);
  }
  printf("Done.\n");
}


x86 assembly (clang, -O0):
<vacuum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xed4(%rip),%rsi
call   1030 <sql_exec@plt>
mov    -0x8(%rbp),%rdi
lea    0xef6(%rip),%rsi
call   1030 <sql_exec@plt>
lea    0xf1e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf2d(%rip),%rsi
call   1030 <sql_exec@plt>
mov    -0x8(%rbp),%rdi
lea    0xf60(%rip),%rsi
call   1030 <sql_exec@plt>
lea    0xf9a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xfa8(%rip),%rsi
call   1030 <sql_exec@plt>
cmpl   $0x0,-0xc(%rbp)
je     11f7 <vacuum+0xc7>
lea    0xf9b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xfc5(%rip),%rsi
call   1030 <sql_exec@plt>
lea    0xfc1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xfd1(%rip),%rsi
xor    %edx,%edx
call   1050 <sql_stdout@plt>
lea    0xfdb(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vacuum>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xfd9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
lea    0xfd8(%rip),%rdi
call   1030 <puts@plt>
lea    0xef1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
lea    0xf25(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
lea    0xfcc(%rip),%rdi
call   1030 <puts@plt>
lea    0xf50(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
test   %ebp,%ebp
je     11e3 <vacuum+0xb3>
lea    0xfd0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sql_exec@plt>
lea    0xfee(%rip),%rdi
call   1030 <puts@plt>
lea    0xf27(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <sql_stdout@plt>
lea    0xf92(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"Deleting invalid ESSIDs and passwords...\0A\00"
@.str.1 = [50 x i8] c"DELETE FROM essid WHERE VERIFY_ESSID(essid) != 0;\00"
@.str.2 = [52 x i8] c"DELETE FROM passwd WHERE VERIFY_PASSWD(passwd) != 0\00"
@.str.3 = [31 x i8] c"Deleting unreferenced PMKs...\0A\00"
@.str.4 = [67 x i8] c"DELETE FROM pmk WHERE essid_id NOT IN (SELECT essid_id FROM essid)\00"
@.str.5 = [70 x i8] c"DELETE FROM pmk WHERE passwd_id NOT IN (SELECT passwd_id FROM passwd)\00"
@.str.6 = [30 x i8] c"Analysing index structure...\0A\00"
@.str.7 = [9 x i8] c"ANALYZE;\00"
@.str.8 = [58 x i8] c"Vacuum-cleaning the database. This could take a while...\0A\00"
@.str.9 = [8 x i8] c"VACUUM;\00"
@.str.10 = [32 x i8] c"Checking database integrity...\0A\00"
@.str.11 = [24 x i8] c"PRAGMA integrity_check;\00"
@.str.12 = [7 x i8] c"Done.\0A\00"
define void @vacuum(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = load i32*, i32** %3
%7 = call i32 @sql_exec(i32* %6, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32*, i32** %3
%9 = call i32 @sql_exec(i32* %8, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32*, i32** %3
%12 = call i32 @sql_exec(i32* %11, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32*, i32** %3
%14 = call i32 @sql_exec(i32* %13, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%16 = load i32*, i32** %3
%17 = call i32 @sql_exec(i32* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%22 = load i32*, i32** %3
%23 = call i32 @sql_exec(i32* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%25 = load i32*, i32** %3
%26 = call i32 @sql_stdout(i32* %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 0)
br label %27
27: ; preds = %20, %2
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [50 x i8] c"DELETE FROM essid WHERE VERIFY_ESSID(essid) != 0;\00"
@.str.2 = [52 x i8] c"DELETE FROM passwd WHERE VERIFY_PASSWD(passwd) != 0\00"
@.str.4 = [67 x i8] c"DELETE FROM pmk WHERE essid_id NOT IN (SELECT essid_id FROM essid)\00"
@.str.5 = [70 x i8] c"DELETE FROM pmk WHERE passwd_id NOT IN (SELECT passwd_id FROM passwd)\00"
@.str.7 = [9 x i8] c"ANALYZE;\00"
@.str.9 = [8 x i8] c"VACUUM;\00"
@.str.11 = [24 x i8] c"PRAGMA integrity_check;\00"
@str = [41 x i8] c"Deleting invalid ESSIDs and passwords...\00"
@str.13 = [30 x i8] c"Deleting unreferenced PMKs...\00"
@str.14 = [29 x i8] c"Analysing index structure...\00"
@str.15 = [6 x i8] c"Done.\00"
@str.16 = [57 x i8] c"Vacuum-cleaning the database. This could take a while...\00"
@str.17 = [31 x i8] c"Checking database integrity...\00"
define void @vacuum(i32* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%11 = icmp eq i32 %1, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.16, i64 0, i64 0))
%14 = tail call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.17, i64 0, i64 0))
%16 = tail call i32 @sql_stdout(i32* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 0)
br label %17
17: ; preds = %12, %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0))
ret void
}