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

/* Variables and functions */
scalar_t__ SQLITE_DONE;
int /*<<< orphan*/ SQLITE_TRANSIENT;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sql_exec(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ sql_prepare(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/ **, int);
scalar_t__ sql_step(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sqlite3_bind_text(int /*<<< orphan*/ *, int, char *, int,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_free(char *);
char *sqlite3_mprintf(char *, char const *, char const *);
int /*<<< orphan*/ sqlite3_reset(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char const *, char *);
int strlen(char *);
scalar_t__ verify_essid(char *);
scalar_t__ verify_passwd(char *);
int import_ascii(sqlite3 *db, const char *mode, const char *filename) {
  FILE *f = NULL;
  sqlite3_stmt *stmt;
  char buffer[63 + 1];
  int imported = 0;
  int ignored = 0;
  int imode = 0;
  if (strcasecmp(mode, "essid") == 0) {
    imode = 0;
  } else if (strcasecmp(mode, "passwd") == 0) {
    imode = 1;
  } else {
    printf("Specify either 'essid' or 'passwd' as import mode.\n");
    return 0;
  }
  if (strcmp(filename, "-") == 0) {
    f = stdin;
  } else {
    f = fopen(filename, "r");
  }
  if (f == NULL) {
    printf("Could not open file/stream for reading.\n");
    return 0;
  }
  char *sql =
      sqlite3_mprintf("INSERT OR IGNORE INTO %q (%q) VALUES (@v);", mode, mode);
  sql_prepare(db, sql, &stmt, -1);
  sqlite3_free(sql);
  sql_exec(db, "BEGIN;");
  printf("Reading file...\n");
  while (fgets(buffer, sizeof(buffer), f) != 0) {
    int i = strlen(buffer);
    if (buffer[i - 1] == '\n')
      buffer[--i] = '\0';
    if (buffer[i - 1] == '\r')
      buffer[--i] = '\0';
    imported++;
    if ((imode == 0 && verify_essid(buffer) == 0) ||
        (imode == 1 && verify_passwd(buffer) == 0)) {
      sqlite3_bind_text(stmt, 1, buffer, strlen(buffer), SQLITE_TRANSIENT);
      if (sql_step(stmt, -1) == SQLITE_DONE) {
        sqlite3_reset(stmt);
      } else {
        printf("Error while inserting record into database.\n");
        sql_exec(db, "ROLLBACK;");
        sqlite3_finalize(stmt);
        fclose(f);
        return 1;
      }
    } else {
      ignored++;
    }
    if (imported % 1000 == 0) {
      fprintf(stdout, "%i lines read, %i invalid lines ignored.\r", imported,
              ignored);
      fflush(stdout);
    }
  }
  sqlite3_finalize(stmt);
  if (!feof(f)) {
    printf("Error while reading file.\n");
    sql_exec(db, "ROLLBACK;");
    fclose(f);
    return 1;
  }
  fclose(f);
  printf("Writing...\n");
  sql_exec(db, "COMMIT;");
  printf("Done.\n");
  return 1;
}


x86 assembly (clang, -O0):
<import_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    129a <import_ascii+0x5a>
movl   $0x0,-0x7c(%rbp)
jmp    12dd <import_ascii+0x9d>
mov    -0x18(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12c0 <import_ascii+0x80>
movl   $0x1,-0x7c(%rbp)
jmp    12d8 <import_ascii+0x98>
lea    0xd46(%rip),%rdi
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15e6 <import_ascii+0x3a6>
jmp    12dd <import_ascii+0x9d>
mov    -0x20(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    130a <import_ascii+0xca>
mov    0x2cea(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    131e <import_ascii+0xde>
mov    -0x20(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1341 <import_ascii+0x101>
lea    0xd15(%rip),%rdi
call   1090 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15e6 <import_ascii+0x3a6>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xd1e(%rip),%rdi
call   1160 <sqlite3_mprintf@plt>
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x88(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0xffffffff,%ecx
call   10e0 <sql_prepare@plt>
mov    -0x88(%rbp),%rdi
call   1150 <sqlite3_free@plt>
mov    -0x10(%rbp),%rdi
lea    0xd0d(%rip),%rsi
call   1070 <sql_exec@plt>
lea    0xd08(%rip),%rdi
call   1090 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x40,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1562 <import_ascii+0x322>
lea    -0x70(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    13f7 <import_ascii+0x1b7>
mov    -0x8c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8c(%rbp)
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xd,%eax
jne    1426 <import_ascii+0x1e6>
mov    -0x8c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8c(%rbp)
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jne    144c <import_ascii+0x20c>
lea    -0x70(%rbp),%rdi
call   1030 <verify_essid@plt>
cmp    $0x0,%rax
je     1469 <import_ascii+0x229>
cmpl   $0x1,-0x7c(%rbp)
jne    1517 <import_ascii+0x2d7>
lea    -0x70(%rbp),%rdi
call   1130 <verify_passwd@plt>
cmp    $0x0,%rax
jne    1517 <import_ascii+0x2d7>
mov    -0x30(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x70(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    %eax,%ecx
mov    0x2b39(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1100 <sqlite3_bind_text@plt>
mov    -0x30(%rbp),%rdi
mov    $0xffffffff,%esi
call   1110 <sql_step@plt>
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%rax
jne    14d8 <import_ascii+0x298>
mov    -0x30(%rbp),%rdi
call   1050 <sqlite3_reset@plt>
jmp    1512 <import_ascii+0x2d2>
lea    0xbd2(%rip),%rdi
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xbef(%rip),%rsi
call   1070 <sql_exec@plt>
mov    -0x30(%rbp),%rdi
call   1140 <sqlite3_finalize@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    15e6 <import_ascii+0x3a6>
jmp    1520 <import_ascii+0x2e0>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    155d <import_ascii+0x31d>
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
mov    -0x74(%rbp),%edx
mov    -0x78(%rbp),%ecx
lea    0xb9e(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2a72(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
jmp    139d <import_ascii+0x15d>
mov    -0x30(%rbp),%rdi
call   1140 <sqlite3_finalize@plt>
mov    -0x28(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%eax
jne    15ae <import_ascii+0x36e>
lea    0xb8e(%rip),%rdi
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xb4a(%rip),%rsi
call   1070 <sql_exec@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    15e6 <import_ascii+0x3a6>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xb6f(%rip),%rdi
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xb6b(%rip),%rsi
call   1070 <sql_exec@plt>
lea    0xb67(%rip),%rdi
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<import_ascii>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     1290 <import_ascii+0x50>
lea    0xd8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     1290 <import_ascii+0x50>
lea    0xdf4(%rip),%rdi
jmp    14e5 <import_ascii+0x2a5>
lea    0xd76(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     14cb <import_ascii+0x28b>
lea    0xd60(%rip),%rsi
mov    %rbp,%rdi
call   1120 <fopen@plt>
mov    %rax,%rbp
test   %rbp,%rbp
je     14de <import_ascii+0x29e>
lea    0xd47(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1160 <sqlite3_mprintf@plt>
mov    %rax,%rbx
mov    %rsp,%rdx
mov    $0xffffffff,%r15d
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0xffffffff,%ecx
call   10e0 <sql_prepare@plt>
mov    %rbx,%rdi
call   1150 <sqlite3_free@plt>
lea    0xd3c(%rip),%rsi
mov    %r14,0x8(%rsp)
mov    %r14,%rdi
call   1080 <sql_exec@plt>
lea    0xd9e(%rip),%rdi
call   1060 <puts@plt>
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %rbp,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
mov    %rbp,%r14
je     1483 <import_ascii+0x243>
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0x20(%rsp),%r13
mov    %r14,0x10(%rsp)
jmp    1370 <import_ascii+0x130>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x40,%esi
mov    %r14,%rdx
call   10a0 <fgets@plt>
add    $0xffffffff,%r15d
add    $0x1,%ebx
test   %rax,%rax
je     1483 <import_ascii+0x243>
mov    %r13,%rdi
call   1090 <strlen@plt>
movslq %eax,%rdx
lea    -0x1(%rdx),%rcx
cmpb   $0xa,0x1f(%rsp,%rdx,1)
jne    13c0 <import_ascii+0x180>
movb   $0x0,0x20(%rsp,%rcx,1)
add    $0xfffffffe,%eax
movslq %eax,%rcx
cmpb   $0xd,0x20(%rsp,%rcx,1)
je     13c7 <import_ascii+0x187>
cmpq   $0x0,0x18(%rsp)
je     13d4 <import_ascii+0x194>
mov    %r13,%rdi
call   1130 <verify_passwd@plt>
test   %rax,%rax
je     13e1 <import_ascii+0x1a1>
add    $0x1,%ebp
jmp    143e <import_ascii+0x1fe>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0xd,0x20(%rsp,%rcx,1)
jne    1398 <import_ascii+0x158>
movb   $0x0,0x20(%rsp,%rcx,1)
cmpq   $0x0,0x18(%rsp)
jne    13a0 <import_ascii+0x160>
mov    %r13,%rdi
call   1030 <verify_essid@plt>
test   %rax,%rax
jne    13ad <import_ascii+0x16d>
mov    (%rsp),%r14
mov    %r13,%rdi
call   1090 <strlen@plt>
mov    0x2be4(%rip),%rcx
mov    (%rcx),%r8d
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13,%r14
mov    %r13,%rdx
mov    %eax,%ecx
call   1100 <sqlite3_bind_text@plt>
mov    (%rsp),%rdi
mov    $0xffffffff,%esi
call   1110 <sql_step@plt>
mov    0x2baf(%rip),%rcx
cmp    (%rcx),%rax
jne    1510 <import_ascii+0x2d0>
mov    (%rsp),%rdi
call   1050 <sqlite3_reset@plt>
mov    0x10(%rsp),%rax
mov    %r14,%r13
mov    %rax,%r14
mov    %ebx,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%eax
add    %r15d,%eax
jne    1350 <import_ascii+0x110>
mov    0x2b67(%rip),%r12
mov    (%r12),%edi
lea    0xbe1(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
call   10c0 <fprintf@plt>
mov    (%r12),%edi
call   10f0 <fflush@plt>
jmp    1350 <import_ascii+0x110>
mov    (%rsp),%rdi
call   1140 <sqlite3_finalize@plt>
mov    %r14,%rdi
call   10d0 <feof@plt>
test   %eax,%eax
je     14ee <import_ascii+0x2ae>
mov    %r14,%rdi
call   1070 <fclose@plt>
lea    0xc35(%rip),%rdi
call   1060 <puts@plt>
lea    0xbc4(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1080 <sql_exec@plt>
lea    0xc23(%rip),%rdi
call   1060 <puts@plt>
jmp    1540 <import_ascii+0x300>
mov    0x2b16(%rip),%rax
mov    (%rax),%rbp
test   %rbp,%rbp
jne    12c3 <import_ascii+0x83>
lea    0xc34(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
jmp    1545 <import_ascii+0x305>
lea    0xbcd(%rip),%rdi
call   1060 <puts@plt>
lea    0xb42(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1080 <sql_exec@plt>
mov    %r14,%rdi
jmp    153b <import_ascii+0x2fb>
lea    0xbd6(%rip),%rdi
call   1060 <puts@plt>
lea    0xb20(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1080 <sql_exec@plt>
mov    (%rsp),%rdi
call   1140 <sqlite3_finalize@plt>
mov    0x10(%rsp),%rdi
call   1070 <fclose@plt>
mov    $0x1,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"essid\00"
@.str.1 = [7 x i8] c"passwd\00"
@.str.2 = [52 x i8] c"Specify either 'essid' or 'passwd' as import mode.\0A\00"
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [41 x i8] c"Could not open file/stream for reading.\0A\00"
@.str.6 = [43 x i8] c"INSERT OR IGNORE INTO %q (%q) VALUES (@v);\00"
@.str.7 = [7 x i8] c"BEGIN;\00"
@.str.8 = [17 x i8] c"Reading file...\0A\00"
@SQLITE_TRANSIENT = global i32 0
@SQLITE_DONE = global i64 0
@.str.9 = [45 x i8] c"Error while inserting record into database.\0A\00"
@.str.10 = [10 x i8] c"ROLLBACK;\00"
@stdout = global i32 0
@.str.11 = [42 x i8] c"%i lines read, %i invalid lines ignored.\0D\00"
@.str.12 = [27 x i8] c"Error while reading file.\0A\00"
@.str.13 = [12 x i8] c"Writing...\0A\00"
@.str.14 = [8 x i8] c"COMMIT;\00"
@.str.15 = [7 x i8] c"Done.\0A\00"
define i32 @import_ascii(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [64 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* null, i32** %8
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%16 = load i8*, i8** %6
%17 = call i64 @strcasecmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 0, i32* %13
br label %28
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = call i64 @strcasecmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %13
br label %27
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %160
27: ; preds = %24
br label %28
28: ; preds = %27, %19
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32*, i32** @stdin
store i32* %33, i32** %8
br label %37
34: ; preds = %28
%35 = load i8*, i8** %7
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %36, i32** %8
br label %37
37: ; preds = %34, %32
%38 = load i32*, i32** %8
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %4
br label %160
42: ; preds = %37
%43 = load i8*, i8** %6
%44 = load i8*, i8** %6
%45 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %43, i8* %44)
store i8* %45, i8** %14
%46 = load i32*, i32** %5
%47 = load i8*, i8** %14
%48 = call i32 @sql_prepare(i32* %46, i8* %47, i32** %9, i32 -1)
%49 = load i8*, i8** %14
%50 = call i32 @sqlite3_free(i8* %49)
%51 = load i32*, i32** %5
%52 = call i32 @sql_exec(i32* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %54
54: ; preds = %140, %42
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%56 = load i32*, i32** %8
%57 = call i64 @fgets(i8* %55, i32 64, i32* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %141
59: ; preds = %54
%60 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
store i32 %61, i32* %15
%62 = load i32, i32* %15
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 10
br i1 %68, label %69, label %74
69: ; preds = %59
%70 = load i32, i32* %15
%71 = add nsw i32 %70, -1
store i32 %71, i32* %15
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 %72
store i8 0, i8* %73
br label %74
74: ; preds = %69, %59
%75 = load i32, i32* %15
%76 = sub nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 13
br i1 %81, label %82, label %87
82: ; preds = %74
%83 = load i32, i32* %15
%84 = add nsw i32 %83, -1
store i32 %84, i32* %15
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 %85
store i8 0, i8* %86
br label %87
87: ; preds = %82, %74
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 1
store i32 %89, i32* %11
%90 = load i32, i32* %13
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%94 = call i64 @verify_essid(i8* %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %103, label %96
96: ; preds = %92, %87
%97 = load i32, i32* %13
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %126
99: ; preds = %96
%100 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%101 = call i64 @verify_passwd(i8* %100)
%102 = icmp eq i64 %101, 0
br i1 %102, label %103, label %126
103: ; preds = %99, %92
%104 = load i32*, i32** %9
%105 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%106 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%107 = call i32 @strlen(i8* %106)
%108 = load i32, i32* @SQLITE_TRANSIENT
%109 = call i32 @sqlite3_bind_text(i32* %104, i32 1, i8* %105, i32 %107, i32 %108)
%110 = load i32*, i32** %9
%111 = call i64 @sql_step(i32* %110, i32 -1)
%112 = load i64, i64* @SQLITE_DONE
%113 = icmp eq i64 %111, %112
br i1 %113, label %114, label %117
114: ; preds = %103
%115 = load i32*, i32** %9
%116 = call i32 @sqlite3_reset(i32* %115)
br label %125
117: ; preds = %103
%118 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%119 = load i32*, i32** %5
%120 = call i32 @sql_exec(i32* %119, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%121 = load i32*, i32** %9
%122 = call i32 @sqlite3_finalize(i32* %121)
%123 = load i32*, i32** %8
%124 = call i32 @fclose(i32* %123)
store i32 1, i32* %4
br label %160
125: ; preds = %114
br label %129
126: ; preds = %99, %96
%127 = load i32, i32* %12
%128 = add nsw i32 %127, 1
store i32 %128, i32* %12
br label %129
129: ; preds = %126, %125
%130 = load i32, i32* %11
%131 = srem i32 %130, 1000
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %140
133: ; preds = %129
%134 = load i32, i32* @stdout
%135 = load i32, i32* %11
%136 = load i32, i32* %12
%137 = call i32 @fprintf(i32 %134, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i32 %135, i32 %136)
%138 = load i32, i32* @stdout
%139 = call i32 @fflush(i32 %138)
br label %140
140: ; preds = %133, %129
br label %54
141: ; preds = %54
%142 = load i32*, i32** %9
%143 = call i32 @sqlite3_finalize(i32* %142)
%144 = load i32*, i32** %8
%145 = call i32 @feof(i32* %144)
%146 = icmp ne i32 %145, 0
br i1 %146, label %153, label %147
147: ; preds = %141
%148 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
%149 = load i32*, i32** %5
%150 = call i32 @sql_exec(i32* %149, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%151 = load i32*, i32** %8
%152 = call i32 @fclose(i32* %151)
store i32 1, i32* %4
br label %160
153: ; preds = %141
%154 = load i32*, i32** %8
%155 = call i32 @fclose(i32* %154)
%156 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%157 = load i32*, i32** %5
%158 = call i32 @sql_exec(i32* %157, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
%159 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %4
br label %160
160: ; preds = %153, %147, %117, %40, %25
%161 = load i32, i32* %4
ret i32 %161
}

LLVM IR (-O2):
@.str = [6 x i8] c"essid\00"
@.str.1 = [7 x i8] c"passwd\00"
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@.str.6 = [43 x i8] c"INSERT OR IGNORE INTO %q (%q) VALUES (@v);\00"
@.str.7 = [7 x i8] c"BEGIN;\00"
@SQLITE_TRANSIENT = global i32 0
@SQLITE_DONE = global i64 0
@.str.10 = [10 x i8] c"ROLLBACK;\00"
@stdout = global i32 0
@.str.11 = [42 x i8] c"%i lines read, %i invalid lines ignored.\0D\00"
@.str.14 = [8 x i8] c"COMMIT;\00"
@str = [51 x i8] c"Specify either 'essid' or 'passwd' as import mode.\00"
@str.16 = [16 x i8] c"Reading file...\00"
@str.17 = [26 x i8] c"Error while reading file.\00"
@str.18 = [11 x i8] c"Writing...\00"
@str.19 = [6 x i8] c"Done.\00"
@str.20 = [44 x i8] c"Error while inserting record into database.\00"
@str.21 = [40 x i8] c"Could not open file/stream for reading.\00"
define i32 @import_ascii(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca [64 x i8]
%6 = bitcast i32** %4 to i8*
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = tail call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = tail call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %107
15: ; preds = %10, %3
%16 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32*, i32** @stdin
br label %22
20: ; preds = %15
%21 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = phi i32* [ %19, %18 ], [ %21, %20 ]
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.21, i64 0, i64 0))
br label %107
27: ; preds = %22
%28 = tail call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8* %1)
%29 = call i32 @sql_prepare(i32* %0, i8* %28, i32** %4, i32 -1)
%30 = call i32 @sqlite3_free(i8* %28)
%31 = call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.16, i64 0, i64 0))
%33 = call i64 @fgets(i8* %7, i32 64, i32* %23)
%34 = icmp eq i64 %33, 0
br i1 %34, label %93, label %35
35: ; preds = %27, %90
%36 = phi i32 [ %82, %90 ], [ 0, %27 ]
%37 = phi i32 [ %54, %90 ], [ 0, %27 ]
%38 = call i32 @strlen(i8* %7)
%39 = add nsw i32 %38, -1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %35
store i8 0, i8* %41
%45 = add nsw i32 %38, -2
%46 = sext i32 %45 to i64
br label %47
47: ; preds = %44, %35
%48 = phi i64 [ %46, %44 ], [ %40, %35 ]
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 13
br i1 %51, label %52, label %53
52: ; preds = %47
store i8 0, i8* %49
br label %53
53: ; preds = %52, %47
%54 = add nuw nsw i32 %37, 1
br i1 %9, label %55, label %58
55: ; preds = %53
%56 = call i64 @verify_essid(i8* %7)
%57 = icmp eq i64 %56, 0
br i1 %57, label %61, label %79
58: ; preds = %53
%59 = call i64 @verify_passwd(i8* %7)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %79
61: ; preds = %58, %55
%62 = load i32*, i32** %4
%63 = call i32 @strlen(i8* %7)
%64 = load i32, i32* @SQLITE_TRANSIENT
%65 = call i32 @sqlite3_bind_text(i32* %62, i32 1, i8* %7, i32 %63, i32 %64)
%66 = load i32*, i32** %4
%67 = call i64 @sql_step(i32* %66, i32 -1)
%68 = load i64, i64* @SQLITE_DONE
%69 = icmp eq i64 %67, %68
br i1 %69, label %70, label %73
70: ; preds = %61
%71 = load i32*, i32** %4
%72 = call i32 @sqlite3_reset(i32* %71)
br label %81
73: ; preds = %61
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.20, i64 0, i64 0))
%75 = call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%76 = load i32*, i32** %4
%77 = call i32 @sqlite3_finalize(i32* %76)
%78 = call i32 @fclose(i32* %23)
br label %107
79: ; preds = %55, %58
%80 = add nsw i32 %36, 1
br label %81
81: ; preds = %79, %70
%82 = phi i32 [ %36, %70 ], [ %80, %79 ]
%83 = urem i32 %54, 1000
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %90
85: ; preds = %81
%86 = load i32, i32* @stdout
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), i32 %54, i32 %82)
%88 = load i32, i32* @stdout
%89 = call i32 @fflush(i32 %88)
br label %90
90: ; preds = %81, %85
%91 = call i64 @fgets(i8* %7, i32 64, i32* %23)
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %35
93: ; preds = %90, %27
%94 = load i32*, i32** %4
%95 = call i32 @sqlite3_finalize(i32* %94)
%96 = call i32 @feof(i32* %23)
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %102
98: ; preds = %93
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.17, i64 0, i64 0))
%100 = call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%101 = call i32 @fclose(i32* %23)
br label %107
102: ; preds = %93
%103 = call i32 @fclose(i32* %23)
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%105 = call i32 @sql_exec(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.19, i64 0, i64 0))
br label %107
107: ; preds = %73, %98, %102, %25, %13
%108 = phi i32 [ 0, %25 ], [ 0, %13 ], [ 1, %102 ], [ 1, %98 ], [ 1, %73 ]
ret i32 %108
}