#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 SQLITE_OK;
int asprintf(char **, char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int get_column_count(char *, char *);
int /*<<< orphan*/ make_html_table(char *, char *, char *, char **, int, int,
                                   int, char *, char *, int, char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_column_name(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*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void parse_sql_field_names(char *html_file_name, char *database_name, char *sql,
                           int precision, int font_size, char *bg_color1,
                           char *bg_color2, int alternate,
                           char *field_bg_color) {
  int i = 0;
  int commas = 0;
  int fields = 0;
  bool fields_found = true;
  int field_count = 0;
  int as_return = 0;
  int sql_return = 0;
  char *start;
  char *end;
  char c1 = 'a';
  char c2 = 'b';
  char c3 = 'c';
  char c4 = 'd';
  sqlite3 *handle = NULL;
  sqlite3_stmt *stmt = NULL;
  start = sql;
  end = strstr(sql, "FROM");
  if (end == NULL) {
    printf("Can't find FROM in the SQL statement.\n");
  } else {
    while (start < end) {
      c3 = c2;
      c2 = c1;
      c1 = *start;
      if (c3 == ' ' && c2 == '*' && c1 == ' ') {
        printf("No field names in sql string.\n");
        fields_found = false;
      }
      if (*start == ',') {
        commas++;
      }
      start++;
    }
    if (fields_found == false) {
      field_count = get_column_count(database_name, sql);
      commas = field_count - 1;
    }
    char *field_names[commas + 1];
    for (i = 0; i < commas + 1; i++)
      field_names[i] = NULL;
    if (fields_found == false) {
      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 {
        for (i = 0; i < field_count; i++) {
          as_return =
              asprintf(&field_names[i], "%s", sqlite3_column_name(stmt, i));
          if (as_return == -1)
            printf("Memory allocation failed in asprintf.\n");
        }
      }
      sqlite3_finalize(stmt);
      sqlite3_close(handle);
    }
    i = 0;
    if (fields_found == true) {
      int j = 7;
      int k = 7;
      start = sql + 7;
      while (start < end) {
        c4 = c3;
        c3 = c2;
        c2 = c1;
        c1 = *start;
        if (c4 == ' ' && c3 == 'A' && c2 == 'S' && c1 == ' ') {
          k = j + 1;
          printf("Found ' AS '\n");
        }
        if (*start == ',' || start == end - 1) {
          field_names[i] = (char *)malloc((j - k + 1) * sizeof(char));
          if (field_names[i] != NULL)
            memset(field_names[i], '\0', j - k + 1);
          if (field_names[i] == NULL)
            printf("Malloc error.\n");
          strncpy(field_names[i], sql + k, j - k);
          i++;
          k = j + 2;
        }
        j++;
        start++;
      }
    }
    for (i = 0; i < commas + 1; i++) {
      printf("Field %s\n", field_names[i]);
    }
    fields = commas + 1;
    make_html_table(html_file_name, database_name, sql, field_names, fields,
                    precision, font_size, bg_color1, bg_color2, alternate,
                    field_bg_color, fields_found);
    for (i = 0; i < commas + 1; i++) {
      if (field_names[i] != NULL)
        free(field_names[i]);
    }
  }
}


x86 assembly (clang, -O0):
<parse_sql_field_names>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %ecx,-0x34(%rbp)
mov    %r8d,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x1,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movb   $0x61,-0x71(%rbp)
movb   $0x62,-0x72(%rbp)
movb   $0x63,-0x73(%rbp)
movb   $0x64,-0x74(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   1100 <strstr@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    12a0 <parse_sql_field_names+0xc0>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1777 <parse_sql_field_names+0x597>
jmp    12a5 <parse_sql_field_names+0xc5>
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
jae    132e <parse_sql_field_names+0x14e>
mov    -0x72(%rbp),%al
mov    %al,-0x73(%rbp)
mov    -0x71(%rbp),%al
mov    %al,-0x72(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x71(%rbp)
movsbl -0x73(%rbp),%eax
cmp    $0x20,%eax
jne    1304 <parse_sql_field_names+0x124>
movsbl -0x72(%rbp),%eax
cmp    $0x2a,%eax
jne    1304 <parse_sql_field_names+0x124>
movsbl -0x71(%rbp),%eax
cmp    $0x20,%eax
jne    1304 <parse_sql_field_names+0x124>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    131d <parse_sql_field_names+0x13d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    12a5 <parse_sql_field_names+0xc5>
cmpl   $0x0,-0x50(%rbp)
jne    1351 <parse_sql_field_names+0x171>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <get_column_count@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x90(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    13bd <parse_sql_field_names+0x1dd>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    138b <parse_sql_field_names+0x1ab>
cmpl   $0x0,-0x50(%rbp)
jne    14b0 <parse_sql_field_names+0x2d0>
mov    -0x28(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1070 <sqlite3_open@plt>
mov    -0x80(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x88(%rbp),%rcx
xor    %r8d,%r8d
call   10e0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    0x2beb(%rip),%rcx
cmp    (%rcx),%eax
je     1418 <parse_sql_field_names+0x238>
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    149b <parse_sql_field_names+0x2bb>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1496 <parse_sql_field_names+0x2b6>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1060 <sqlite3_column_name@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%edx
lea    0xc0b(%rip),%rsi
call   10c0 <asprintf@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    1483 <parse_sql_field_names+0x2a3>
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1488 <parse_sql_field_names+0x2a8>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    141f <parse_sql_field_names+0x23f>
jmp    149b <parse_sql_field_names+0x2bb>
mov    -0x88(%rbp),%rdi
call   10d0 <sqlite3_finalize@plt>
mov    -0x80(%rbp),%rdi
call   10a0 <sqlite3_close@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x1,-0x50(%rbp)
jne    1671 <parse_sql_field_names+0x491>
movl   $0x7,-0x9c(%rbp)
movl   $0x7,-0xa0(%rbp)
mov    -0x30(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
jae    166c <parse_sql_field_names+0x48c>
mov    -0x73(%rbp),%al
mov    %al,-0x74(%rbp)
mov    -0x72(%rbp),%al
mov    %al,-0x73(%rbp)
mov    -0x71(%rbp),%al
mov    %al,-0x72(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x71(%rbp)
movsbl -0x74(%rbp),%eax
cmp    $0x20,%eax
jne    155b <parse_sql_field_names+0x37b>
movsbl -0x73(%rbp),%eax
cmp    $0x41,%eax
jne    155b <parse_sql_field_names+0x37b>
movsbl -0x72(%rbp),%eax
cmp    $0x53,%eax
jne    155b <parse_sql_field_names+0x37b>
movsbl -0x71(%rbp),%eax
cmp    $0x20,%eax
jne    155b <parse_sql_field_names+0x37b>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
lea    0xb44(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     1580 <parse_sql_field_names+0x3a0>
mov    -0x68(%rbp),%rax
mov    -0x70(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    164c <parse_sql_field_names+0x46c>
mov    -0x9c(%rbp),%eax
sub    -0xa0(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rdx
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x44(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     15e2 <parse_sql_field_names+0x402>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x9c(%rbp),%edx
sub    -0xa0(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1606 <parse_sql_field_names+0x426>
lea    0xaa7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
movslq -0xa0(%rbp),%rax
add    %rax,%rsi
mov    -0x9c(%rbp),%edx
sub    -0xa0(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    14e1 <parse_sql_field_names+0x301>
jmp    1671 <parse_sql_field_names+0x491>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    16b4 <parse_sql_field_names+0x4d4>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xa16(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1678 <parse_sql_field_names+0x498>
mov    -0xa8(%rbp),%rcx
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x4c(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    -0x38(%rbp),%r15d
mov    -0x40(%rbp),%r14
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10
mov    -0x50(%rbp),%eax
sub    $0x30,%rsp
mov    %r15d,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %eax,0x28(%rsp)
call   10f0 <make_html_table@plt>
add    $0x30,%rsp
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    176d <parse_sql_field_names+0x58d>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     175a <parse_sql_field_names+0x57a>
mov    -0xa8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    175f <parse_sql_field_names+0x57f>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    171f <parse_sql_field_names+0x53f>
mov    -0x90(%rbp),%rax
mov    %rax,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sql_field_names>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r9,-0xd0(%rbp)
mov    %r8d,%r15d
mov    %ecx,-0x54(%rbp)
mov    %rdx,%r14
mov    %rsi,-0x78(%rbp)
mov    %rdi,-0xc8(%rbp)
mov    0x20(%rbp),%r13
mov    0x18(%rbp),%r12d
mov    0x10(%rbp),%rbx
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0x90(%rbp)
lea    0xdb8(%rip),%rsi
mov    %rdx,%rdi
call   1110 <strstr@plt>
test   %rax,%rax
je     1300 <parse_sql_field_names+0x110>
mov    %r13,-0xa8(%rbp)
mov    %r12,-0xb0(%rbp)
mov    %rbx,-0xb8(%rbp)
mov    %r15,-0xc0(%rbp)
mov    %rax,-0x60(%rbp)
sub    %r14,%rax
mov    %rax,-0x88(%rbp)
mov    %r14,-0x38(%rbp)
jbe    131a <parse_sql_field_names+0x12a>
mov    %r14,%rsi
mov    $0x1,%edi
mov    $0x61,%r15b
mov    $0x62,%al
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    12ca <parse_sql_field_names+0xda>
mov    %r15d,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    $0x2c,%al
sete   %cl
add    %ecx,%r12d
add    $0x1,%rbx
mov    %r14d,%eax
cmp    %rbx,-0x88(%rbp)
je     1330 <parse_sql_field_names+0x140>
mov    %r15d,%r14d
mov    %eax,%r13d
movzbl (%rsi,%rbx,1),%r15d
cmp    $0x20,%al
jne    12a1 <parse_sql_field_names+0xb1>
mov    %r15d,%eax
cmp    $0x2a,%r14b
jne    12b0 <parse_sql_field_names+0xc0>
cmp    $0x20,%r15b
jne    12b0 <parse_sql_field_names+0xc0>
lea    0xd86(%rip),%rdi
call   1060 <puts@plt>
mov    -0x38(%rbp),%rsi
movzbl (%rsi,%rbx,1),%eax
xor    %edi,%edi
jmp    12b0 <parse_sql_field_names+0xc0>
lea    0xd8c(%rip),%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <puts@plt>
xor    %r12d,%r12d
mov    $0x1,%eax
mov    %rax,-0x50(%rbp)
mov    $0x61,%r15b
mov    $0x62,%bl
mov    $0x63,%r13b
jmp    133f <parse_sql_field_names+0x14f>
test   %edi,%edi
je     1619 <parse_sql_field_names+0x429>
mov    %rdi,-0x50(%rbp)
mov    %r14d,%ebx
mov    %rsp,-0x70(%rbp)
lea    0x1(%r12),%r14d
mov    %rsp,%rdi
lea    0xf(,%r14,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
mov    %r12d,%eax
lea    0x8(,%rax,8),%rdx
movl   $0x0,-0x3c(%rbp)
mov    %rdi,-0x48(%rbp)
xor    %esi,%esi
call   10a0 <memset@plt>
mov    %r14,-0x80(%rbp)
mov    -0x38(%rbp),%rdx
mov    -0x60(%rbp),%r8
mov    %ebx,%ecx
cmpl   $0x1,-0x50(%rbp)
mov    %r14,-0x68(%rbp)
jne    150e <parse_sql_field_names+0x31e>
lea    0x7(%rdx),%rax
mov    %rax,-0xd8(%rbp)
cmp    %r8,%rax
jae    150e <parse_sql_field_names+0x31e>
add    $0xffffffffffffffff,%r8
addq   $0xfffffffffffffff9,-0x88(%rbp)
f9
xor    %r12d,%r12d
mov    $0x7,%edi
movl   $0x0,-0x58(%rbp)
mov    %r8,-0x60(%rbp)
jmp    141b <parse_sql_field_names+0x22b>
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rdx
add    $0x7,%rdx
movslq -0x9c(%rbp),%rsi
mov    -0x38(%rbp),%rbx
add    %rbx,%rsi
call   1040 <strncpy@plt>
mov    %rbx,%rdx
addl   $0x1,-0x58(%rbp)
lea    0x9(%r12),%edi
mov    -0x60(%rbp),%r8
movzbl -0x29(%rbp),%ecx
add    $0x1,%r12
mov    %ecx,%r13d
mov    %r15d,%ecx
movzbl -0x2a(%rbp),%r15d
cmp    %r12,-0x88(%rbp)
je     150e <parse_sql_field_names+0x31e>
mov    -0xd8(%rbp),%rax
lea    (%rax,%r12,1),%r14
movzbl (%rax,%r12,1),%eax
cmp    $0x20,%r13b
mov    %al,-0x2a(%rbp)
jne    1480 <parse_sql_field_names+0x290>
cmp    $0x41,%cl
jne    1480 <parse_sql_field_names+0x290>
cmp    $0x53,%r15b
jne    1480 <parse_sql_field_names+0x290>
mov    %eax,%ebx
cmp    $0x20,%al
jne    1476 <parse_sql_field_names+0x286>
mov    %r15b,-0x29(%rbp)
lea    0x8(%r12),%r15d
mov    %ecx,%r13d
lea    0xbc8(%rip),%rdi
mov    %r8,%rbx
call   1060 <puts@plt>
mov    %r15d,%edi
movzbl -0x29(%rbp),%r15d
mov    %rbx,%r8
mov    %r13d,%ecx
mov    -0x38(%rbp),%rdx
movzbl (%r14),%ebx
cmp    $0x2c,%bl
jne    1487 <parse_sql_field_names+0x297>
jmp    14a0 <parse_sql_field_names+0x2b0>
nopl   (%rax)
mov    %eax,%ebx
cmp    $0x2c,%bl
je     14a0 <parse_sql_field_names+0x2b0>
cmp    %r8,%r14
je     14a0 <parse_sql_field_names+0x2b0>
mov    -0x68(%rbp),%r14
jmp    13ff <parse_sql_field_names+0x20f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %cl,-0x29(%rbp)
mov    %edi,-0x9c(%rbp)
mov    %edi,%ebx
neg    %ebx
lea    (%r12,%rbx,1),%r13
add    $0x8,%r13
mov    %r13d,%edi
call   10c0 <malloc@plt>
mov    %rax,%rdi
movslq -0x58(%rbp),%rax
mov    -0x48(%rbp),%r14
mov    %rdi,(%r14,%rax,8)
test   %rdi,%rdi
je     14e5 <parse_sql_field_names+0x2f5>
xor    %esi,%esi
mov    %r13d,%edx
mov    %rax,%r13
call   10a0 <memset@plt>
mov    %r13,%rax
mov    (%r14,%r13,8),%rdi
mov    -0x68(%rbp),%r14
test   %rdi,%rdi
jne    13d0 <parse_sql_field_names+0x1e0>
lea    0xb19(%rip),%rdi
mov    %rax,%r13
call   1060 <puts@plt>
mov    -0x48(%rbp),%rax
mov    (%rax,%r13,8),%rdi
jmp    13d0 <parse_sql_field_names+0x1e0>
cmpb   $0x0,-0x3c(%rbp)
je     155d <parse_sql_field_names+0x36d>
mov    -0xc8(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x48(%rbp),%rcx
mov    %r14d,%r8d
mov    -0x54(%rbp),%r9d
push   -0x50(%rbp)
push   -0xa8(%rbp)
push   -0xb0(%rbp)
push   -0xb8(%rbp)
push   -0xd0(%rbp)
push   -0xc0(%rbp)
call   1100 <make_html_table@plt>
add    $0x30,%rsp
mov    -0x70(%rbp),%r14
jmp    15e1 <parse_sql_field_names+0x3f1>
lea    0xaa4(%rip),%r14
xor    %ebx,%ebx
mov    -0xa8(%rbp),%r13
mov    -0x48(%rbp),%r15
mov    -0x80(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1580 <parse_sql_field_names+0x390>
mov    -0xc8(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    %r15,%rcx
mov    -0x68(%rbp),%r8
mov    -0x54(%rbp),%r9d
push   -0x50(%rbp)
push   %r13
push   -0xb0(%rbp)
push   -0xb8(%rbp)
push   -0xd0(%rbp)
push   -0xc0(%rbp)
call   1100 <make_html_table@plt>
add    $0x30,%rsp
cmpb   $0x0,-0x3c(%rbp)
mov    -0x70(%rbp),%r14
je     15f3 <parse_sql_field_names+0x403>
mov    %r14,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1609 <parse_sql_field_names+0x419>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     15e1 <parse_sql_field_names+0x3f1>
mov    (%r15,%rbx,8),%rdi
test   %rdi,%rdi
je     1600 <parse_sql_field_names+0x410>
call   1030 <free@plt>
jmp    1600 <parse_sql_field_names+0x410>
mov    %r14b,-0x29(%rbp)
mov    -0x78(%rbp),%r14
mov    %r14,%rdi
call   1050 <get_column_count@plt>
mov    %eax,%r12d
mov    %rsp,-0x70(%rbp)
mov    %eax,%eax
mov    %rax,-0x80(%rbp)
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
test   %r12d,%r12d
setle  %al
mov    %eax,-0x3c(%rbp)
jle    166d <parse_sql_field_names+0x47d>
lea    -0x1(%r12),%eax
lea    0x8(,%rax,8),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    %rbx,-0x48(%rbp)
lea    -0x98(%rbp),%rsi
mov    %r14,%rdi
call   1080 <sqlite3_open@plt>
mov    -0x98(%rbp),%rdi
lea    -0x90(%rbp),%rcx
mov    -0x38(%rbp),%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10f0 <sqlite3_prepare_v2@plt>
mov    0x2942(%rip),%rcx
cmp    (%rcx),%eax
jne    1700 <parse_sql_field_names+0x510>
mov    %r12,%r14
test   %r14d,%r14d
jle    170f <parse_sql_field_names+0x51f>
xor    %ebx,%ebx
mov    -0x48(%rbp),%r12
jmp    16ce <parse_sql_field_names+0x4de>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x8,%r12
cmp    %rbx,-0x80(%rbp)
je     170f <parse_sql_field_names+0x51f>
mov    -0x90(%rbp),%rdi
mov    %ebx,%esi
call   1070 <sqlite3_column_name@plt>
mov    %r12,%rdi
lea    0x91f(%rip),%rsi
mov    %eax,%edx
call   10d0 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    16c0 <parse_sql_field_names+0x4d0>
lea    0x934(%rip),%rdi
call   1060 <puts@plt>
jmp    16c0 <parse_sql_field_names+0x4d0>
lea    0x94c(%rip),%rdi
call   1060 <puts@plt>
mov    %r12,%r14
mov    -0x90(%rbp),%rdi
call   10e0 <sqlite3_finalize@plt>
mov    -0x98(%rbp),%rdi
call   10b0 <sqlite3_close@plt>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdx
mov    -0x29(%rbp),%cl
mov    -0x60(%rbp),%r8
jmp    1388 <parse_sql_field_names+0x198>

LLVM IR (-O0):
@.str = [5 x i8] c"FROM\00"
@.str.1 = [39 x i8] c"Can't find FROM in the SQL statement.\0A\00"
@.str.2 = [31 x i8] c"No field names in sql string.\0A\00"
@SQLITE_OK = global i32 0
@.str.3 = [35 x i8] c"SQLite couldn't parse SQL string.\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [39 x i8] c"Memory allocation failed in asprintf.\0A\00"
@.str.6 = [14 x i8] c"Found ' AS '\0A\00"
@.str.7 = [15 x i8] c"Malloc error.\0A\00"
@.str.8 = [10 x i8] c"Field %s\0A\00"
define void @parse_sql_field_names(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i8* %5, i8* %6, i32 %7, i8* %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca i8
%29 = alloca i8
%30 = alloca i8
%31 = alloca i8
%32 = alloca i32*
%33 = alloca i32*
%34 = alloca i8*
%35 = alloca i64
%36 = alloca i32
%37 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i8* %2, i8** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i8* %6, i8** %16
store i32 %7, i32* %17
store i8* %8, i8** %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 1, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
store i32 0, i32* %25
store i8 97, i8* %28
store i8 98, i8* %29
store i8 99, i8* %30
store i8 100, i8* %31
store i32* null, i32** %32
store i32* null, i32** %33
%38 = load i8*, i8** %12
store i8* %38, i8** %26
%39 = load i8*, i8** %12
%40 = call i8* @strstr(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %40, i8** %27
%41 = load i8*, i8** %27
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %9
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %304
45: ; preds = %9
br label %46
46: ; preds = %76, %45
%47 = load i8*, i8** %26
%48 = load i8*, i8** %27
%49 = icmp ult i8* %47, %48
br i1 %49, label %50, label %79
50: ; preds = %46
%51 = load i8, i8* %29
store i8 %51, i8* %30
%52 = load i8, i8* %28
store i8 %52, i8* %29
%53 = load i8*, i8** %26
%54 = load i8, i8* %53
store i8 %54, i8* %28
%55 = load i8, i8* %30
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 32
br i1 %57, label %58, label %68
58: ; preds = %50
%59 = load i8, i8* %29
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 42
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load i8, i8* %28
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 32
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %22
br label %68
68: ; preds = %66, %62, %58, %50
%69 = load i8*, i8** %26
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 44
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = load i32, i32* %20
%75 = add nsw i32 %74, 1
store i32 %75, i32* %20
br label %76
76: ; preds = %73, %68
%77 = load i8*, i8** %26
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %26
br label %46
79: ; preds = %46
%80 = load i32, i32* %22
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = load i8*, i8** %11
%84 = load i8*, i8** %12
%85 = call i32 @get_column_count(i8* %83, i8* %84)
store i32 %85, i32* %23
%86 = load i32, i32* %23
%87 = sub nsw i32 %86, 1
store i32 %87, i32* %20
br label %88
88: ; preds = %82, %79
%89 = load i32, i32* %20
%90 = add nsw i32 %89, 1
%91 = zext i32 %90 to i64
%92 = call i8* @llvm.stacksave()
store i8* %92, i8** %34
%93 = alloca i8*, i64 %91
store i64 %91, i64* %35
store i32 0, i32* %19
br label %94
94: ; preds = %103, %88
%95 = load i32, i32* %19
%96 = load i32, i32* %20
%97 = add nsw i32 %96, 1
%98 = icmp slt i32 %95, %97
br i1 %98, label %99, label %106
99: ; preds = %94
%100 = load i32, i32* %19
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %93, i64 %101
store i8* null, i8** %102
br label %103
103: ; preds = %99
%104 = load i32, i32* %19
%105 = add nsw i32 %104, 1
store i32 %105, i32* %19
br label %94
106: ; preds = %94
%107 = load i32, i32* %22
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %147
109: ; preds = %106
%110 = load i8*, i8** %11
%111 = call i32 @sqlite3_open(i8* %110, i32** %32)
%112 = load i32*, i32** %32
%113 = load i8*, i8** %12
%114 = call i32 @sqlite3_prepare_v2(i32* %112, i8* %113, i32 -1, i32** %33, i32 0)
store i32 %114, i32* %25
%115 = load i32, i32* %25
%116 = load i32, i32* @SQLITE_OK
%117 = icmp ne i32 %115, %116
br i1 %117, label %118, label %120
118: ; preds = %109
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %142
120: ; preds = %109
store i32 0, i32* %19
br label %121
121: ; preds = %138, %120
%122 = load i32, i32* %19
%123 = load i32, i32* %23
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %141
125: ; preds = %121
%126 = load i32, i32* %19
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8*, i8** %93, i64 %127
%129 = load i32*, i32** %33
%130 = load i32, i32* %19
%131 = call i32 @sqlite3_column_name(i32* %129, i32 %130)
%132 = call i32 @asprintf(i8** %128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %131)
store i32 %132, i32* %24
%133 = load i32, i32* %24
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %137
135: ; preds = %125
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %137
137: ; preds = %135, %125
br label %138
138: ; preds = %137
%139 = load i32, i32* %19
%140 = add nsw i32 %139, 1
store i32 %140, i32* %19
br label %121
141: ; preds = %121
br label %142
142: ; preds = %141, %118
%143 = load i32*, i32** %33
%144 = call i32 @sqlite3_finalize(i32* %143)
%145 = load i32*, i32** %32
%146 = call i32 @sqlite3_close(i32* %145)
br label %147
147: ; preds = %142, %106
store i32 0, i32* %19
%148 = load i32, i32* %22
%149 = icmp eq i32 %148, 1
br i1 %149, label %150, label %251
150: ; preds = %147
store i32 7, i32* %36
store i32 7, i32* %37
%151 = load i8*, i8** %12
%152 = getelementptr inbounds i8, i8* %151, i64 7
store i8* %152, i8** %26
br label %153
153: ; preds = %245, %150
%154 = load i8*, i8** %26
%155 = load i8*, i8** %27
%156 = icmp ult i8* %154, %155
br i1 %156, label %157, label %250
157: ; preds = %153
%158 = load i8, i8* %30
store i8 %158, i8* %31
%159 = load i8, i8* %29
store i8 %159, i8* %30
%160 = load i8, i8* %28
store i8 %160, i8* %29
%161 = load i8*, i8** %26
%162 = load i8, i8* %161
store i8 %162, i8* %28
%163 = load i8, i8* %31
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 32
br i1 %165, label %166, label %182
166: ; preds = %157
%167 = load i8, i8* %30
%168 = sext i8 %167 to i32
%169 = icmp eq i32 %168, 65
br i1 %169, label %170, label %182
170: ; preds = %166
%171 = load i8, i8* %29
%172 = sext i8 %171 to i32
%173 = icmp eq i32 %172, 83
br i1 %173, label %174, label %182
174: ; preds = %170
%175 = load i8, i8* %28
%176 = sext i8 %175 to i32
%177 = icmp eq i32 %176, 32
br i1 %177, label %178, label %182
178: ; preds = %174
%179 = load i32, i32* %36
%180 = add nsw i32 %179, 1
store i32 %180, i32* %37
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %182
182: ; preds = %178, %174, %170, %166, %157
%183 = load i8*, i8** %26
%184 = load i8, i8* %183
%185 = sext i8 %184 to i32
%186 = icmp eq i32 %185, 44
br i1 %186, label %192, label %187
187: ; preds = %182
%188 = load i8*, i8** %26
%189 = load i8*, i8** %27
%190 = getelementptr inbounds i8, i8* %189, i64 -1
%191 = icmp eq i8* %188, %190
br i1 %191, label %192, label %245
192: ; preds = %187, %182
%193 = load i32, i32* %36
%194 = load i32, i32* %37
%195 = sub nsw i32 %193, %194
%196 = add nsw i32 %195, 1
%197 = sext i32 %196 to i64
%198 = mul i64 %197, 1
%199 = trunc i64 %198 to i32
%200 = call i64 @malloc(i32 %199)
%201 = inttoptr i64 %200 to i8*
%202 = load i32, i32* %19
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i8*, i8** %93, i64 %203
store i8* %201, i8** %204
%205 = load i32, i32* %19
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i8*, i8** %93, i64 %206
%208 = load i8*, i8** %207
%209 = icmp ne i8* %208, null
br i1 %209, label %210, label %220
210: ; preds = %192
%211 = load i32, i32* %19
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds i8*, i8** %93, i64 %212
%214 = load i8*, i8** %213
%215 = load i32, i32* %36
%216 = load i32, i32* %37
%217 = sub nsw i32 %215, %216
%218 = add nsw i32 %217, 1
%219 = call i32 @memset(i8* %214, i8 signext 0, i32 %218)
br label %220
220: ; preds = %210, %192
%221 = load i32, i32* %19
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds i8*, i8** %93, i64 %222
%224 = load i8*, i8** %223
%225 = icmp eq i8* %224, null
br i1 %225, label %226, label %228
226: ; preds = %220
%227 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %228
228: ; preds = %226, %220
%229 = load i32, i32* %19
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds i8*, i8** %93, i64 %230
%232 = load i8*, i8** %231
%233 = load i8*, i8** %12
%234 = load i32, i32* %37
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds i8, i8* %233, i64 %235
%237 = load i32, i32* %36
%238 = load i32, i32* %37
%239 = sub nsw i32 %237, %238
%240 = call i32 @strncpy(i8* %232, i8* %236, i32 %239)
%241 = load i32, i32* %19
%242 = add nsw i32 %241, 1
store i32 %242, i32* %19
%243 = load i32, i32* %36
%244 = add nsw i32 %243, 2
store i32 %244, i32* %37
br label %245
245: ; preds = %228, %187
%246 = load i32, i32* %36
%247 = add nsw i32 %246, 1
store i32 %247, i32* %36
%248 = load i8*, i8** %26
%249 = getelementptr inbounds i8, i8* %248, i32 1
store i8* %249, i8** %26
br label %153
250: ; preds = %153
br label %251
251: ; preds = %250, %147
store i32 0, i32* %19
br label %252
252: ; preds = %263, %251
%253 = load i32, i32* %19
%254 = load i32, i32* %20
%255 = add nsw i32 %254, 1
%256 = icmp slt i32 %253, %255
br i1 %256, label %257, label %266
257: ; preds = %252
%258 = load i32, i32* %19
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds i8*, i8** %93, i64 %259
%261 = load i8*, i8** %260
%262 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %261)
br label %263
263: ; preds = %257
%264 = load i32, i32* %19
%265 = add nsw i32 %264, 1
store i32 %265, i32* %19
br label %252
266: ; preds = %252
%267 = load i32, i32* %20
%268 = add nsw i32 %267, 1
store i32 %268, i32* %21
%269 = load i8*, i8** %10
%270 = load i8*, i8** %11
%271 = load i8*, i8** %12
%272 = load i32, i32* %21
%273 = load i32, i32* %13
%274 = load i32, i32* %14
%275 = load i8*, i8** %15
%276 = load i8*, i8** %16
%277 = load i32, i32* %17
%278 = load i8*, i8** %18
%279 = load i32, i32* %22
%280 = call i32 @make_html_table(i8* %269, i8* %270, i8* %271, i8** %93, i32 %272, i32 %273, i32 %274, i8* %275, i8* %276, i32 %277, i8* %278, i32 %279)
store i32 0, i32* %19
br label %281
281: ; preds = %299, %266
%282 = load i32, i32* %19
%283 = load i32, i32* %20
%284 = add nsw i32 %283, 1
%285 = icmp slt i32 %282, %284
br i1 %285, label %286, label %302
286: ; preds = %281
%287 = load i32, i32* %19
%288 = sext i32 %287 to i64
%289 = getelementptr inbounds i8*, i8** %93, i64 %288
%290 = load i8*, i8** %289
%291 = icmp ne i8* %290, null
br i1 %291, label %292, label %298
292: ; preds = %286
%293 = load i32, i32* %19
%294 = sext i32 %293 to i64
%295 = getelementptr inbounds i8*, i8** %93, i64 %294
%296 = load i8*, i8** %295
%297 = call i32 @free(i8* %296)
br label %298
298: ; preds = %292, %286
br label %299
299: ; preds = %298
%300 = load i32, i32* %19
%301 = add nsw i32 %300, 1
store i32 %301, i32* %19
br label %281
302: ; preds = %281
%303 = load i8*, i8** %34
br label %304
304: ; preds = %302, %43
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"FROM\00"
@SQLITE_OK = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.8 = [10 x i8] c"Field %s\0A\00"
@str = [14 x i8] c"Malloc error.\00"
@str.9 = [13 x i8] c"Found ' AS '\00"
@str.10 = [38 x i8] c"Memory allocation failed in asprintf.\00"
@str.11 = [34 x i8] c"SQLite couldn't parse SQL string.\00"
@str.12 = [30 x i8] c"No field names in sql string.\00"
@str.13 = [38 x i8] c"Can't find FROM in the SQL statement.\00"
define void @parse_sql_field_names(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i8* %5, i8* %6, i32 %7, i8* %8) {
%10 = ptrtoint i8* %2 to i64
%11 = alloca i32*
%12 = alloca i32*
%13 = bitcast i32** %11 to i8*
store i32* null, i32** %11
%14 = bitcast i32** %12 to i8*
store i32* null, i32** %12
%15 = tail call i8* @strstr(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = ptrtoint i8* %15 to i64
%17 = icmp eq i8* %15, null
br i1 %17, label %23, label %18
18: ; preds = %9
%19 = icmp ugt i8* %15, %2
br i1 %19, label %20, label %62
20: ; preds = %18
%21 = sub i64 %16, %10
%22 = getelementptr i8, i8* %2, i64 %21
br label %25
23: ; preds = %9
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
br label %203
25: ; preds = %20, %40
%26 = phi i32 [ %45, %40 ], [ 0, %20 ]
%27 = phi i8 [ %28, %40 ], [ 98, %20 ]
%28 = phi i8 [ %31, %40 ], [ 97, %20 ]
%29 = phi i8* [ %46, %40 ], [ %2, %20 ]
%30 = phi i32 [ %42, %40 ], [ 1, %20 ]
%31 = load i8, i8* %29
%32 = icmp eq i8 %27, 32
%33 = icmp eq i8 %28, 42
%34 = select i1 %32, i1 %33, i1 false
%35 = icmp eq i8 %31, 32
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %37, label %40
37: ; preds = %25
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
%39 = load i8, i8* %29
br label %40
40: ; preds = %37, %25
%41 = phi i8 [ %39, %37 ], [ %31, %25 ]
%42 = phi i32 [ 0, %37 ], [ %30, %25 ]
%43 = icmp eq i8 %41, 44
%44 = zext i1 %43 to i32
%45 = add nuw nsw i32 %26, %44
%46 = getelementptr inbounds i8, i8* %29, i64 1
%47 = icmp eq i8* %46, %22
br i1 %47, label %48, label %25
48: ; preds = %40
%49 = icmp eq i32 %42, 0
br i1 %49, label %50, label %62
50: ; preds = %48
%51 = tail call i32 @get_column_count(i8* %1, i8* %2)
%52 = zext i32 %51 to i64
%53 = tail call i8* @llvm.stacksave()
%54 = alloca i8*, i64 %52
%55 = icmp slt i32 %51, 1
br i1 %55, label %76, label %56
56: ; preds = %50
%57 = add nsw i32 %51, -1
%58 = bitcast i8** %54 to i8*
%59 = zext i32 %57 to i64
%60 = shl nuw nsw i64 %59, 3
%61 = add nuw nsw i64 %60, 8
br label %76
62: ; preds = %18, %48
%63 = phi i8 [ %27, %48 ], [ 99, %18 ]
%64 = phi i8 [ %28, %48 ], [ 98, %18 ]
%65 = phi i8 [ %31, %48 ], [ 97, %18 ]
%66 = phi i32 [ %42, %48 ], [ 1, %18 ]
%67 = phi i32 [ %45, %48 ], [ 0, %18 ]
%68 = add i32 %67, 1
%69 = zext i32 %68 to i64
%70 = tail call i8* @llvm.stacksave()
%71 = alloca i8*, i64 %69
%72 = bitcast i8** %71 to i8*
%73 = zext i32 %67 to i64
%74 = shl nuw nsw i64 %73, 3
%75 = add nuw nsw i64 %74, 8
br label %106
76: ; preds = %50, %56
%77 = call i32 @sqlite3_open(i8* %1, i32** %11)
%78 = load i32*, i32** %11
%79 = call i32 @sqlite3_prepare_v2(i32* %78, i8* %2, i32 -1, i32** %12, i32 0)
%80 = load i32, i32* @SQLITE_OK
%81 = icmp eq i32 %79, %80
br i1 %81, label %82, label %86
82: ; preds = %76
%83 = icmp sgt i32 %51, 0
br i1 %83, label %84, label %101
84: ; preds = %82
%85 = zext i32 %51 to i64
br label %88
86: ; preds = %76
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
br label %101
88: ; preds = %84, %98
%89 = phi i64 [ 0, %84 ], [ %99, %98 ]
%90 = getelementptr inbounds i8*, i8** %54, i64 %89
%91 = load i32*, i32** %12
%92 = trunc i64 %89 to i32
%93 = call i32 @sqlite3_column_name(i32* %91, i32 %92)
%94 = call i32 @asprintf(i8** %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %93)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %88
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
br label %98
98: ; preds = %88, %96
%99 = add nuw nsw i64 %89, 1
%100 = icmp eq i64 %99, %85
br i1 %100, label %101, label %88
101: ; preds = %98, %82, %86
%102 = load i32*, i32** %12
%103 = call i32 @sqlite3_finalize(i32* %102)
%104 = load i32*, i32** %11
%105 = call i32 @sqlite3_close(i32* %104)
br label %106
106: ; preds = %62, %101
%107 = phi i8 [ %27, %101 ], [ %63, %62 ]
%108 = phi i8 [ %28, %101 ], [ %64, %62 ]
%109 = phi i8 [ %31, %101 ], [ %65, %62 ]
%110 = phi i32 [ 0, %101 ], [ %66, %62 ]
%111 = phi i32 [ %51, %101 ], [ %68, %62 ]
%112 = phi i64 [ %52, %101 ], [ %69, %62 ]
%113 = phi i8* [ %53, %101 ], [ %70, %62 ]
%114 = phi i1 [ %55, %101 ], [ false, %62 ]
%115 = phi i8** [ %54, %101 ], [ %71, %62 ]
%116 = icmp eq i32 %110, 1
br i1 %116, label %117, label %180
117: ; preds = %106
%118 = getelementptr inbounds i8, i8* %2, i64 7
%119 = icmp ult i8* %118, %15
br i1 %119, label %120, label %180
120: ; preds = %117
%121 = getelementptr inbounds i8, i8* %15, i64 -1
%122 = sub i64 %16, %10
%123 = getelementptr i8, i8* %2, i64 %122
br label %124
124: ; preds = %120, %174
%125 = phi i32 [ 7, %120 ], [ %176, %174 ]
%126 = phi i32 [ 7, %120 ], [ %177, %174 ]
%127 = phi i32 [ 0, %120 ], [ %175, %174 ]
%128 = phi i8 [ %107, %120 ], [ %129, %174 ]
%129 = phi i8 [ %108, %120 ], [ %130, %174 ]
%130 = phi i8 [ %109, %120 ], [ %132, %174 ]
%131 = phi i8* [ %118, %120 ], [ %178, %174 ]
%132 = load i8, i8* %131
%133 = icmp eq i8 %128, 32
%134 = icmp eq i8 %129, 65
%135 = select i1 %133, i1 %134, i1 false
%136 = icmp eq i8 %130, 83
%137 = select i1 %135, i1 %136, i1 false
%138 = icmp eq i8 %132, 32
%139 = select i1 %137, i1 %138, i1 false
br i1 %139, label %140, label %144
140: ; preds = %124
%141 = add nuw nsw i32 %126, 1
%142 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%143 = load i8, i8* %131
br label %144
144: ; preds = %140, %124
%145 = phi i8 [ %143, %140 ], [ %132, %124 ]
%146 = phi i32 [ %141, %140 ], [ %125, %124 ]
%147 = icmp eq i8 %145, 44
%148 = icmp eq i8* %131, %121
%149 = select i1 %147, i1 true, i1 %148
br i1 %149, label %150, label %174
150: ; preds = %144
%151 = sub nsw i32 %126, %146
%152 = add nsw i32 %151, 1
%153 = call i64 @malloc(i32 %152)
%154 = inttoptr i64 %153 to i8*
%155 = sext i32 %127 to i64
%156 = getelementptr inbounds i8*, i8** %115, i64 %155
store i8* %154, i8** %156
%157 = icmp eq i64 %153, 0
br i1 %157, label %161, label %158
158: ; preds = %150
%159 = call i32 @memset(i8* %154, i8 signext 0, i32 %152)
%160 = load i8*, i8** %156
br label %161
161: ; preds = %158, %150
%162 = phi i8* [ %160, %158 ], [ %154, %150 ]
%163 = icmp eq i8* %162, null
br i1 %163, label %164, label %167
164: ; preds = %161
%165 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%166 = load i8*, i8** %156
br label %167
167: ; preds = %164, %161
%168 = phi i8* [ %166, %164 ], [ %162, %161 ]
%169 = sext i32 %146 to i64
%170 = getelementptr inbounds i8, i8* %2, i64 %169
%171 = call i32 @strncpy(i8* %168, i8* %170, i32 %151)
%172 = add nsw i32 %127, 1
%173 = add nuw nsw i32 %126, 2
br label %174
174: ; preds = %144, %167
%175 = phi i32 [ %172, %167 ], [ %127, %144 ]
%176 = phi i32 [ %173, %167 ], [ %146, %144 ]
%177 = add nuw nsw i32 %126, 1
%178 = getelementptr inbounds i8, i8* %131, i64 1
%179 = icmp eq i8* %178, %123
br i1 %179, label %180, label %124
180: ; preds = %174, %117, %106
br i1 %114, label %181, label %183
181: ; preds = %180
%182 = call i32 @make_html_table(i8* %0, i8* %1, i8* %2, i8** %115, i32 %111, i32 %3, i32 %4, i8* %5, i8* %6, i32 %7, i8* %8, i32 %110)
br label %202
183: ; preds = %180, %183
%184 = phi i64 [ %188, %183 ], [ 0, %180 ]
%185 = getelementptr inbounds i8*, i8** %115, i64 %184
%186 = load i8*, i8** %185
%187 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %186)
%188 = add nuw nsw i64 %184, 1
%189 = icmp eq i64 %188, %112
br i1 %189, label %190, label %183
190: ; preds = %183
%191 = call i32 @make_html_table(i8* %0, i8* %1, i8* %2, i8** %115, i32 %111, i32 %3, i32 %4, i8* %5, i8* %6, i32 %7, i8* %8, i32 %110)
br i1 %114, label %202, label %192
192: ; preds = %190, %199
%193 = phi i64 [ %200, %199 ], [ 0, %190 ]
%194 = getelementptr inbounds i8*, i8** %115, i64 %193
%195 = load i8*, i8** %194
%196 = icmp eq i8* %195, null
br i1 %196, label %199, label %197
197: ; preds = %192
%198 = call i32 @free(i8* %195)
br label %199
199: ; preds = %192, %197
%200 = add nuw nsw i64 %193, 1
%201 = icmp eq i64 %200, %112
br i1 %201, label %202, label %192
202: ; preds = %199, %181, %190
br label %203
203: ; preds = %202, %23
ret void
}