#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ load_file_params;
struct TYPE_4__ {
  char *buffer;
  long buffer_length;
  int /*<<< orphan*/ buffer_type;
};
typedef int /*<<< orphan*/ MYSQL_STMT;
typedef TYPE_1__ MYSQL_BIND;
typedef int /*<<< orphan*/ MYSQL;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ MYSQL_TYPE_BLOB;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
size_t fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ *getMysqlConn();
char *malloc(int);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mysqlErrAndExit(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mysql_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_stmt_bind_param(int /*<<< orphan*/ *, TYPE_1__ *);
int /*<<< orphan*/ mysql_stmt_close(int /*<<< orphan*/ *);
scalar_t__ mysql_stmt_execute(int /*<<< orphan*/ *);
int /*<<< orphan*/ *mysql_stmt_init(int /*<<< orphan*/ *);
scalar_t__ mysql_stmt_prepare(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "usage: %s <log-file>\n", argv[0]);
    exit(1);
  }
  FILE *fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    fprintf(stderr, "Could not open file\n");
    exit(1);
  }
  MYSQL *dbconn;
  dbconn = getMysqlConn();
  if (fseek(fp, 0L, SEEK_END) != 0) {
    fprintf(stderr, "Seek (to end) error\n");
    exit(1);
  }
  long bufsize = ftell(fp);
  if (bufsize == -1) {
    fprintf(stderr, "ftell error\n");
    exit(1);
  }
  char *buffer = malloc(sizeof(char) * bufsize);
  if (buffer == NULL) {
    fprintf(stderr, "malloc error\n");
    exit(1);
  }
  if (fseek(fp, 0L, SEEK_SET) != 0) {
    fprintf(stderr, "Seek (to start) error\n");
    exit(1);
  }
  size_t newLen = fread(buffer, sizeof(char), bufsize, fp);
  if (newLen == 0) {
    fputs("Error reading file", stderr);
    exit(1);
  }
  fclose(fp);
  char *load_file_stmt_sql =
      "UPDATE updates SET output=? ORDER BY id DESC LIMIT 1";
  MYSQL_STMT *load_file_stmt = mysql_stmt_init(dbconn);
  if (!load_file_stmt) {
    mysqlErrAndExit(dbconn, "mysql_stmt_init");
  }
  if (mysql_stmt_prepare(load_file_stmt, load_file_stmt_sql,
                         strlen(load_file_stmt_sql))) {
    mysqlErrAndExit(dbconn, "mysql_stmt_prepare set_next_user");
  }
  MYSQL_BIND load_file_params[1];
  memset(load_file_params, 0, sizeof(load_file_params));
  load_file_params[0].buffer_type = MYSQL_TYPE_BLOB;
  load_file_params[0].buffer = buffer;
  load_file_params[0].buffer_length = bufsize;
  mysql_stmt_bind_param(load_file_stmt, load_file_params);
  if (mysql_stmt_execute(load_file_stmt)) {
    mysqlErrAndExit(dbconn, "(prepared) load_file_stmt");
  }
  mysql_stmt_close(load_file_stmt);
  free(buffer);
  mysql_close(dbconn);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1288 <main+0x48>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd7f(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12cc <main+0x8c>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    $0x0,%al
call   10f0 <getMysqlConn@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d06(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1100 <fseek@plt>
cmp    $0x0,%rax
je     1318 <main+0xd8>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xffffffffffffffff,-0x28(%rbp)
jne    1351 <main+0x111>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1390 <main+0x150>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xcd1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c2d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1100 <fseek@plt>
cmp    $0x0,%rax
je     13d1 <main+0x191>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
lea    0xc9e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1415 <main+0x1d5>
mov    0x2bdb(%rip),%rax
mov    (%rax),%esi
lea    0xc6f(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xc63(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <mysql_stmt_init@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1451 <main+0x211>
mov    -0x20(%rbp),%rdi
lea    0xc71(%rip),%rsi
call   1160 <mysqlErrAndExit@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
call   10a0 <mysql_stmt_prepare@plt>
cmp    $0x0,%rax
je     1493 <main+0x253>
mov    -0x20(%rbp),%rdi
lea    0xc3f(%rip),%rsi
call   1160 <mysqlErrAndExit@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2b26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1140 <mysql_stmt_bind_param@plt>
mov    -0x48(%rbp),%rdi
call   1130 <mysql_stmt_execute@plt>
cmp    $0x0,%rax
je     14ef <main+0x2af>
mov    -0x20(%rbp),%rdi
lea    0xc04(%rip),%rsi
call   1160 <mysqlErrAndExit@plt>
mov    -0x48(%rbp),%rdi
call   10d0 <mysql_stmt_close@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1110 <mysql_close@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x1,%edi
jle    13c7 <main+0x187>
mov    0x8(%rsi),%rdi
lea    0xdb5(%rip),%rsi
call   1120 <fopen@plt>
test   %rax,%rax
je     13eb <main+0x1ab>
mov    %rax,%rbx
xor    %eax,%eax
call   10f0 <getMysqlConn@plt>
mov    %rax,%r14
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1100 <fseek@plt>
test   %rax,%rax
jne    13fd <main+0x1bd>
mov    %rbx,%rdi
call   10c0 <ftell@plt>
cmp    $0xffffffffffffffff,%rax
je     140f <main+0x1cf>
mov    %rax,%r12
mov    %r12d,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     1421 <main+0x1e1>
mov    %rax,%r15
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1100 <fseek@plt>
test   %rax,%rax
jne    1433 <main+0x1f3>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1454 <main+0x214>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1080 <mysql_stmt_init@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1320 <main+0xe0>
lea    0xda5(%rip),%rsi
mov    %r14,%rdi
call   1160 <mysqlErrAndExit@plt>
lea    0xd61(%rip),%r13
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   10a0 <mysql_stmt_prepare@plt>
test   %rax,%rax
je     1350 <main+0x110>
lea    0xd85(%rip),%rsi
mov    %r14,%rdi
call   1160 <mysqlErrAndExit@plt>
mov    %rsp,%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %r15,(%rsp)
mov    %r12,0x8(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1140 <mysql_stmt_bind_param@plt>
mov    %rbx,%rdi
call   1130 <mysql_stmt_execute@plt>
test   %rax,%rax
je     139f <main+0x15f>
lea    0xd57(%rip),%rsi
mov    %r14,%rdi
call   1160 <mysqlErrAndExit@plt>
mov    %rbx,%rdi
call   10d0 <mysql_stmt_close@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1110 <mysql_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xc26(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    0xc1e(%rip),%rsi
jmp    1443 <main+0x203>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
lea    0xc21(%rip),%rsi
jmp    1443 <main+0x203>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xc24(%rip),%rsi
jmp    1443 <main+0x203>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
lea    0xc1f(%rip),%rsi
jmp    1443 <main+0x203>
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
lea    0xc1b(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    0x2b7d(%rip),%rax
mov    (%rax),%esi
lea    0xc11(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i64, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"usage: %s <log-file>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"Could not open file\0A\00"
@SEEK_END = global i32 0
@.str.3 = [21 x i8] c"Seek (to end) error\0A\00"
@.str.4 = [13 x i8] c"ftell error\0A\00"
@.str.5 = [14 x i8] c"malloc error\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [23 x i8] c"Seek (to start) error\0A\00"
@.str.7 = [19 x i8] c"Error reading file\00"
@.str.8 = [53 x i8] c"UPDATE updates SET output=? ORDER BY id DESC LIMIT 1\00"
@.str.9 = [16 x i8] c"mysql_stmt_init\00"
@.str.10 = [33 x i8] c"mysql_stmt_prepare set_next_user\00"
@MYSQL_TYPE_BLOB = global i32 0
@.str.11 = [26 x i8] c"(prepared) load_file_stmt\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 i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca [1 x %struct.TYPE_4__]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %23
%35 = call i32* (...) @getMysqlConn()
store i32* %35, i32** %7
%36 = load i32*, i32** %6
%37 = load i32, i32* @SEEK_END
%38 = call i64 @fseek(i32* %36, i64 0, i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
%45 = load i32*, i32** %6
%46 = call i64 @ftell(i32* %45)
store i64 %46, i64* %8
%47 = load i64, i64* %8
%48 = icmp eq i64 %47, -1
br i1 %48, label %49, label %53
49: ; preds = %44
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %44
%54 = load i64, i64* %8
%55 = mul i64 1, %54
%56 = trunc i64 %55 to i32
%57 = call i8* @malloc(i32 %56)
store i8* %57, i8** %9
%58 = load i8*, i8** %9
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %64
60: ; preds = %53
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %53
%65 = load i32*, i32** %6
%66 = load i32, i32* @SEEK_SET
%67 = call i64 @fseek(i32* %65, i64 0, i32 %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %64
%74 = load i8*, i8** %9
%75 = load i64, i64* %8
%76 = load i32*, i32** %6
%77 = call i64 @fread(i8* %74, i32 1, i64 %75, i32* %76)
store i64 %77, i64* %10
%78 = load i64, i64* %10
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %73
%81 = load i32, i32* @stderr
%82 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %81)
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %73
%85 = load i32*, i32** %6
%86 = call i32 @fclose(i32* %85)
store i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i8** %11
%87 = load i32*, i32** %7
%88 = call i32* @mysql_stmt_init(i32* %87)
store i32* %88, i32** %12
%89 = load i32*, i32** %12
%90 = icmp ne i32* %89, null
br i1 %90, label %94, label %91
91: ; preds = %84
%92 = load i32*, i32** %7
%93 = call i32 @mysqlErrAndExit(i32* %92, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %94
94: ; preds = %91, %84
%95 = load i32*, i32** %12
%96 = load i8*, i8** %11
%97 = load i8*, i8** %11
%98 = call i32 @strlen(i8* %97)
%99 = call i64 @mysql_stmt_prepare(i32* %95, i8* %96, i32 %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %94
%102 = load i32*, i32** %7
%103 = call i32 @mysqlErrAndExit(i32* %102, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0))
br label %104
104: ; preds = %101, %94
%105 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %13, i64 0, i64 0
%106 = call i32 @memset(%struct.TYPE_4__* %105, i32 0, i32 24)
%107 = load i32, i32* @MYSQL_TYPE_BLOB
%108 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %13, i64 0, i64 0
%109 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %108, i32 0, i32 2
store i32 %107, i32* %109
%110 = load i8*, i8** %9
%111 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %13, i64 0, i64 0
%112 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %111, i32 0, i32 0
store i8* %110, i8** %112
%113 = load i64, i64* %8
%114 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %13, i64 0, i64 0
%115 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %114, i32 0, i32 1
store i64 %113, i64* %115
%116 = load i32*, i32** %12
%117 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %13, i64 0, i64 0
%118 = call i32 @mysql_stmt_bind_param(i32* %116, %struct.TYPE_4__* %117)
%119 = load i32*, i32** %12
%120 = call i64 @mysql_stmt_execute(i32* %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %104
%123 = load i32*, i32** %7
%124 = call i32 @mysqlErrAndExit(i32* %123, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %125
125: ; preds = %122, %104
%126 = load i32*, i32** %12
%127 = call i32 @mysql_stmt_close(i32* %126)
%128 = load i8*, i8** %9
%129 = call i32 @free(i8* %128)
%130 = load i32*, i32** %7
%131 = call i32 @mysql_close(i32* %130)
%132 = load i32, i32* %3
ret i32 %132
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i64, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"usage: %s <log-file>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"Could not open file\0A\00"
@SEEK_END = global i32 0
@.str.3 = [21 x i8] c"Seek (to end) error\0A\00"
@.str.4 = [13 x i8] c"ftell error\0A\00"
@.str.5 = [14 x i8] c"malloc error\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [23 x i8] c"Seek (to start) error\0A\00"
@.str.7 = [19 x i8] c"Error reading file\00"
@.str.8 = [53 x i8] c"UPDATE updates SET output=? ORDER BY id DESC LIMIT 1\00"
@.str.9 = [16 x i8] c"mysql_stmt_init\00"
@.str.10 = [33 x i8] c"mysql_stmt_prepare set_next_user\00"
@MYSQL_TYPE_BLOB = global i32 0
@.str.11 = [26 x i8] c"(prepared) load_file_stmt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x %struct.TYPE_4__]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = tail call i32* (...) @getMysqlConn()
%21 = load i32, i32* @SEEK_END
%22 = tail call i64 @fseek(i32* %13, i64 0, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = tail call i64 @ftell(i32* %13)
%30 = icmp eq i64 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = trunc i64 %29 to i32
%37 = tail call i8* @malloc(i32 %36)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %35
%44 = load i32, i32* @SEEK_SET
%45 = tail call i64 @fseek(i32* %13, i64 0, i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %43
%52 = tail call i64 @fread(i8* %37, i32 1, i64 %29, i32* %13)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = tail call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %51
%59 = tail call i32 @fclose(i32* %13)
%60 = tail call i32* @mysql_stmt_init(i32* %20)
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = tail call i32 @mysqlErrAndExit(i32* %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %64
64: ; preds = %62, %58
%65 = tail call i32 @strlen(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
%66 = tail call i64 @mysql_stmt_prepare(i32* %60, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i32 %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = tail call i32 @mysqlErrAndExit(i32* %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = bitcast [1 x %struct.TYPE_4__]* %3 to i8*
%72 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %3, i64 0, i64 0
%73 = call i32 @memset(%struct.TYPE_4__* %72, i32 0, i32 24)
%74 = load i32, i32* @MYSQL_TYPE_BLOB
%75 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %3, i64 0, i64 0, i32 2
store i32 %74, i32* %75
%76 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %3, i64 0, i64 0, i32 0
store i8* %37, i8** %76
%77 = getelementptr inbounds [1 x %struct.TYPE_4__], [1 x %struct.TYPE_4__]* %3, i64 0, i64 0, i32 1
store i64 %29, i64* %77
%78 = call i32 @mysql_stmt_bind_param(i32* %60, %struct.TYPE_4__* %72)
%79 = call i64 @mysql_stmt_execute(i32* %60)
%80 = icmp eq i64 %79, 0
br i1 %80, label %83, label %81
81: ; preds = %70
%82 = call i32 @mysqlErrAndExit(i32* %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %83
83: ; preds = %81, %70
%84 = call i32 @mysql_stmt_close(i32* %60)
%85 = call i32 @free(i8* %37)
%86 = call i32 @mysql_close(i32* %20)
ret i32 0
}