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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ executeSqlStmt(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int, int, int, long, float);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ tic();
long toc();
long executeSqlFile(sqlite3 *db, char *filename) {
  char *stmt = NULL;
  size_t len = 0;
  ssize_t read;
  int ntrans = 0;
  int currstmts = 0;
  int maxstmts = 0;
  int nstmts = 0;
  FILE *fp = fopen(filename, "r");
  assert(fp != NULL);
  tic();
  while ((read = getline(&stmt, &len, fp)) != -1) {
    if ((stmt == NULL) || (strlen(stmt) == 0))
      continue;
    if (strncmp(stmt, "BEGIN", 5) == 0) {
    }
    if (strncmp(stmt, "COMMIT", 5) == 0) {
      ntrans++;
      if (currstmts > maxstmts)
        maxstmts = currstmts;
      currstmts = 0;
    }
    nstmts++;
    currstmts++;
    executeSqlStmt(db, stmt, nstmts);
  }
  long t = toc();
  float f = ntrans * 1000000;
  f /= t;
  printf("%s %d statements, %d transactions, max size %d in %ld microseconds "
         "is %f trans/sec\n",
         filename, nstmts, ntrans, maxstmts, t, f);
  free(stmt);
  fclose(fp);
  return ntrans;
}


x86 assembly (clang, -O0):
<executeSqlFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x0,%al
call   1090 <tic@plt>
mov    -0x40(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10d0 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     12e5 <executeSqlFile+0x135>
cmpq   $0x0,-0x18(%rbp)
je     1254 <executeSqlFile+0xa4>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
jne    1259 <executeSqlFile+0xa9>
jmp    1219 <executeSqlFile+0x69>
mov    -0x18(%rbp),%rdi
lea    0xd9e(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    127d <executeSqlFile+0xcd>
jmp    127d <executeSqlFile+0xcd>
mov    -0x18(%rbp),%rdi
lea    0xd80(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    12be <executeSqlFile+0x10e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    12b7 <executeSqlFile+0x107>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   10b0 <executeSqlStmt@plt>
jmp    1219 <executeSqlFile+0x69>
mov    $0x0,%al
call   1030 <toc@plt>
mov    %rax,-0x48(%rbp)
imul   $0xf4240,-0x28(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4c(%rbp)
cvtsi2ssq -0x48(%rbp),%xmm1
movss  -0x4c(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x48(%rbp),%r9
movss  -0x4c(%rbp),%xmm0
lea    0xcdd(%rip),%rdi
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movslq -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeSqlFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rax
mov    %rdi,0x18(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe31(%rip),%rsi
mov    %rax,0x20(%rsp)
mov    %rax,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1090 <assert@plt>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1080 <tic@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
mov    $0x0,%r13d
mov    $0x0,%ebp
cmp    $0xffffffff,%eax
je     12cd <executeSqlFile+0x12d>
xor    %ebp,%ebp
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r14
xor    %r12d,%r12d
xor    %r13d,%r13d
movl   $0x0,0x4(%rsp)
jmp    1253 <executeSqlFile+0xb3>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
je     12cd <executeSqlFile+0x12d>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1240 <executeSqlFile+0xa0>
cmpb   $0x0,(%rdi)
je     1240 <executeSqlFile+0xa0>
lea    0xd99(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
mov    0x8(%rsp),%rdi
lea    0xd89(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    %r13d,%r12d
mov    %r13d,%ecx
cmovg  %r12d,%ecx
add    $0x1,%r12d
xor    %edx,%edx
test   %rax,%rax
cmove  %ecx,%r13d
mov    $0x1,%eax
cmove  %eax,%r12d
sete   %dl
add    %edx,%ebp
mov    0x4(%rsp),%edx
add    $0x1,%edx
mov    0x8(%rsp),%rsi
mov    0x18(%rsp),%rdi
mov    %edx,0x4(%rsp)
call   10a0 <executeSqlStmt@plt>
jmp    1240 <executeSqlFile+0xa0>
xor    %eax,%eax
call   1030 <toc@plt>
imul   $0xf4240,%ebp,%ecx
cvtsi2ss %ecx,%xmm0
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
lea    0xd21(%rip),%rdi
mov    0x20(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    %ebp,%ecx
mov    %r13d,%r8d
mov    %rax,%r9
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
movslq %ebp,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"BEGIN\00"
@.str.2 = [7 x i8] c"COMMIT\00"
@.str.3 = [84 x i8] c"%s %d statements, %d transactions, max size %d in %ld microseconds is %f trans/sec\0A\00"
define i64 @executeSqlFile(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i64
%14 = alloca float
store i32* %0, i32** %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i64 0, i64* %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%15 = load i8*, i8** %4
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %12
%17 = load i32*, i32** %12
%18 = icmp ne i32* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 (...) @tic()
br label %22
22: ; preds = %52, %33, %2
%23 = load i32*, i32** %12
%24 = call i32 @getline(i8** %5, i64* %6, i32* %23)
store i32 %24, i32* %7
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %61
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = icmp eq i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = call i64 @strlen(i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29, %26
br label %22
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = call i64 @strncmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
br label %39
39: ; preds = %38, %34
%40 = load i8*, i8** %5
%41 = call i64 @strncmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 5)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
%46 = load i32, i32* %9
%47 = load i32, i32* %10
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = load i32, i32* %9
store i32 %50, i32* %10
br label %51
51: ; preds = %49, %43
store i32 0, i32* %9
br label %52
52: ; preds = %51, %39
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
%57 = load i32*, i32** %3
%58 = load i8*, i8** %5
%59 = load i32, i32* %11
%60 = call i32 @executeSqlStmt(i32* %57, i8* %58, i32 %59)
br label %22
61: ; preds = %22
%62 = call i64 (...) @toc()
store i64 %62, i64* %13
%63 = load i32, i32* %8
%64 = mul nsw i32 %63, 1000000
%65 = sitofp i32 %64 to float
store float %65, float* %14
%66 = load i64, i64* %13
%67 = sitofp i64 %66 to float
%68 = load float, float* %14
%69 = fdiv float %68, %67
store float %69, float* %14
%70 = load i8*, i8** %4
%71 = load i32, i32* %11
%72 = load i32, i32* %8
%73 = load i32, i32* %10
%74 = load i64, i64* %13
%75 = load float, float* %14
%76 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.3, i64 0, i64 0), i8* %70, i32 %71, i32 %72, i32 %73, i64 %74, float %75)
%77 = load i8*, i8** %5
%78 = call i32 @free(i8* %77)
%79 = load i32*, i32** %12
%80 = call i32 @fclose(i32* %79)
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
ret i64 %82
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"BEGIN\00"
@.str.2 = [7 x i8] c"COMMIT\00"
@.str.3 = [84 x i8] c"%s %d statements, %d transactions, max size %d in %ld microseconds is %f trans/sec\0A\00"
define i64 @executeSqlFile(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32* %7, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 (...) @tic()
%12 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%13 = icmp eq i32 %12, -1
br i1 %13, label %45, label %14
14: ; preds = %2, %28
%15 = phi i32 [ %37, %28 ], [ 0, %2 ]
%16 = phi i32 [ %40, %28 ], [ 0, %2 ]
%17 = phi i32 [ %35, %28 ], [ 0, %2 ]
%18 = phi i32 [ %38, %28 ], [ 0, %2 ]
br label %19
19: ; preds = %14, %25
%20 = load i8*, i8** %3
%21 = icmp eq i8* %20, null
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22, %19
%26 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%27 = icmp eq i32 %26, -1
br i1 %27, label %45, label %19
28: ; preds = %22
%29 = call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%30 = load i8*, i8** %3
%31 = call i64 @strncmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 5)
%32 = icmp eq i64 %31, 0
%33 = icmp sgt i32 %16, %17
%34 = select i1 %32, i1 %33, i1 false
%35 = select i1 %34, i32 %16, i32 %17
%36 = zext i1 %32 to i32
%37 = add nuw nsw i32 %15, %36
%38 = add nuw nsw i32 %18, 1
%39 = add nsw i32 %16, 1
%40 = select i1 %32, i32 1, i32 %39
%41 = load i8*, i8** %3
%42 = call i32 @executeSqlStmt(i32* %0, i8* %41, i32 %38)
%43 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %14
45: ; preds = %28, %25, %2
%46 = phi i32 [ 0, %2 ], [ %18, %25 ], [ %38, %28 ]
%47 = phi i32 [ 0, %2 ], [ %17, %25 ], [ %35, %28 ]
%48 = phi i32 [ 0, %2 ], [ %15, %25 ], [ %37, %28 ]
%49 = call i64 (...) @toc()
%50 = mul nsw i32 %48, 1000000
%51 = sitofp i32 %50 to float
%52 = sitofp i64 %49 to float
%53 = fdiv float %51, %52
%54 = call i32 @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %46, i32 %48, i32 %47, i64 %49, float %53)
%55 = load i8*, i8** %3
%56 = call i32 @free(i8* %55)
%57 = call i32 @fclose(i32* %7)
%58 = sext i32 %48 to i64
ret i64 %58
}