#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
#define SQLITE_BLOB 132
#define SQLITE_FLOAT 131
#define SQLITE_INTEGER 130
#define SQLITE_NULL 129
int SQLITE_OK;
scalar_t__ SQLITE_ROW;
#define SQLITE_TEXT 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_count(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_column_double(int /*<<< orphan*/ *, int);
int sqlite3_column_int(int /*<<< orphan*/ *, int);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
int sqlite3_column_type(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_open(char *, int /*<<< orphan*/ **);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/);
scalar_t__ sqlite3_step(int /*<<< orphan*/ *);
void get_data_for_query(FILE *f, char *database_name, char *sql, int precision,
                        char *bg_color1, char *bg_color2, int alternate) {
  int i = 0;
  int column_count = 0;
  int column_type = 0;
  int sql_return = 0;
  int color_count_row = 1;
  int color_count_column = 1;
  sqlite3 *handle = NULL;
  sqlite3_stmt *stmt = NULL;
  sqlite3_open(database_name, &handle);
  sql_return = sqlite3_prepare_v2(handle, sql, -1, &stmt, 0);
  if (sql_return != SQLITE_OK) {
    printf("SQLite couldn't parse SQL string.\n");
  } else {
    column_count = sqlite3_column_count(stmt);
    printf("Column Count %i\n", column_count);
    while (sqlite3_step(stmt) == SQLITE_ROW) {
      if (alternate == 1)
        color_count_row++;
      fprintf(f, "<tr>\n");
      for (i = 0; i < column_count; i++) {
        column_type = sqlite3_column_type(stmt, i);
        if (alternate == 2)
          color_count_column++;
        if (i == 0 && alternate == 2)
          color_count_column = 0;
        switch (column_type) {
        case SQLITE_INTEGER: {
          if (color_count_row % 2 == 0 || color_count_column % 2 == 0 ||
              alternate == 0) {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%i</td>\n",
                    bg_color1, sqlite3_column_int(stmt, i));
          } else {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%i</td>\n",
                    bg_color2, sqlite3_column_int(stmt, i));
          }
          break;
        }
        case SQLITE_FLOAT: {
          if (color_count_row % 2 == 0 || color_count_column % 2 == 0 ||
              alternate == 0) {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%.*f</td>\n",
                    bg_color1, precision, sqlite3_column_double(stmt, i));
          } else {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%.*f</td>\n",
                    bg_color2, precision, sqlite3_column_double(stmt, i));
          }
          break;
        }
        case SQLITE_TEXT: {
          if (color_count_row % 2 == 0 || color_count_column % 2 == 0 ||
              alternate == 0) {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color1, sqlite3_column_text(stmt, i));
          } else {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color2, sqlite3_column_text(stmt, i));
          }
          break;
        }
        case SQLITE_BLOB: {
          if (color_count_row % 2 == 0 || color_count_column % 2 == 0 ||
              alternate == 0) {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color1, "Blob");
          } else {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color2, "Blob");
          }
          break;
        }
        case SQLITE_NULL: {
          if (color_count_row % 2 == 0 || color_count_column % 2 == 0 ||
              alternate == 0) {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color1, "Null");
          } else {
            fprintf(f,
                    "<td style=\"border:1px solid #000000\" "
                    "bgcolor=\"%s\">%s</td>\n",
                    bg_color2, "Null");
          }
          break;
        }
        }
      }
      fprintf(f, "</tr>\n");
    }
    sqlite3_finalize(stmt);
    sqlite3_close(handle);
  }
}


