#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 M_PI;
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ SQLITE_STATIC;
double acos(int);
int cos(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int sin(double);
int /*<<< orphan*/ sqlite3_bind_double(int /*<<< orphan*/ *, int, double);
int /*<<< orphan*/ sqlite3_bind_text(int /*<<< orphan*/ *, int, char *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int sqlite3_column_count(int /*<<< orphan*/ *);
double sqlite3_column_double(int /*<<< orphan*/ *, int);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_exec(int /*<<< orphan*/ *, char *,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  sqlite3 *db;
  sqlite3_stmt *stmt;
  sqlite3_stmt *tempstmt;
  sqlite3_stmt *selstmt;
  double lat1, lng1, lat2, lng2;
  char source[5];
  char destination[5];
  char airline[5];
  int rc;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <database file>\n", argv[0]);
    return (1);
  }
  rc = sqlite3_open(argv[1], &db);
  if (rc) {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return (1);
  }
  char *sql_stmt =
      "select distinct r.Source_airport, a.Latitude, a.Longitude, "
      "r.Destination_airport, a2.Latitude, a2.Longitude, r.Airline "
      "from airports a, airports a2, routes r "
      "where r.Source_airport = a.IATA_FAA and "
      "r.Destination_airport = a2.IATA_FAA;";
  char *temp_stmt = "CREATE TEMPORARY TABLE dist(Source TEXT, Destination "
                    "TEXT, Airline TEXT, Distance REAL);";
  sqlite3_exec(db, temp_stmt, 0, 0, 0);
  rc = sqlite3_prepare_v2(db, sql_stmt, -1, &stmt, 0);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Preparation failed: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return 1;
  }
  while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
    strcpy(source, sqlite3_column_text(stmt, 0));
    lat1 = sqlite3_column_double(stmt, 1);
    lng1 = sqlite3_column_double(stmt, 2);
    strcpy(destination, sqlite3_column_text(stmt, 3));
    lat2 = sqlite3_column_double(stmt, 4);
    lng2 = sqlite3_column_double(stmt, 5);
    strcpy(airline, sqlite3_column_text(stmt, 6));
    double rlat1 = lat1 * (M_PI / 180);
    double rlat2 = lat2 * (M_PI / 180);
    double rlng1 = lng1 * (M_PI / 180);
    double rlng2 = lng2 * (M_PI / 180);
    double dlat = rlat2 - rlat1;
    double dlng = rlng2 - rlng1;
    double thtm = ((rlat1 + rlat2) / 2);
    double dist = ((6371.009) * acos((sin(rlat1) * sin(rlat2)) +
                                     (cos(rlat1) * cos(rlat1) * cos(dlng))));
    char *insert_stmt = "INSERT INTO dist(Source, Destination, Airline, "
                        "Distance) VALUES (?, ?, ?, ?)";
    rc = sqlite3_prepare_v2(db, insert_stmt, -1, &tempstmt, NULL);
    if (rc != SQLITE_OK) {
      fprintf(stderr, "Preparation failed: %s\n", sqlite3_errmsg(db));
      sqlite3_close(db);
      return 1;
    }
    sqlite3_bind_text(tempstmt, 1, source, strlen(source), SQLITE_STATIC);
    sqlite3_bind_text(tempstmt, 2, destination, strlen(destination),
                      SQLITE_STATIC);
    sqlite3_bind_text(tempstmt, 3, airline, strlen(airline), SQLITE_STATIC);
    sqlite3_bind_double(tempstmt, 4, dist);
    rc = sqlite3_step(tempstmt);
    sqlite3_finalize(tempstmt);
  }
  char *final_sql = "select Source, Destination, Airline, Distance "
                    "from dist "
                    "order by Distance desc limit 10;";
  rc = sqlite3_prepare_v2(db, final_sql, -1, &stmt, 0);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Preparation failed: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return 1;
  }
  while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
    int col;
    for (col = 0; col < sqlite3_column_count(stmt) - 1; col++) {
      printf("%s|", sqlite3_column_text(stmt, col));
    }
    printf("%s", sqlite3_column_text(stmt, col));
    printf("\n");
  }
  sqlite3_finalize(stmt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     127b <main+0x4b>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda6(%rip),%rsi
call   10c0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    189a <main+0x66a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <sqlite3_open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     12db <main+0xab>
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd0(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <sqlite3_errmsg@plt>
mov    -0xd0(%rbp),%edi
mov    %rax,%rdx
lea    0xd6a(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
jmp    189a <main+0x66a>
lea    0xd62(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe42(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x78(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <sqlite3_exec@plt>
mov    -0x18(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1150 <sqlite3_prepare_v2@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    0x2cb1(%rip),%rcx
cmp    (%rcx),%eax
je     1379 <main+0x149>
mov    0x2c92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <sqlite3_errmsg@plt>
mov    -0xd4(%rbp),%edi
mov    %rax,%rdx
lea    0xe29(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
jmp    189a <main+0x66a>
jmp    137e <main+0x14e>
mov    -0x20(%rbp),%rdi
call   10b0 <sqlite3_step@plt>
mov    %eax,-0x64(%rbp)
mov    0x2c2f(%rip),%rcx
cmp    (%rcx),%eax
jne    174e <main+0x51e>
lea    -0x55(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1110 <sqlite3_column_text@plt>
mov    -0x100(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1090 <sqlite3_column_double@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1090 <sqlite3_column_double@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0x5a(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1110 <sqlite3_column_text@plt>
mov    -0xf8(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1090 <sqlite3_column_double@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1090 <sqlite3_column_double@plt>
movsd  %xmm0,-0x50(%rbp)
lea    -0x5f(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1110 <sqlite3_column_text@plt>
mov    -0xf0(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movsd  -0x38(%rbp),%xmm0
mov    0x2b82(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    0x2b5f(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
mov    0x2b39(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
mov    0x2b13(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
subsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
subsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
addsd  -0x88(%rbp),%xmm0
ff
movsd  0xad7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   10d0 <sin@plt>
mov    %eax,-0xe4(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
call   10d0 <sin@plt>
mov    %eax,%ecx
mov    -0xe4(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0xdc(%rbp)
movsd  -0x80(%rbp),%xmm0
call   1120 <cos@plt>
mov    %eax,-0xe0(%rbp)
movsd  -0x80(%rbp),%xmm0
call   1120 <cos@plt>
mov    %eax,%ecx
mov    -0xe0(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0xd8(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
call   1120 <cos@plt>
mov    -0xdc(%rbp),%edi
mov    %eax,%ecx
mov    -0xd8(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1080 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xa3a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
lea    0xbc7(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x28(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1150 <sqlite3_prepare_v2@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    0x29d5(%rip),%rcx
cmp    (%rcx),%eax
je     1655 <main+0x425>
mov    0x29b6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <sqlite3_errmsg@plt>
mov    -0x104(%rbp),%edi
mov    %rax,%rdx
lea    0xb4d(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
jmp    189a <main+0x66a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x55(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0x55(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x138(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    %eax,%ecx
mov    0x293d(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1130 <sqlite3_bind_text@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x5a(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x5a(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rdx
mov    %eax,%ecx
mov    0x28fa(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
call   1130 <sqlite3_bind_text@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x5f(%rbp),%rax
mov    %rax,-0x110(%rbp)
lea    -0x5f(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x118(%rbp),%rdi
mov    -0x110(%rbp),%rdx
mov    %eax,%ecx
mov    0x28b7(%rip),%rax
mov    (%rax),%r8d
mov    $0x3,%esi
call   1130 <sqlite3_bind_text@plt>
mov    -0x28(%rbp),%rdi
movsd  -0xb8(%rbp),%xmm0
ff
mov    $0x4,%esi
call   1100 <sqlite3_bind_double@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <sqlite3_step@plt>
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%rdi
call   1140 <sqlite3_finalize@plt>
jmp    137e <main+0x14e>
lea    0xa98(%rip),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1150 <sqlite3_prepare_v2@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    0x2859(%rip),%rcx
cmp    (%rcx),%eax
je     17d1 <main+0x5a1>
mov    0x283a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <sqlite3_errmsg@plt>
mov    -0x13c(%rbp),%edi
mov    %rax,%rdx
lea    0x9d1(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <sqlite3_close@plt>
movl   $0x1,-0x4(%rbp)
jmp    189a <main+0x66a>
jmp    17d6 <main+0x5a6>
mov    -0x20(%rbp),%rdi
call   10b0 <sqlite3_step@plt>
mov    %eax,-0x64(%rbp)
mov    0x27d7(%rip),%rcx
cmp    (%rcx),%eax
jne    188a <main+0x65a>
movl   $0x0,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
mov    %eax,-0x140(%rbp)
mov    -0x20(%rbp),%rdi
call   10f0 <sqlite3_column_count@plt>
mov    %eax,%ecx
mov    -0x140(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1857 <main+0x627>
mov    -0x20(%rbp),%rdi
mov    -0xcc(%rbp),%esi
call   1110 <sqlite3_column_text@plt>
mov    %rax,%rsi
lea    0xa0a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    17fb <main+0x5cb>
mov    -0x20(%rbp),%rdi
mov    -0xcc(%rbp),%esi
call   1110 <sqlite3_column_text@plt>
mov    %rax,%rsi
lea    0x9da(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0x7ab(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    17d6 <main+0x5a6>
mov    -0x20(%rbp),%rdi
call   1140 <sqlite3_finalize@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x2,%edi
jne    1284 <main+0x44>
mov    0x8(%rsi),%rdi
lea    0x10(%rsp),%rsi
call   1060 <sqlite3_open@plt>
test   %eax,%eax
je     12a1 <main+0x61>
mov    0x2d64(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   10b0 <sqlite3_errmsg@plt>
lea    0xda4(%rip),%rsi
jmp    165c <main+0x41c>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd71(%rip),%rsi
call   10d0 <fprintf@plt>
jmp    1670 <main+0x430>
mov    0x10(%rsp),%rdi
lea    0xe7a(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <sqlite3_exec@plt>
mov    0x10(%rsp),%rdi
lea    0xd77(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1160 <sqlite3_prepare_v2@plt>
mov    0x2d02(%rip),%rbx
cmp    (%rbx),%eax
jne    1642 <main+0x402>
mov    0x8(%rsp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x2cc9(%rip),%rcx
cmp    (%rcx),%eax
jne    1556 <main+0x316>
lea    0x53(%rsp),%r12
lea    0x4e(%rsp),%r14
mov    0x2cb8(%rip),%r13
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1120 <sqlite3_column_text@plt>
mov    %r12,%r15
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   10a0 <sqlite3_column_double@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x8(%rsp),%rdi
mov    $0x2,%esi
call   10a0 <sqlite3_column_double@plt>
movsd  %xmm0,0x40(%rsp)
mov    0x8(%rsp),%rdi
mov    $0x3,%esi
call   1120 <sqlite3_column_text@plt>
lea    0x3b(%rsp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%rdi
mov    $0x4,%esi
call   10a0 <sqlite3_column_double@plt>
movsd  %xmm0,0x30(%rsp)
mov    0x8(%rsp),%rdi
mov    $0x5,%esi
call   10a0 <sqlite3_column_double@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x8(%rsp),%rdi
mov    $0x6,%esi
call   1120 <sqlite3_column_text@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    0x2c2d(%rip),%rax
movslq (%rax),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
cvtsi2sd %ecx,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x30(%rsp),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x30(%rsp)
movsd  0x40(%rsp),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x28(%rsp),%xmm3
mulsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm3,0x28(%rsp)
call   10e0 <sin@plt>
mov    %eax,%ebp
movsd  0x30(%rsp),%xmm0
call   10e0 <sin@plt>
imul   %eax,%ebp
movsd  0x18(%rsp),%xmm0
call   1130 <cos@plt>
mov    %eax,%r12d
movsd  0x18(%rsp),%xmm0
call   1130 <cos@plt>
imul   %eax,%r12d
movsd  0x28(%rsp),%xmm0
call   1130 <cos@plt>
imul   %eax,%r12d
add    %ebp,%r12d
mov    %r12d,%edi
call   1090 <acos@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x10(%rsp),%rdi
lea    0xd23(%rip),%rsi
mov    $0xffffffff,%edx
lea    0x20(%rsp),%rcx
xor    %r8d,%r8d
call   1160 <sqlite3_prepare_v2@plt>
cmp    (%rbx),%eax
jne    1642 <main+0x402>
movsd  0x18(%rsp),%xmm0
mulsd  0xb63(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x20(%rsp),%rbp
mov    %r15,%r12
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    0x0(%r13),%r8d
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1140 <sqlite3_bind_text@plt>
mov    0x20(%rsp),%rbp
lea    0x3b(%rsp),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    0x0(%r13),%r8d
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1140 <sqlite3_bind_text@plt>
mov    0x20(%rsp),%rbp
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    0x0(%r13),%r8d
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1140 <sqlite3_bind_text@plt>
mov    0x20(%rsp),%rdi
mov    $0x4,%esi
movsd  0x18(%rsp),%xmm0
call   1110 <sqlite3_bind_double@plt>
mov    0x20(%rsp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x20(%rsp),%rdi
call   1150 <sqlite3_finalize@plt>
mov    0x8(%rsp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x2a72(%rip),%rcx
cmp    (%rcx),%eax
je     1310 <main+0xd0>
mov    0x10(%rsp),%rdi
lea    0xc83(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1160 <sqlite3_prepare_v2@plt>
cmp    (%rbx),%eax
jne    1642 <main+0x402>
mov    0x8(%rsp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x2a33(%rip),%rcx
cmp    (%rcx),%eax
jne    1684 <main+0x444>
lea    0xca2(%rip),%rbx
lea    0xc9f(%rip),%r14
jmp    15ec <main+0x3ac>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1120 <sqlite3_column_text@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%rdi
call   10c0 <sqlite3_step@plt>
mov    0x29dc(%rip),%rcx
cmp    (%rcx),%eax
jne    1684 <main+0x444>
mov    0x8(%rsp),%rdi
call   1100 <sqlite3_column_count@plt>
mov    $0x0,%ebp
cmp    $0x2,%eax
jl     15b0 <main+0x370>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
call   1120 <sqlite3_column_text@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%rdi
call   1100 <sqlite3_column_count@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jl     1610 <main+0x3d0>
jmp    15b0 <main+0x370>
mov    0x2987(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   10b0 <sqlite3_errmsg@plt>
lea    0xb24(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10d0 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   10f0 <sqlite3_close@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rdi
call   1150 <sqlite3_finalize@plt>
xor    %eax,%eax
jmp    1675 <main+0x435>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s <database file>\0A\00"
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.2 = [235 x i8] c"select distinct r.Source_airport, a.Latitude, a.Longitude, r.Destination_airport, a2.Latitude, a2.Longitude, r.Airline from airports a, airports a2, routes r where r.Source_airport = a.IATA_FAA and r.Destination_airport = a2.IATA_FAA;\00"
@.str.3 = [89 x i8] c"CREATE TEMPORARY TABLE dist(Source TEXT, Destination TEXT, Airline TEXT, Distance REAL);\00"
@SQLITE_OK = global i32 0
@.str.4 = [24 x i8] c"Preparation failed: %s\0A\00"
@SQLITE_ROW = global i32 0
@M_PI = global i32 0
@.str.5 = [77 x i8] c"INSERT INTO dist(Source, Destination, Airline, Distance) VALUES (?, ?, ?, ?)\00"
@SQLITE_STATIC = global i32 0
@.str.6 = [89 x i8] c"select Source, Destination, Airline, Distance from dist order by Distance desc limit 10;\00"
@.str.7 = [4 x i8] c"%s|\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca [5 x i8]
%15 = alloca [5 x i8]
%16 = alloca [5 x i8]
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca i8*
%29 = alloca i8*
%30 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 2
br i1 %32, label %33, label %39
33: ; preds = %2
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %37)
store i32 1, i32* %3
br label %226
39: ; preds = %2
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @sqlite3_open(i8* %42, i32** %6)
store i32 %43, i32* %17
%44 = load i32, i32* %17
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %53
46: ; preds = %39
%47 = load i32, i32* @stderr
%48 = load i32*, i32** %6
%49 = call i8* @sqlite3_errmsg(i32* %48)
%50 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = load i32*, i32** %6
%52 = call i32 @sqlite3_close(i32* %51)
store i32 1, i32* %3
br label %226
53: ; preds = %39
store i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.2, i64 0, i64 0), i8** %18
store i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.3, i64 0, i64 0), i8** %19
%54 = load i32*, i32** %6
%55 = load i8*, i8** %19
%56 = call i32 @sqlite3_exec(i32* %54, i8* %55, i32 0, i32 0, i32 0)
%57 = load i32*, i32** %6
%58 = load i8*, i8** %18
%59 = call i32 @sqlite3_prepare_v2(i32* %57, i8* %58, i32 -1, i32** %7, i32* null)
store i32 %59, i32* %17
%60 = load i32, i32* %17
%61 = load i32, i32* @SQLITE_OK
%62 = icmp ne i32 %60, %61
br i1 %62, label %63, label %70
63: ; preds = %53
%64 = load i32, i32* @stderr
%65 = load i32*, i32** %6
%66 = call i8* @sqlite3_errmsg(i32* %65)
%67 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %66)
%68 = load i32*, i32** %6
%69 = call i32 @sqlite3_close(i32* %68)
store i32 1, i32* %3
br label %226
70: ; preds = %53
br label %71
71: ; preds = %156, %70
%72 = load i32*, i32** %7
%73 = call i32 @sqlite3_step(i32* %72)
store i32 %73, i32* %17
%74 = load i32, i32* @SQLITE_ROW
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %182
76: ; preds = %71
%77 = getelementptr inbounds [5 x i8], [5 x i8]* %14, i64 0, i64 0
%78 = load i32*, i32** %7
%79 = call i8* @sqlite3_column_text(i32* %78, i32 0)
%80 = call i32 @strcpy(i8* %77, i8* %79)
%81 = load i32*, i32** %7
%82 = call double @sqlite3_column_double(i32* %81, i32 1)
store double %82, double* %10
%83 = load i32*, i32** %7
%84 = call double @sqlite3_column_double(i32* %83, i32 2)
store double %84, double* %11
%85 = getelementptr inbounds [5 x i8], [5 x i8]* %15, i64 0, i64 0
%86 = load i32*, i32** %7
%87 = call i8* @sqlite3_column_text(i32* %86, i32 3)
%88 = call i32 @strcpy(i8* %85, i8* %87)
%89 = load i32*, i32** %7
%90 = call double @sqlite3_column_double(i32* %89, i32 4)
store double %90, double* %12
%91 = load i32*, i32** %7
%92 = call double @sqlite3_column_double(i32* %91, i32 5)
store double %92, double* %13
%93 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%94 = load i32*, i32** %7
%95 = call i8* @sqlite3_column_text(i32* %94, i32 6)
%96 = call i32 @strcpy(i8* %93, i8* %95)
%97 = load double, double* %10
%98 = load i32, i32* @M_PI
%99 = sdiv i32 %98, 180
%100 = sitofp i32 %99 to double
%101 = fmul double %97, %100
store double %101, double* %20
%102 = load double, double* %12
%103 = load i32, i32* @M_PI
%104 = sdiv i32 %103, 180
%105 = sitofp i32 %104 to double
%106 = fmul double %102, %105
store double %106, double* %21
%107 = load double, double* %11
%108 = load i32, i32* @M_PI
%109 = sdiv i32 %108, 180
%110 = sitofp i32 %109 to double
%111 = fmul double %107, %110
store double %111, double* %22
%112 = load double, double* %13
%113 = load i32, i32* @M_PI
%114 = sdiv i32 %113, 180
%115 = sitofp i32 %114 to double
%116 = fmul double %112, %115
store double %116, double* %23
%117 = load double, double* %21
%118 = load double, double* %20
%119 = fsub double %117, %118
store double %119, double* %24
%120 = load double, double* %23
%121 = load double, double* %22
%122 = fsub double %120, %121
store double %122, double* %25
%123 = load double, double* %20
%124 = load double, double* %21
%125 = fadd double %123, %124
%126 = fdiv double %125, 2.000000e+00
store double %126, double* %26
%127 = load double, double* %20
%128 = call i32 @sin(double %127)
%129 = load double, double* %21
%130 = call i32 @sin(double %129)
%131 = mul nsw i32 %128, %130
%132 = load double, double* %20
%133 = call i32 @cos(double %132)
%134 = load double, double* %20
%135 = call i32 @cos(double %134)
%136 = mul nsw i32 %133, %135
%137 = load double, double* %25
%138 = call i32 @cos(double %137)
%139 = mul nsw i32 %136, %138
%140 = add nsw i32 %131, %139
%141 = call double @acos(i32 %140)
%142 = fmul double 0x40B8E3024DD2F1AA, %141
store double %142, double* %27
store i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), i8** %28
%143 = load i32*, i32** %6
%144 = load i8*, i8** %28
%145 = call i32 @sqlite3_prepare_v2(i32* %143, i8* %144, i32 -1, i32** %8, i32* null)
store i32 %145, i32* %17
%146 = load i32, i32* %17
%147 = load i32, i32* @SQLITE_OK
%148 = icmp ne i32 %146, %147
br i1 %148, label %149, label %156
149: ; preds = %76
%150 = load i32, i32* @stderr
%151 = load i32*, i32** %6
%152 = call i8* @sqlite3_errmsg(i32* %151)
%153 = call i32 @fprintf(i32 %150, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %152)
%154 = load i32*, i32** %6
%155 = call i32 @sqlite3_close(i32* %154)
store i32 1, i32* %3
br label %226
156: ; preds = %76
%157 = load i32*, i32** %8
%158 = getelementptr inbounds [5 x i8], [5 x i8]* %14, i64 0, i64 0
%159 = getelementptr inbounds [5 x i8], [5 x i8]* %14, i64 0, i64 0
%160 = call i32 @strlen(i8* %159)
%161 = load i32, i32* @SQLITE_STATIC
%162 = call i32 @sqlite3_bind_text(i32* %157, i32 1, i8* %158, i32 %160, i32 %161)
%163 = load i32*, i32** %8
%164 = getelementptr inbounds [5 x i8], [5 x i8]* %15, i64 0, i64 0
%165 = getelementptr inbounds [5 x i8], [5 x i8]* %15, i64 0, i64 0
%166 = call i32 @strlen(i8* %165)
%167 = load i32, i32* @SQLITE_STATIC
%168 = call i32 @sqlite3_bind_text(i32* %163, i32 2, i8* %164, i32 %166, i32 %167)
%169 = load i32*, i32** %8
%170 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%171 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%172 = call i32 @strlen(i8* %171)
%173 = load i32, i32* @SQLITE_STATIC
%174 = call i32 @sqlite3_bind_text(i32* %169, i32 3, i8* %170, i32 %172, i32 %173)
%175 = load i32*, i32** %8
%176 = load double, double* %27
%177 = call i32 @sqlite3_bind_double(i32* %175, i32 4, double %176)
%178 = load i32*, i32** %8
%179 = call i32 @sqlite3_step(i32* %178)
store i32 %179, i32* %17
%180 = load i32*, i32** %8
%181 = call i32 @sqlite3_finalize(i32* %180)
br label %71
182: ; preds = %71
store i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.6, i64 0, i64 0), i8** %29
%183 = load i32*, i32** %6
%184 = load i8*, i8** %29
%185 = call i32 @sqlite3_prepare_v2(i32* %183, i8* %184, i32 -1, i32** %7, i32* null)
store i32 %185, i32* %17
%186 = load i32, i32* %17
%187 = load i32, i32* @SQLITE_OK
%188 = icmp ne i32 %186, %187
br i1 %188, label %189, label %196
189: ; preds = %182
%190 = load i32, i32* @stderr
%191 = load i32*, i32** %6
%192 = call i8* @sqlite3_errmsg(i32* %191)
%193 = call i32 @fprintf(i32 %190, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %192)
%194 = load i32*, i32** %6
%195 = call i32 @sqlite3_close(i32* %194)
store i32 1, i32* %3
br label %226
196: ; preds = %182
br label %197
197: ; preds = %217, %196
%198 = load i32*, i32** %7
%199 = call i32 @sqlite3_step(i32* %198)
store i32 %199, i32* %17
%200 = load i32, i32* @SQLITE_ROW
%201 = icmp eq i32 %199, %200
br i1 %201, label %202, label %223
202: ; preds = %197
store i32 0, i32* %30
br label %203
203: ; preds = %214, %202
%204 = load i32, i32* %30
%205 = load i32*, i32** %7
%206 = call i32 @sqlite3_column_count(i32* %205)
%207 = sub nsw i32 %206, 1
%208 = icmp slt i32 %204, %207
br i1 %208, label %209, label %217
209: ; preds = %203
%210 = load i32*, i32** %7
%211 = load i32, i32* %30
%212 = call i8* @sqlite3_column_text(i32* %210, i32 %211)
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %212)
br label %214
214: ; preds = %209
%215 = load i32, i32* %30
%216 = add nsw i32 %215, 1
store i32 %216, i32* %30
br label %203
217: ; preds = %203
%218 = load i32*, i32** %7
%219 = load i32, i32* %30
%220 = call i8* @sqlite3_column_text(i32* %218, i32 %219)
%221 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %220)
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %197
223: ; preds = %197
%224 = load i32*, i32** %7
%225 = call i32 @sqlite3_finalize(i32* %224)
store i32 0, i32* %3
br label %226
226: ; preds = %223, %189, %149, %63, %46, %33
%227 = load i32, i32* %3
ret i32 %227
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Usage: %s <database file>\0A\00"
@.str.1 = [25 x i8] c"Can't open database: %s\0A\00"
@.str.2 = [235 x i8] c"select distinct r.Source_airport, a.Latitude, a.Longitude, r.Destination_airport, a2.Latitude, a2.Longitude, r.Airline from airports a, airports a2, routes r where r.Source_airport = a.IATA_FAA and r.Destination_airport = a2.IATA_FAA;\00"
@.str.3 = [89 x i8] c"CREATE TEMPORARY TABLE dist(Source TEXT, Destination TEXT, Airline TEXT, Distance REAL);\00"
@SQLITE_OK = global i32 0
@.str.4 = [24 x i8] c"Preparation failed: %s\0A\00"
@SQLITE_ROW = global i32 0
@M_PI = global i32 0
@.str.5 = [77 x i8] c"INSERT INTO dist(Source, Destination, Airline, Distance) VALUES (?, ?, ?, ?)\00"
@SQLITE_STATIC = global i32 0
@.str.6 = [89 x i8] c"select Source, Destination, Airline, Distance from dist order by Distance desc limit 10;\00"
@.str.7 = [4 x i8] c"%s|\00"
@.str.8 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [5 x i8]
%7 = alloca [5 x i8]
%8 = alloca [5 x i8]
%9 = bitcast i32** %3 to i8*
%10 = bitcast i32** %4 to i8*
%11 = bitcast i32** %5 to i8*
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%15 = icmp eq i32 %0, 2
br i1 %15, label %20, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %166
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @sqlite3_open(i8* %22, i32** %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i32*, i32** %3
%28 = call i8* @sqlite3_errmsg(i32* %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32*, i32** %3
%31 = call i32 @sqlite3_close(i32* %30)
br label %166
32: ; preds = %20
%33 = load i32*, i32** %3
%34 = call i32 @sqlite3_exec(i32* %33, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0)
%35 = load i32*, i32** %3
%36 = call i32 @sqlite3_prepare_v2(i32* %35, i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.2, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%37 = load i32, i32* @SQLITE_OK
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %44
39: ; preds = %32
%40 = load i32*, i32** %4
%41 = call i32 @sqlite3_step(i32* %40)
%42 = load i32, i32* @SQLITE_ROW
%43 = icmp eq i32 %41, %42
br i1 %43, label %51, label %122
44: ; preds = %32
%45 = load i32, i32* @stderr
%46 = load i32*, i32** %3
%47 = call i8* @sqlite3_errmsg(i32* %46)
%48 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = load i32*, i32** %3
%50 = call i32 @sqlite3_close(i32* %49)
br label %166
51: ; preds = %39, %98
%52 = load i32*, i32** %4
%53 = call i8* @sqlite3_column_text(i32* %52, i32 0)
%54 = call i32 @strcpy(i8* %12, i8* %53)
%55 = load i32*, i32** %4
%56 = call double @sqlite3_column_double(i32* %55, i32 1)
%57 = load i32*, i32** %4
%58 = call double @sqlite3_column_double(i32* %57, i32 2)
%59 = load i32*, i32** %4
%60 = call i8* @sqlite3_column_text(i32* %59, i32 3)
%61 = call i32 @strcpy(i8* %13, i8* %60)
%62 = load i32*, i32** %4
%63 = call double @sqlite3_column_double(i32* %62, i32 4)
%64 = load i32*, i32** %4
%65 = call double @sqlite3_column_double(i32* %64, i32 5)
%66 = load i32*, i32** %4
%67 = call i8* @sqlite3_column_text(i32* %66, i32 6)
%68 = call i32 @strcpy(i8* %14, i8* %67)
%69 = load i32, i32* @M_PI
%70 = sdiv i32 %69, 180
%71 = sitofp i32 %70 to double
%72 = fmul double %56, %71
%73 = fmul double %63, %71
%74 = fmul double %58, %71
%75 = fmul double %65, %71
%76 = fsub double %75, %74
%77 = call i32 @sin(double %72)
%78 = call i32 @sin(double %73)
%79 = mul nsw i32 %78, %77
%80 = call i32 @cos(double %72)
%81 = call i32 @cos(double %72)
%82 = mul nsw i32 %81, %80
%83 = call i32 @cos(double %76)
%84 = mul nsw i32 %82, %83
%85 = add nsw i32 %84, %79
%86 = call double @acos(i32 %85)
%87 = load i32*, i32** %3
%88 = call i32 @sqlite3_prepare_v2(i32* %87, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), i32 -1, i32** %5, i32* null)
%89 = load i32, i32* @SQLITE_OK
%90 = icmp eq i32 %88, %89
br i1 %90, label %98, label %91
91: ; preds = %51
%92 = load i32, i32* @stderr
%93 = load i32*, i32** %3
%94 = call i8* @sqlite3_errmsg(i32* %93)
%95 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %94)
%96 = load i32*, i32** %3
%97 = call i32 @sqlite3_close(i32* %96)
br label %166
98: ; preds = %51
%99 = fmul double %86, 0x40B8E3024DD2F1AA
%100 = load i32*, i32** %5
%101 = call i32 @strlen(i8* %12)
%102 = load i32, i32* @SQLITE_STATIC
%103 = call i32 @sqlite3_bind_text(i32* %100, i32 1, i8* %12, i32 %101, i32 %102)
%104 = load i32*, i32** %5
%105 = call i32 @strlen(i8* %13)
%106 = load i32, i32* @SQLITE_STATIC
%107 = call i32 @sqlite3_bind_text(i32* %104, i32 2, i8* %13, i32 %105, i32 %106)
%108 = load i32*, i32** %5
%109 = call i32 @strlen(i8* %14)
%110 = load i32, i32* @SQLITE_STATIC
%111 = call i32 @sqlite3_bind_text(i32* %108, i32 3, i8* %14, i32 %109, i32 %110)
%112 = load i32*, i32** %5
%113 = call i32 @sqlite3_bind_double(i32* %112, i32 4, double %99)
%114 = load i32*, i32** %5
%115 = call i32 @sqlite3_step(i32* %114)
%116 = load i32*, i32** %5
%117 = call i32 @sqlite3_finalize(i32* %116)
%118 = load i32*, i32** %4
%119 = call i32 @sqlite3_step(i32* %118)
%120 = load i32, i32* @SQLITE_ROW
%121 = icmp eq i32 %119, %120
br i1 %121, label %51, label %122
122: ; preds = %98, %39
%123 = load i32*, i32** %3
%124 = call i32 @sqlite3_prepare_v2(i32* %123, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.6, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%125 = load i32, i32* @SQLITE_OK
%126 = icmp eq i32 %124, %125
br i1 %126, label %127, label %132
127: ; preds = %122
%128 = load i32*, i32** %4
%129 = call i32 @sqlite3_step(i32* %128)
%130 = load i32, i32* @SQLITE_ROW
%131 = icmp eq i32 %129, %130
br i1 %131, label %139, label %163
132: ; preds = %122
%133 = load i32, i32* @stderr
%134 = load i32*, i32** %3
%135 = call i8* @sqlite3_errmsg(i32* %134)
%136 = call i32 @fprintf(i32 %133, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %135)
%137 = load i32*, i32** %3
%138 = call i32 @sqlite3_close(i32* %137)
br label %166
139: ; preds = %127, %153
%140 = load i32*, i32** %4
%141 = call i32 @sqlite3_column_count(i32* %140)
%142 = icmp sgt i32 %141, 1
br i1 %142, label %143, label %153
143: ; preds = %139, %143
%144 = phi i32 [ %148, %143 ], [ 0, %139 ]
%145 = load i32*, i32** %4
%146 = call i8* @sqlite3_column_text(i32* %145, i32 %144)
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %146)
%148 = add nuw nsw i32 %144, 1
%149 = load i32*, i32** %4
%150 = call i32 @sqlite3_column_count(i32* %149)
%151 = add nsw i32 %150, -1
%152 = icmp slt i32 %148, %151
br i1 %152, label %143, label %153
153: ; preds = %143, %139
%154 = phi i32 [ 0, %139 ], [ %148, %143 ]
%155 = load i32*, i32** %4
%156 = call i8* @sqlite3_column_text(i32* %155, i32 %154)
%157 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %156)
%158 = call i32 @putchar(i32 10)
%159 = load i32*, i32** %4
%160 = call i32 @sqlite3_step(i32* %159)
%161 = load i32, i32* @SQLITE_ROW
%162 = icmp eq i32 %160, %161
br i1 %162, label %139, label %163
163: ; preds = %153, %127
%164 = load i32*, i32** %4
%165 = call i32 @sqlite3_finalize(i32* %164)
br label %166
166: ; preds = %91, %44, %163, %132, %25, %16
%167 = phi i32 [ 1, %16 ], [ 1, %25 ], [ 1, %44 ], [ 1, %132 ], [ 0, %163 ], [ 1, %91 ]
ret i32 %167
}