#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 */

/* Variables and functions */
int check_sql_for_select(char *);
int /*<<< orphan*/ parse_sql_field_names(char *, char *, char *, int, int,
                                         char *, char *, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int check = 0;
  char sql[] = "SELECT T1.KeyID, T1.plate, T1.Groups AS G1, T2.data, "
               "T2.percent FROM aux AS T1, data AS T2 WHERE T1.KeyID=T2.KeyID;";
  char database_name[] = "VelociRaptorData.db";
  char html_file_name[] = "table2.html";
  int precision = 2;
  int font_size = 12;
  char bg_color1[] = "yellow";
  char bg_color2[] = "MediumOrchid";
  int alternate = 1;
  char field_bg_color[] = "silver";
  check = check_sql_for_select(sql);
  if (check == 0) {
    printf("%s\n", sql);
    parse_sql_field_names(html_file_name, database_name, sql, precision,
                          font_size, bg_color1, bg_color2, alternate,
                          field_bg_color);
  } else {
    printf("SQL statement doesn't check out.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x74,%edx
call   1060 <memcpy@plt>
mov    0xf0b(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xf05(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xf00(%rip),%eax
mov    %eax,-0x90(%rbp)
mov    0xef7(%rip),%rax
mov    %rax,-0xac(%rbp)
mov    0xef2(%rip),%eax
mov    %eax,-0xa4(%rbp)
movl   $0x2,-0xb0(%rbp)
movl   $0xc,-0xb4(%rbp)
mov    0xed6(%rip),%eax
mov    %eax,-0xbb(%rbp)
mov    0xecd(%rip),%ax
mov    %ax,-0xb7(%rbp)
mov    0xec2(%rip),%al
mov    %al,-0xb5(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0xc8(%rbp)
mov    0xeb1(%rip),%eax
mov    %eax,-0xc0(%rbp)
mov    0xea9(%rip),%al
mov    %al,-0xbc(%rbp)
movl   $0x1,-0xcc(%rbp)
mov    0xe94(%rip),%eax
mov    %eax,-0xd3(%rbp)
mov    0xe8b(%rip),%ax
mov    %ax,-0xcf(%rbp)
mov    0xe80(%rip),%al
mov    %al,-0xcd(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <check_sql_for_select@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    12bb <main+0x17b>
lea    -0x80(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xac(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    -0xb0(%rbp),%ecx
mov    -0xb4(%rbp),%r8d
lea    -0xbb(%rbp),%r9
lea    -0xc8(%rbp),%r11
mov    -0xcc(%rbp),%r10d
lea    -0xd3(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <parse_sql_field_names@plt>
jmp    12c9 <main+0x189>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xd0,%rsp
movaps 0xf21(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xf02(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe89(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movl   $0x3b4449,0xc0(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x62642e,0x40(%rsp)
movabs $0x682e32656c626174,%rax
32 2e 68
mov    %rax,0x10(%rsp)
movl   $0x6c6d74,0x18(%rsp)
movl   $0x776f6c,0xb(%rsp)
movl   $0x6c6c6579,0x8(%rsp)
6c
movabs $0x64696863724f6d,%rax
mov    %rax,0x25(%rsp)
movabs $0x724f6d756964654d,%rax
6d 4f 72
mov    %rax,0x20(%rsp)
movl   $0x726576,0x3(%rsp)
movl   $0x766c6973,(%rsp)
lea    0x50(%rsp),%rdi
call   1050 <check_sql_for_select@plt>
test   %eax,%eax
je     1227 <main+0xf7>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
jmp    126d <main+0x13d>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0x28(%rsp),%r10
lea    0x18(%rsp),%rdi
lea    0x38(%rsp),%rsi
lea    0x10(%rsp),%r9
mov    %rbx,%rdx
mov    $0x2,%ecx
mov    $0xc,%r8d
push   %rax
push   $0x1
push   %r10
call   1040 <parse_sql_field_names@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.sql = [116 x i8] c"SELECT T1.KeyID, T1.plate, T1.Groups AS G1, T2.data, T2.percent FROM aux AS T1, data AS T2 WHERE T1.KeyID=T2.KeyID;\00"
@__const.main.database_name = [20 x i8] c"VelociRaptorData.db\00"
@__const.main.html_file_name = [12 x i8] c"table2.html\00"
@__const.main.bg_color1 = [7 x i8] c"yellow\00"
@__const.main.bg_color2 = [13 x i8] c"MediumOrchid\00"
@__const.main.field_bg_color = [7 x i8] c"silver\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [34 x i8] c"SQL statement doesn't check out.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [116 x i8]
%4 = alloca [20 x i8]
%5 = alloca [12 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [7 x i8]
%9 = alloca [13 x i8]
%10 = alloca i32
%11 = alloca [7 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%12 = bitcast [116 x i8]* %3 to i8*
%13 = bitcast [20 x i8]* %4 to i8*
%14 = bitcast [12 x i8]* %5 to i8*
store i32 2, i32* %6
store i32 12, i32* %7
%15 = bitcast [7 x i8]* %8 to i8*
%16 = bitcast [13 x i8]* %9 to i8*
store i32 1, i32* %10
%17 = bitcast [7 x i8]* %11 to i8*
%18 = getelementptr inbounds [116 x i8], [116 x i8]* %3, i64 0, i64 0
%19 = call i32 @check_sql_for_select(i8* %18)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %0
%23 = getelementptr inbounds [116 x i8], [116 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%27 = getelementptr inbounds [116 x i8], [116 x i8]* %3, i64 0, i64 0
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
%32 = load i32, i32* %10
%33 = getelementptr inbounds [7 x i8], [7 x i8]* %11, i64 0, i64 0
%34 = call i32 @parse_sql_field_names(i8* %25, i8* %26, i8* %27, i32 %28, i32 %29, i8* %30, i8* %31, i32 %32, i8* %33)
br label %37
35: ; preds = %0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %22
ret i32 0
}

LLVM IR (-O2):
@__const.main.sql = [116 x i8] c"SELECT T1.KeyID, T1.plate, T1.Groups AS G1, T2.data, T2.percent FROM aux AS T1, data AS T2 WHERE T1.KeyID=T2.KeyID;\00"
@__const.main.database_name = [20 x i8] c"VelociRaptorData.db\00"
@__const.main.html_file_name = [12 x i8] c"table2.html\00"
@__const.main.bg_color1 = [7 x i8] c"yellow\00"
@__const.main.bg_color2 = [13 x i8] c"MediumOrchid\00"
@__const.main.field_bg_color = [7 x i8] c"silver\00"
@str = [33 x i8] c"SQL statement doesn't check out.\00"
define i32 @main() {
%1 = alloca [116 x i8]
%2 = alloca [20 x i8]
%3 = alloca [12 x i8]
%4 = alloca [7 x i8]
%5 = alloca [13 x i8]
%6 = alloca [7 x i8]
%7 = getelementptr inbounds [116 x i8], [116 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%13 = call i32 @check_sql_for_select(i8* %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = call i32 @puts(i8* %7)
%17 = call i32 @parse_sql_field_names(i8* %9, i8* %8, i8* %7, i32 2, i32 12, i8* %10, i8* %11, i32 1, i8* %12)
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret i32 0
}