x86 assembly (clang, -O0):
<get_data_for_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x58(%rbp),%rcx
xor    %r8d,%r8d
call   10e0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
je     126d <get_data_for_query+0xad>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16a7 <get_data_for_query+0x4e7>
mov    -0x58(%rbp),%rdi
call   10b0 <sqlite3_column_count@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1080 <sqlite3_step@plt>
mov    0x2d3e(%rip),%rcx
cmp    (%rcx),%rax
jne    1695 <get_data_for_query+0x4d5>
cmpl   $0x1,0x10(%rbp)
jne    12b6 <get_data_for_query+0xf6>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    167e <get_data_for_query+0x4be>
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <sqlite3_column_type@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x2,0x10(%rbp)
jne    12fd <get_data_for_query+0x13d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1318 <get_data_for_query+0x158>
cmpl   $0x2,0x10(%rbp)
jne    1318 <get_data_for_query+0x158>
movl   $0x0,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x4,%eax
ja     166b <get_data_for_query+0x4ab>
mov    -0x60(%rbp),%rax
lea    0xcc8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1373 <get_data_for_query+0x1b3>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1373 <get_data_for_query+0x1b3>
cmpl   $0x0,0x10(%rbp)
jne    13ac <get_data_for_query+0x1ec>
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <sqlite3_column_int@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    %eax,%ecx
lea    0xcae(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    13e0 <get_data_for_query+0x220>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <sqlite3_column_int@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    %eax,%ecx
lea    0xc75(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    166b <get_data_for_query+0x4ab>
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1417 <get_data_for_query+0x257>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1417 <get_data_for_query+0x257>
cmpl   $0x0,0x10(%rbp)
jne    146c <get_data_for_query+0x2ac>
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <sqlite3_column_double@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x84(%rbp),%ecx
mov    %eax,%r8d
lea    0xc29(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14bc <get_data_for_query+0x2fc>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <sqlite3_column_double@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    -0x9c(%rbp),%ecx
mov    %eax,%r8d
lea    0xbd4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    166b <get_data_for_query+0x4ab>
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     14f3 <get_data_for_query+0x333>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     14f3 <get_data_for_query+0x333>
cmpl   $0x0,0x10(%rbp)
jne    1539 <get_data_for_query+0x379>
mov    -0x8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10c0 <sqlite3_column_text@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb8(%rbp),%rdx
mov    %rax,%rcx
lea    0xb99(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    157a <get_data_for_query+0x3ba>
mov    -0x8(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   10c0 <sqlite3_column_text@plt>
mov    -0xd0(%rbp),%rdi
mov    -0xc8(%rbp),%rdx
mov    %rax,%rcx
lea    0xb53(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    166b <get_data_for_query+0x4ab>
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     15b1 <get_data_for_query+0x3f1>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     15b1 <get_data_for_query+0x3f1>
cmpl   $0x0,0x10(%rbp)
jne    15d3 <get_data_for_query+0x413>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xb06(%rip),%rsi
lea    0xb3a(%rip),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15f0 <get_data_for_query+0x430>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xae4(%rip),%rsi
lea    0xb18(%rip),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    166b <get_data_for_query+0x4ab>
mov    -0x44(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1627 <get_data_for_query+0x467>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1627 <get_data_for_query+0x467>
cmpl   $0x0,0x10(%rbp)
jne    1649 <get_data_for_query+0x489>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xa90(%rip),%rsi
lea    0xac9(%rip),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1666 <get_data_for_query+0x4a6>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xa6e(%rip),%rsi
lea    0xaa7(%rip),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    166b <get_data_for_query+0x4ab>
jmp    1670 <get_data_for_query+0x4b0>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12cf <get_data_for_query+0x10f>
mov    -0x8(%rbp),%rdi
lea    0xa82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    128a <get_data_for_query+0xca>
mov    -0x58(%rbp),%rdi
call   10d0 <sqlite3_finalize@plt>
mov    -0x50(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_data_for_query>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%rax
mov    %rdi,%r12
movq   $0x0,0x28(%rsp)
movq   $0x0,(%rsp)
lea    0x28(%rsp),%rsi
mov    %rax,%rdi
call   1040 <sqlite3_open@plt>
mov    0x28(%rsp),%rdi
mov    %rsp,%rcx
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10f0 <sqlite3_prepare_v2@plt>
mov    0x2dac(%rip),%rcx
cmp    (%rcx),%eax
jne    154e <get_data_for_query+0x36e>
mov    %ebp,0x24(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14,0x10(%rsp)
mov    (%rsp),%rdi
call   10c0 <sqlite3_column_count@plt>
lea    0xdb2(%rip),%rdi
mov    %eax,0x34(%rsp)
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1090 <sqlite3_step@plt>
mov    0x2d59(%rip),%rcx
cmp    (%rcx),%rax
jne    155c <get_data_for_query+0x37c>
mov    %r12,%rbx
mov    0x70(%rsp),%r12d
xor    %eax,%eax
cmp    $0x1,%r12d
sete   %al
mov    %eax,0x30(%rsp)
xor    %r13d,%r13d
cmp    $0x2,%r12d
sete   %r13b
mov    $0x1,%r14d
xor    $0x2,%r12d
mov    $0x1,%ebp
mov    %rbx,0x8(%rsp)
jmp    12f7 <get_data_for_query+0x117>
xchg   %ax,%ax
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xe17(%rip),%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
call   1100 <fwrite@plt>
mov    (%rsp),%rdi
call   1090 <sqlite3_step@plt>
mov    0x2cea(%rip),%rcx
cmp    (%rcx),%rax
jne    155c <get_data_for_query+0x37c>
add    0x30(%rsp),%ebp
mov    $0x5,%esi
mov    $0x1,%edx
lea    0xd19(%rip),%rdi
mov    %rbx,%rcx
call   1100 <fwrite@plt>
mov    0x34(%rsp),%ebx
test   %ebx,%ebx
jle    12c0 <get_data_for_query+0xe0>
xor    %r15d,%r15d
jmp    1355 <get_data_for_query+0x175>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   10d0 <sqlite3_column_text@plt>
mov    0x8(%rsp),%rdi
lea    0xd6a(%rip),%rsi
mov    0x18(%rsp),%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%r15d
cmp    %r15d,%ebx
je     12c0 <get_data_for_query+0xe0>
add    %r13d,%r14d
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1080 <sqlite3_column_type@plt>
mov    %r12d,%ecx
or     %r15d,%ecx
mov    $0x0,%ecx
cmove  %ecx,%r14d
add    $0xffffff80,%eax
cmp    $0x4,%eax
ja     1348 <get_data_for_query+0x168>
lea    0xc7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
test   $0x1,%bpl
je     1321 <get_data_for_query+0x141>
cmpl   $0x0,0x70(%rsp)
je     1321 <get_data_for_query+0x141>
mov    %r14d,%eax
and    $0x1,%eax
je     1321 <get_data_for_query+0x141>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   10d0 <sqlite3_column_text@plt>
mov    0x8(%rsp),%rdi
lea    0xceb(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %rax,%rcx
jmp    1341 <get_data_for_query+0x161>
test   $0x1,%bpl
jne    145d <get_data_for_query+0x27d>
mov    0x8(%rsp),%rdi
lea    0xcc8(%rip),%rsi
mov    0x18(%rsp),%rdx
jmp    1485 <get_data_for_query+0x2a5>
test   $0x1,%bpl
jne    1491 <get_data_for_query+0x2b1>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1070 <sqlite3_column_int@plt>
mov    0x8(%rsp),%rdi
lea    0xc24(%rip),%rsi
mov    0x18(%rsp),%rdx
jmp    14c5 <get_data_for_query+0x2e5>
test   $0x1,%bpl
jne    14d3 <get_data_for_query+0x2f3>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1060 <sqlite3_column_double@plt>
mov    0x8(%rsp),%rdi
lea    0xc33(%rip),%rsi
mov    0x18(%rsp),%rdx
jmp    1507 <get_data_for_query+0x327>
test   $0x1,%bpl
jne    151a <get_data_for_query+0x33a>
mov    0x8(%rsp),%rdi
lea    0xc50(%rip),%rsi
mov    0x18(%rsp),%rdx
jmp    1542 <get_data_for_query+0x362>
cmpl   $0x0,0x70(%rsp)
je     13cf <get_data_for_query+0x1ef>
mov    %r14d,%eax
and    $0x1,%eax
je     13cf <get_data_for_query+0x1ef>
mov    0x8(%rsp),%rdi
lea    0xc23(%rip),%rsi
mov    0x10(%rsp),%rdx
lea    0xc57(%rip),%rcx
jmp    1341 <get_data_for_query+0x161>
cmpl   $0x0,0x70(%rsp)
je     13ef <get_data_for_query+0x20f>
mov    %r14d,%eax
and    $0x1,%eax
je     13ef <get_data_for_query+0x20f>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1070 <sqlite3_column_int@plt>
mov    0x8(%rsp),%rdi
lea    0xb6b(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1348 <get_data_for_query+0x168>
cmpl   $0x0,0x70(%rsp)
je     141b <get_data_for_query+0x23b>
mov    %r14d,%eax
and    $0x1,%eax
je     141b <get_data_for_query+0x23b>
mov    (%rsp),%rdi
mov    %r15d,%esi
call   1060 <sqlite3_column_double@plt>
mov    0x8(%rsp),%rdi
lea    0xb64(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    0x24(%rsp),%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1348 <get_data_for_query+0x168>
cmpl   $0x0,0x70(%rsp)
je     1447 <get_data_for_query+0x267>
mov    %r14d,%eax
and    $0x1,%eax
je     1447 <get_data_for_query+0x267>
mov    0x8(%rsp),%rdi
lea    0xb66(%rip),%rsi
mov    0x10(%rsp),%rdx
lea    0xb95(%rip),%rcx
jmp    1341 <get_data_for_query+0x161>
lea    0xb9a(%rip),%rdi
call   1030 <puts@plt>
jmp    156f <get_data_for_query+0x38f>
mov    (%rsp),%rdi
call   10e0 <sqlite3_finalize@plt>
mov    0x28(%rsp),%rdi
call   10b0 <sqlite3_close@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SQLITE_OK = global i32 0
@.str = [35 x i8] c"SQLite couldn't parse SQL string.\0A\00"
@.str.1 = [17 x i8] c"Column Count %i\0A\00"
@SQLITE_ROW = global i64 0
@.str.2 = [6 x i8] c"<tr>\0A\00"
@.str.3 = [59 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%i</td>\0A\00"
@.str.4 = [61 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%.*f</td>\0A\00"
@.str.5 = [59 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%s</td>\0A\00"
@.str.6 = [5 x i8] c"Blob\00"
@.str.7 = [5 x i8] c"Null\00"
@.str.8 = [7 x i8] c"</tr>\0A\00"
define void @get_data_for_query(i32* %0, i8* %1, i8* %2, i32 %3, i8* %4, i8* %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32*
%22 = alloca i32*
store i32* %0, i32** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i32 %6, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 1, i32* %19
store i32 1, i32* %20
store i32* null, i32** %21
store i32* null, i32** %22
%23 = load i8*, i8** %9
%24 = call i32 @sqlite3_open(i8* %23, i32** %21)
%25 = load i32*, i32** %21
%26 = load i8*, i8** %10
%27 = call i32 @sqlite3_prepare_v2(i32* %25, i8* %26, i32 -1, i32** %22, i32 0)
store i32 %27, i32* %18
%28 = load i32, i32* %18
%29 = load i32, i32* @SQLITE_OK
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %206
33: ; preds = %7
%34 = load i32*, i32** %22
%35 = call i32 @sqlite3_column_count(i32* %34)
store i32 %35, i32* %16
%36 = load i32, i32* %16
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %198, %33
%39 = load i32*, i32** %22
%40 = call i64 @sqlite3_step(i32* %39)
%41 = load i64, i64* @SQLITE_ROW
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %201
43: ; preds = %38
%44 = load i32, i32* %14
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %19
%48 = add nsw i32 %47, 1
store i32 %48, i32* %19
br label %49
49: ; preds = %46, %43
%50 = load i32*, i32** %8
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %15
br label %52
52: ; preds = %195, %49
%53 = load i32, i32* %15
%54 = load i32, i32* %16
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %198
56: ; preds = %52
%57 = load i32*, i32** %22
%58 = load i32, i32* %15
%59 = call i32 @sqlite3_column_type(i32* %57, i32 %58)
store i32 %59, i32* %17
%60 = load i32, i32* %14
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %65
62: ; preds = %56
%63 = load i32, i32* %20
%64 = add nsw i32 %63, 1
store i32 %64, i32* %20
br label %65
65: ; preds = %62, %56
%66 = load i32, i32* %15
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = load i32, i32* %14
%70 = icmp eq i32 %69, 2
br i1 %70, label %71, label %72
71: ; preds = %68
store i32 0, i32* %20
br label %72
72: ; preds = %71, %68, %65
%73 = load i32, i32* %17
switch i32 %73, label %194 [
i32 130, label %74
i32 131, label %100
i32 128, label %128
i32 132, label %154
i32 129, label %174
]
74: ; preds = %72
%75 = load i32, i32* %19
%76 = srem i32 %75, 2
%77 = icmp eq i32 %76, 0
br i1 %77, label %85, label %78
78: ; preds = %74
%79 = load i32, i32* %20
%80 = srem i32 %79, 2
%81 = icmp eq i32 %80, 0
br i1 %81, label %85, label %82
82: ; preds = %78
%83 = load i32, i32* %14
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %82, %78, %74
%86 = load i32*, i32** %8
%87 = load i8*, i8** %12
%88 = load i32*, i32** %22
%89 = load i32, i32* %15
%90 = call i32 @sqlite3_column_int(i32* %88, i32 %89)
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %87, i32 %90)
br label %99
92: ; preds = %82
%93 = load i32*, i32** %8
%94 = load i8*, i8** %13
%95 = load i32*, i32** %22
%96 = load i32, i32* %15
%97 = call i32 @sqlite3_column_int(i32* %95, i32 %96)
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %94, i32 %97)
br label %99
99: ; preds = %92, %85
br label %194
100: ; preds = %72
%101 = load i32, i32* %19
%102 = srem i32 %101, 2
%103 = icmp eq i32 %102, 0
br i1 %103, label %111, label %104
104: ; preds = %100
%105 = load i32, i32* %20
%106 = srem i32 %105, 2
%107 = icmp eq i32 %106, 0
br i1 %107, label %111, label %108
108: ; preds = %104
%109 = load i32, i32* %14
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %119
111: ; preds = %108, %104, %100
%112 = load i32*, i32** %8
%113 = load i8*, i8** %12
%114 = load i32, i32* %11
%115 = load i32*, i32** %22
%116 = load i32, i32* %15
%117 = call i32 @sqlite3_column_double(i32* %115, i32 %116)
%118 = call i32 (i32*, i8*, ...) @fprintf(i32* %112, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %113, i32 %114, i32 %117)
br label %127
119: ; preds = %108
%120 = load i32*, i32** %8
%121 = load i8*, i8** %13
%122 = load i32, i32* %11
%123 = load i32*, i32** %22
%124 = load i32, i32* %15
%125 = call i32 @sqlite3_column_double(i32* %123, i32 %124)
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %121, i32 %122, i32 %125)
br label %127
127: ; preds = %119, %111
br label %194
128: ; preds = %72
%129 = load i32, i32* %19
%130 = srem i32 %129, 2
%131 = icmp eq i32 %130, 0
br i1 %131, label %139, label %132
132: ; preds = %128
%133 = load i32, i32* %20
%134 = srem i32 %133, 2
%135 = icmp eq i32 %134, 0
br i1 %135, label %139, label %136
136: ; preds = %132
%137 = load i32, i32* %14
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %146
139: ; preds = %136, %132, %128
%140 = load i32*, i32** %8
%141 = load i8*, i8** %12
%142 = load i32*, i32** %22
%143 = load i32, i32* %15
%144 = call i8* @sqlite3_column_text(i32* %142, i32 %143)
%145 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %141, i8* %144)
br label %153
146: ; preds = %136
%147 = load i32*, i32** %8
%148 = load i8*, i8** %13
%149 = load i32*, i32** %22
%150 = load i32, i32* %15
%151 = call i8* @sqlite3_column_text(i32* %149, i32 %150)
%152 = call i32 (i32*, i8*, ...) @fprintf(i32* %147, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %148, i8* %151)
br label %153
153: ; preds = %146, %139
br label %194
154: ; preds = %72
%155 = load i32, i32* %19
%156 = srem i32 %155, 2
%157 = icmp eq i32 %156, 0
br i1 %157, label %165, label %158
158: ; preds = %154
%159 = load i32, i32* %20
%160 = srem i32 %159, 2
%161 = icmp eq i32 %160, 0
br i1 %161, label %165, label %162
162: ; preds = %158
%163 = load i32, i32* %14
%164 = icmp eq i32 %163, 0
br i1 %164, label %165, label %169
165: ; preds = %162, %158, %154
%166 = load i32*, i32** %8
%167 = load i8*, i8** %12
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %166, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %167, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %173
169: ; preds = %162
%170 = load i32*, i32** %8
%171 = load i8*, i8** %13
%172 = call i32 (i32*, i8*, ...) @fprintf(i32* %170, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %171, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %173
173: ; preds = %169, %165
br label %194
174: ; preds = %72
%175 = load i32, i32* %19
%176 = srem i32 %175, 2
%177 = icmp eq i32 %176, 0
br i1 %177, label %185, label %178
178: ; preds = %174
%179 = load i32, i32* %20
%180 = srem i32 %179, 2
%181 = icmp eq i32 %180, 0
br i1 %181, label %185, label %182
182: ; preds = %178
%183 = load i32, i32* %14
%184 = icmp eq i32 %183, 0
br i1 %184, label %185, label %189
185: ; preds = %182, %178, %174
%186 = load i32*, i32** %8
%187 = load i8*, i8** %12
%188 = call i32 (i32*, i8*, ...) @fprintf(i32* %186, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %187, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %193
189: ; preds = %182
%190 = load i32*, i32** %8
%191 = load i8*, i8** %13
%192 = call i32 (i32*, i8*, ...) @fprintf(i32* %190, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %191, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %193
193: ; preds = %189, %185
br label %194
194: ; preds = %72, %193, %173, %153, %127, %99
br label %195
195: ; preds = %194
%196 = load i32, i32* %15
%197 = add nsw i32 %196, 1
store i32 %197, i32* %15
br label %52
198: ; preds = %52
%199 = load i32*, i32** %8
%200 = call i32 (i32*, i8*, ...) @fprintf(i32* %199, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %38
201: ; preds = %38
%202 = load i32*, i32** %22
%203 = call i32 @sqlite3_finalize(i32* %202)
%204 = load i32*, i32** %21
%205 = call i32 @sqlite3_close(i32* %204)
br label %206
206: ; preds = %201, %31
ret void
}

LLVM IR (-O2):
@SQLITE_OK = global i32 0
@.str.1 = [17 x i8] c"Column Count %i\0A\00"
@SQLITE_ROW = global i64 0
@.str.2 = [6 x i8] c"<tr>\0A\00"
@.str.3 = [59 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%i</td>\0A\00"
@.str.4 = [61 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%.*f</td>\0A\00"
@.str.5 = [59 x i8] c"<td style=\22border:1px solid\22 bgcolor=\22%s\22>%s</td>\0A\00"
@.str.6 = [5 x i8] c"Blob\00"
@.str.7 = [5 x i8] c"Null\00"
@.str.8 = [7 x i8] c"</tr>\0A\00"
@str = [34 x i8] c"SQLite couldn't parse SQL string.\00"
define void @get_data_for_query(i32* nocapture %0, i8* %1, i8* %2, i32 %3, i8* %4, i8* %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32*
%10 = bitcast i32** %8 to i8*
store i32* null, i32** %8
%11 = bitcast i32** %9 to i8*
store i32* null, i32** %9
%12 = call i32 @sqlite3_open(i8* %1, i32** %8)
%13 = load i32*, i32** %8
%14 = call i32 @sqlite3_prepare_v2(i32* %13, i8* %2, i32 -1, i32** %9, i32 0)
%15 = load i32, i32* @SQLITE_OK
%16 = icmp eq i32 %14, %15
br i1 %16, label %19, label %17
17: ; preds = %7
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %123
19: ; preds = %7
%20 = load i32*, i32** %9
%21 = call i32 @sqlite3_column_count(i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %9
%24 = call i64 @sqlite3_step(i32* %23)
%25 = load i64, i64* @SQLITE_ROW
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %118
27: ; preds = %19
%28 = icmp eq i32 %6, 1
%29 = zext i1 %28 to i32
%30 = icmp sgt i32 %21, 0
%31 = icmp eq i32 %6, 2
%32 = zext i1 %31 to i32
%33 = icmp eq i32 %6, 0
br label %34
34: ; preds = %27, %111
%35 = phi i32 [ 1, %27 ], [ %112, %111 ]
%36 = phi i32 [ 1, %27 ], [ %37, %111 ]
%37 = add nuw nsw i32 %36, %29
%38 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i64 1, i32* %0)
br i1 %30, label %39, label %111
39: ; preds = %34
%40 = and i32 %37, 1
%41 = icmp eq i32 %40, 0
br label %42
42: ; preds = %39, %108
%43 = phi i32 [ %35, %39 ], [ %50, %108 ]
%44 = phi i32 [ 0, %39 ], [ %109, %108 ]
%45 = load i32*, i32** %9
%46 = call i32 @sqlite3_column_type(i32* %45, i32 %44)
%47 = add nsw i32 %43, %32
%48 = icmp eq i32 %44, 0
%49 = and i1 %31, %48
%50 = select i1 %49, i32 0, i32 %47
switch i32 %46, label %108 [
i32 130, label %51
i32 131, label %64
i32 128, label %77
i32 132, label %90
i32 129, label %99
]
51: ; preds = %42
br i1 %41, label %56, label %52
52: ; preds = %51
%53 = and i32 %50, 1
%54 = icmp eq i32 %53, 0
%55 = or i1 %33, %54
br i1 %55, label %56, label %60
56: ; preds = %52, %51
%57 = load i32*, i32** %9
%58 = call i32 @sqlite3_column_int(i32* %57, i32 %44)
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %58)
br label %108
60: ; preds = %52
%61 = load i32*, i32** %9
%62 = call i32 @sqlite3_column_int(i32* %61, i32 %44)
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 %62)
br label %108
64: ; preds = %42
br i1 %41, label %69, label %65
65: ; preds = %64
%66 = and i32 %50, 1
%67 = icmp eq i32 %66, 0
%68 = or i1 %33, %67
br i1 %68, label %69, label %73
69: ; preds = %65, %64
%70 = load i32*, i32** %9
%71 = call i32 @sqlite3_column_double(i32* %70, i32 %44)
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %3, i32 %71)
br label %108
73: ; preds = %65
%74 = load i32*, i32** %9
%75 = call i32 @sqlite3_column_double(i32* %74, i32 %44)
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %5, i32 %3, i32 %75)
br label %108
77: ; preds = %42
br i1 %41, label %82, label %78
78: ; preds = %77
%79 = and i32 %50, 1
%80 = icmp eq i32 %79, 0
%81 = or i1 %33, %80
br i1 %81, label %82, label %86
82: ; preds = %78, %77
%83 = load i32*, i32** %9
%84 = call i8* @sqlite3_column_text(i32* %83, i32 %44)
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* %84)
br label %108
86: ; preds = %78
%87 = load i32*, i32** %9
%88 = call i8* @sqlite3_column_text(i32* %87, i32 %44)
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %88)
br label %108
90: ; preds = %42
br i1 %41, label %95, label %91
91: ; preds = %90
%92 = and i32 %50, 1
%93 = icmp eq i32 %92, 0
%94 = or i1 %33, %93
br i1 %94, label %95, label %97
95: ; preds = %91, %90
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %108
97: ; preds = %91
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %108
99: ; preds = %42
br i1 %41, label %104, label %100
100: ; preds = %99
%101 = and i32 %50, 1
%102 = icmp eq i32 %101, 0
%103 = or i1 %33, %102
br i1 %103, label %104, label %106
104: ; preds = %100, %99
%105 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %108
106: ; preds = %100
%107 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %108
108: ; preds = %42, %60, %56, %73, %69, %86, %82, %97, %95, %106, %104
%109 = add nuw nsw i32 %44, 1
%110 = icmp eq i32 %109, %21
br i1 %110, label %111, label %42
111: ; preds = %108, %34
%112 = phi i32 [ %35, %34 ], [ %50, %108 ]
%113 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i64 6, i64 1, i32* %0)
%114 = load i32*, i32** %9
%115 = call i64 @sqlite3_step(i32* %114)
%116 = load i64, i64* @SQLITE_ROW
%117 = icmp eq i64 %115, %116
br i1 %117, label %34, label %118
118: ; preds = %111, %19
%119 = load i32*, i32** %9
%120 = call i32 @sqlite3_finalize(i32* %119)
%121 = load i32*, i32** %8
%122 = call i32 @sqlite3_close(i32* %121)
br label %123
123: ; preds = %118, %17
ret void
}