#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*/ time_t;
struct stat {
  scalar_t__ st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float atof(char const *);
int /*<<< orphan*/ *copySplitData(int /*<<< orphan*/ *, double, long);
int /*<<< orphan*/ ctime_r(int /*<<< orphan*/ *, char *);
float fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fstat(int /*<<< orphan*/, struct stat *);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int /*<<< orphan*/ stat(char const *, struct stat *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ *tmpfile();
int main(int argc, const char **argv) {
  char buf[1024];
  double t1, t2;
  FILE *fd, *tempfd;
  long before, after;
  char btime[26];
  const char *base_filename;
  float min_timedifference;
  struct stat fbuf;
  struct stat ftempbuf;
  if (argc != 3) {
    printf("\n"
           " logsplitter - split a log file into smaller chunks, based on the "
           "consecutive timestamp difference\n\n"
           "USAGE:  logsplitter [min_time_difference_in_seconds] [FILE]\n\n");
    return -1;
  }
  min_timedifference = atof(argv[1]);
  base_filename = argv[2];
  printf("I: Minimum time difference is: %f seconds.\n", min_timedifference);
  fd = fopen(base_filename, "r+");
  if (!fd) {
    printf("E: Opening %s ...[failed]\n", base_filename);
    return -1;
  } else
    printf("I: Opening %s ...[success]\n", base_filename);
  stat(base_filename, &fbuf);
  if ((tempfd = tmpfile()) == NULL) {
    printf("E: Cannot create a temporary file! Aborting...\n");
    return -1;
  }
  while (1) {
    fgets(buf, 1024, fd);
    if (feof(fd))
      break;
    fputs(buf, tempfd);
  }
  fflush(tempfd);
  fclose(fd);
  fstat(fileno(tempfd), &ftempbuf);
  if ((fbuf.st_size - ftempbuf.st_size) != 0) {
    printf("E: The temporary file differs than the original log file by %ld "
           "bytes! Aborting...",
           fbuf.st_size - ftempbuf.st_size);
  }
  rewind(tempfd);
  while (!feof(tempfd)) {
    fgets(buf, 1024, tempfd);
    if (strncmp(buf, "##", 2) == 0)
      printf("> ignoring: %s", buf);
    else {
      sscanf(buf, "%lf", &t1);
      break;
    }
  }
  while (!feof(tempfd)) {
    before = ftell(tempfd);
    fgets(buf, 1024, tempfd);
    if (strncmp(buf, "##", 2) == 0)
      printf("> ignoring: %s", buf);
    else
      sscanf(buf, "%lf", &t2);
    after = ftell(tempfd);
    if ((fabs(t2 - t1) > min_timedifference) && (after - before > 0)) {
      time_t t = (time_t)t1;
      ctime_r(&t, btime);
      printf("I: Break (%f) needed after T = %f -> %s", t2 - t1, t1, btime);
      tempfd = copySplitData(tempfd, t2, after - before);
      if (ftell(tempfd) == 0)
        break;
      rewind(tempfd);
    }
    t1 = t2;
  }
  fclose(tempfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     126d <main+0x3d>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1665 <main+0x435>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x46c(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x468(%rbp)
movss  -0x46c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x468(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jne    12f4 <main+0xc4>
mov    -0x468(%rbp),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1665 <main+0x435>
mov    -0x468(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x468(%rbp),%rdi
lea    -0x478(%rbp),%rsi
call   10f0 <stat@plt>
mov    $0x0,%al
call   10c0 <tmpfile@plt>
mov    %rax,-0x430(%rbp)
cmp    $0x0,%rax
jne    134e <main+0x11e>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1665 <main+0x435>
jmp    1353 <main+0x123>
lea    -0x410(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
mov    -0x428(%rbp),%rdi
call   10e0 <feof@plt>
cmp    $0x0,%rax
je     1386 <main+0x156>
jmp    139e <main+0x16e>
lea    -0x410(%rbp),%rdi
mov    -0x430(%rbp),%rsi
call   1090 <fputs@plt>
jmp    1353 <main+0x123>
mov    -0x430(%rbp),%rdi
call   1110 <fflush@plt>
mov    -0x428(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x430(%rbp),%rdi
call   1100 <fileno@plt>
mov    %eax,%edi
lea    -0x480(%rbp),%rsi
call   1150 <fstat@plt>
mov    -0x478(%rbp),%rax
sub    -0x480(%rbp),%rax
cmp    $0x0,%rax
je     1404 <main+0x1d4>
mov    -0x478(%rbp),%rsi
sub    -0x480(%rbp),%rsi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x430(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x430(%rbp),%rdi
call   10e0 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1432 <main+0x202>
jmp    14aa <main+0x27a>
lea    -0x410(%rbp),%rdi
mov    -0x430(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xd34(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1486 <main+0x256>
lea    -0x410(%rbp),%rsi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14a5 <main+0x275>
lea    -0x410(%rbp),%rdi
lea    0xd0a(%rip),%rsi
lea    -0x418(%rbp),%rdx
call   1130 <sscanf@plt>
jmp    14aa <main+0x27a>
jmp    1410 <main+0x1e0>
jmp    14af <main+0x27f>
mov    -0x430(%rbp),%rdi
call   10e0 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14d1 <main+0x2a1>
jmp    1652 <main+0x422>
mov    -0x430(%rbp),%rdi
call   10d0 <ftell@plt>
mov    %rax,-0x438(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x430(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xc82(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1538 <main+0x308>
lea    -0x410(%rbp),%rsi
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1552 <main+0x322>
lea    -0x410(%rbp),%rdi
lea    0xc58(%rip),%rsi
lea    -0x420(%rbp),%rdx
call   1130 <sscanf@plt>
mov    -0x430(%rbp),%rdi
call   10d0 <ftell@plt>
mov    %rax,-0x440(%rbp)
movsd  -0x420(%rbp),%xmm0
ff
subsd  -0x418(%rbp),%xmm0
ff
call   10b0 <fabs@plt>
ucomiss -0x46c(%rbp),%xmm0
jbe    163d <main+0x40d>
mov    -0x440(%rbp),%rax
sub    -0x438(%rbp),%rax
cmp    $0x0,%rax
jle    163d <main+0x40d>
cvttsd2si -0x418(%rbp),%eax
ff
mov    %eax,-0x484(%rbp)
lea    -0x460(%rbp),%rsi
lea    -0x484(%rbp),%rdi
call   1120 <ctime_r@plt>
movsd  -0x420(%rbp),%xmm0
ff
subsd  -0x418(%rbp),%xmm0
ff
movsd  -0x418(%rbp),%xmm1
ff
lea    -0x460(%rbp),%rsi
lea    0xbbc(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    -0x430(%rbp),%rdi
movsd  -0x420(%rbp),%xmm0
ff
mov    -0x440(%rbp),%rsi
sub    -0x438(%rbp),%rsi
call   1060 <copySplitData@plt>
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
call   10d0 <ftell@plt>
cmp    $0x0,%rax
jne    1631 <main+0x401>
jmp    1652 <main+0x422>
mov    -0x430(%rbp),%rdi
call   1080 <rewind@plt>
movsd  -0x420(%rbp),%xmm0
ff
movsd  %xmm0,-0x418(%rbp)
ff
jmp    14af <main+0x27f>
mov    -0x430(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
cmp    $0x3,%edi
jne    13e1 <main+0x1a1>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atof@plt>
mov    0x10(%rbx),%rbx
movss  %xmm0,0x18(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xd85(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
lea    0xda3(%rip),%rsi
mov    %rbx,%rdi
call   1150 <fopen@plt>
test   %rax,%rax
je     13f4 <main+0x1b4>
mov    %rax,%rbp
lea    0xda6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1100 <stat@plt>
xor    %eax,%eax
call   10d0 <tmpfile@plt>
test   %rax,%rax
je     140c <main+0x1cc>
mov    %rax,%rbx
lea    0x50(%rsp),%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   10b0 <fgets@plt>
mov    %rbp,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
jne    1328 <main+0xe8>
lea    0x50(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <fputs@plt>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   10b0 <fgets@plt>
mov    %rbp,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
je     1300 <main+0xc0>
mov    %rbx,%rdi
call   1120 <fflush@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1110 <fileno@plt>
lea    0x20(%rsp),%rsi
mov    %eax,%edi
call   1160 <fstat@plt>
mov    0x28(%rsp),%rsi
sub    0x20(%rsp),%rsi
je     1366 <main+0x126>
lea    0xd07(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1090 <rewind@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
jne    142b <main+0x1eb>
lea    0x50(%rsp),%rbp
lea    0xd2e(%rip),%r14
lea    0xd2a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1415 <main+0x1d5>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
je     13a0 <main+0x160>
jmp    142b <main+0x1eb>
lea    0xd3e(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    1442 <main+0x202>
lea    0xc34(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%eax
jmp    1442 <main+0x202>
lea    0xce4(%rip),%rdi
jmp    13e8 <main+0x1a8>
lea    0xcaf(%rip),%rsi
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rdx
call   1140 <sscanf@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
je     1454 <main+0x214>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x50(%rsp),%r14
lea    0xc59(%rip),%r15
lea    0x8(%rsp),%r12
jmp    1491 <main+0x251>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1090 <rewind@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
jne    1438 <main+0x1f8>
mov    %rbx,%rdi
call   10e0 <ftell@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14e0 <main+0x2a0>
mov    %r14,%rdi
lea    0xc00(%rip),%rsi
mov    %r12,%rdx
call   1140 <sscanf@plt>
jmp    14f1 <main+0x2b1>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xbd5(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   10e0 <ftell@plt>
mov    %rax,%r13
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
call   10c0 <fabs@plt>
ucomiss 0x18(%rsp),%xmm0
jbe    1478 <main+0x238>
sub    %rbp,%r13
jle    1478 <main+0x238>
cvttsd2si 0x10(%rsp),%eax
mov    %eax,0x1c(%rsp)
lea    0x1c(%rsp),%rdi
lea    0x30(%rsp),%rbp
mov    %rbp,%rsi
call   1130 <ctime_r@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
lea    0xb7b(%rip),%rdi
mov    %rbp,%rsi
mov    $0x2,%al
call   1080 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <copySplitData@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10e0 <ftell@plt>
test   %rax,%rax
jne    1470 <main+0x230>
jmp    1438 <main+0x1f8>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [163 x i8] c"\0A logsplitter - split a log file into smaller chunks, based on the consecutive timestamp difference\0A\0AUSAGE: logsplitter [min_time_difference_in_seconds] [FILE]\0A\0A\00"
@.str.1 = [44 x i8] c"I: Minimum time difference is: %f seconds.\0A\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [27 x i8] c"E: Opening %s ...[failed]\0A\00"
@.str.4 = [28 x i8] c"I: Opening %s ...[success]\0A\00"
@.str.5 = [48 x i8] c"E: Cannot create a temporary file! Aborting...\0A\00"
@.str.6 = [83 x i8] c"E: The temporary file differs than the original log file by %ld bytes! Aborting...\00"
@.str.7 = [3 x i8] c"##\00"
@.str.8 = [15 x i8] c"> ignoring: %s\00"
@.str.9 = [4 x i8] c"%lf\00"
@.str.10 = [40 x i8] c"I: Break (%f) needed after T = %f -> %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca double
%8 = alloca double
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
%13 = alloca [26 x i8]
%14 = alloca i8*
%15 = alloca float
%16 = alloca %struct.stat
%17 = alloca %struct.stat
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %171
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call float @atof(i8* %26)
store float %27, float* %15
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
store i8* %30, i8** %14
%31 = load float, float* %15
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %32)
%34 = load i8*, i8** %14
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %35, i32** %9
%36 = load i32*, i32** %9
%37 = icmp ne i32* %36, null
br i1 %37, label %41, label %38
38: ; preds = %23
%39 = load i8*, i8** %14
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %39)
store i32 -1, i32* %3
br label %171
41: ; preds = %23
%42 = load i8*, i8** %14
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41
%45 = load i8*, i8** %14
%46 = call i32 @stat(i8* %45, %struct.stat* %16)
%47 = call i32* (...) @tmpfile()
store i32* %47, i32** %10
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %171
51: ; preds = %44
br label %52
52: ; preds = %51, %60
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%54 = load i32*, i32** %9
%55 = call i32 @fgets(i8* %53, i32 1024, i32* %54)
%56 = load i32*, i32** %9
%57 = call i64 @feof(i32* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %52
br label %64
60: ; preds = %52
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%62 = load i32*, i32** %10
%63 = call i32 @fputs(i8* %61, i32* %62)
br label %52
64: ; preds = %59
%65 = load i32*, i32** %10
%66 = call i32 @fflush(i32* %65)
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %10
%70 = call i32 @fileno(i32* %69)
%71 = call i32 @fstat(i32 %70, %struct.stat* %17)
%72 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%73 = load i64, i64* %72
%74 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%75 = load i64, i64* %74
%76 = sub nsw i64 %73, %75
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %85
78: ; preds = %64
%79 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%80 = load i64, i64* %79
%81 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%82 = load i64, i64* %81
%83 = sub nsw i64 %80, %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.6, i64 0, i64 0), i64 %83)
br label %85
85: ; preds = %78, %64
%86 = load i32*, i32** %10
%87 = call i32 @rewind(i32* %86)
br label %88
88: ; preds = %106, %85
%89 = load i32*, i32** %10
%90 = call i64 @feof(i32* %89)
%91 = icmp ne i64 %90, 0
%92 = xor i1 %91, true
br i1 %92, label %93, label %107
93: ; preds = %88
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%95 = load i32*, i32** %10
%96 = call i32 @fgets(i8* %94, i32 1024, i32* %95)
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%98 = call i64 @strncmp(i8* %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %93
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %101)
br label %106
103: ; preds = %93
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%105 = call i32 @sscanf(i8* %104, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %7)
br label %107
106: ; preds = %100
br label %88
107: ; preds = %103, %88
br label %108
108: ; preds = %166, %107
%109 = load i32*, i32** %10
%110 = call i64 @feof(i32* %109)
%111 = icmp ne i64 %110, 0
%112 = xor i1 %111, true
br i1 %112, label %113, label %168
113: ; preds = %108
%114 = load i32*, i32** %10
%115 = call i64 @ftell(i32* %114)
store i64 %115, i64* %11
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%117 = load i32*, i32** %10
%118 = call i32 @fgets(i8* %116, i32 1024, i32* %117)
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%120 = call i64 @strncmp(i8* %119, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %113
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %123)
br label %128
125: ; preds = %113
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%127 = call i32 @sscanf(i8* %126, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %8)
br label %128
128: ; preds = %125, %122
%129 = load i32*, i32** %10
%130 = call i64 @ftell(i32* %129)
store i64 %130, i64* %12
%131 = load double, double* %8
%132 = load double, double* %7
%133 = fsub double %131, %132
%134 = call float @fabs(double %133)
%135 = load float, float* %15
%136 = fcmp ogt float %134, %135
br i1 %136, label %137, label %166
137: ; preds = %128
%138 = load i64, i64* %12
%139 = load i64, i64* %11
%140 = sub nsw i64 %138, %139
%141 = icmp sgt i64 %140, 0
br i1 %141, label %142, label %166
142: ; preds = %137
%143 = load double, double* %7
%144 = fptosi double %143 to i32
store i32 %144, i32* %18
%145 = getelementptr inbounds [26 x i8], [26 x i8]* %13, i64 0, i64 0
%146 = call i32 @ctime_r(i32* %18, i8* %145)
%147 = load double, double* %8
%148 = load double, double* %7
%149 = fsub double %147, %148
%150 = load double, double* %7
%151 = getelementptr inbounds [26 x i8], [26 x i8]* %13, i64 0, i64 0
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), double %149, double %150, i8* %151)
%153 = load i32*, i32** %10
%154 = load double, double* %8
%155 = load i64, i64* %12
%156 = load i64, i64* %11
%157 = sub nsw i64 %155, %156
%158 = call i32* @copySplitData(i32* %153, double %154, i64 %157)
store i32* %158, i32** %10
%159 = load i32*, i32** %10
%160 = call i64 @ftell(i32* %159)
%161 = icmp eq i64 %160, 0
br i1 %161, label %162, label %163
162: ; preds = %142
br label %168
163: ; preds = %142
%164 = load i32*, i32** %10
%165 = call i32 @rewind(i32* %164)
br label %166
166: ; preds = %163, %137, %128
%167 = load double, double* %8
store double %167, double* %7
br label %108
168: ; preds = %162, %108
%169 = load i32*, i32** %10
%170 = call i32 @fclose(i32* %169)
store i32 0, i32* %3
br label %171
171: ; preds = %168, %49, %38, %21
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str.1 = [44 x i8] c"I: Minimum time difference is: %f seconds.\0A\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [27 x i8] c"E: Opening %s ...[failed]\0A\00"
@.str.4 = [28 x i8] c"I: Opening %s ...[success]\0A\00"
@.str.6 = [83 x i8] c"E: The temporary file differs than the original log file by %ld bytes! Aborting...\00"
@.str.7 = [3 x i8] c"##\00"
@.str.8 = [15 x i8] c"> ignoring: %s\00"
@.str.9 = [4 x i8] c"%lf\00"
@.str.10 = [40 x i8] c"I: Break (%f) needed after T = %f -> %s\00"
@str = [47 x i8] c"E: Cannot create a temporary file! Aborting...\00"
@str.11 = [162 x i8] c"\0A logsplitter - split a log file into smaller chunks, based on the consecutive timestamp difference\0A\0AUSAGE: logsplitter [min_time_difference_in_seconds] [FILE]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca double
%5 = alloca double
%6 = alloca [26 x i8]
%7 = alloca %struct.stat
%8 = alloca %struct.stat
%9 = alloca i32
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = bitcast double* %4 to i8*
%12 = bitcast double* %5 to i8*
%13 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%14 = bitcast %struct.stat* %7 to i8*
%15 = bitcast %struct.stat* %8 to i8*
%16 = icmp eq i32 %0, 3
br i1 %16, label %19, label %17
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([162 x i8], [162 x i8]* @str.11, i64 0, i64 0))
br label %122
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call float @atof(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = fpext float %22 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %122
31: ; preds = %19
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%33 = call i32 @stat(i8* %24, %struct.stat* %7)
%34 = tail call i32* (...) @tmpfile()
%35 = icmp eq i32* %34, null
br i1 %35, label %40, label %36
36: ; preds = %31
%37 = call i32 @fgets(i8* %10, i32 1024, i32* %27)
%38 = call i64 @feof(i32* %27)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %47
40: ; preds = %31
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %122
42: ; preds = %36, %42
%43 = call i32 @fputs(i8* %10, i32* %34)
%44 = call i32 @fgets(i8* %10, i32 1024, i32* %27)
%45 = call i64 @feof(i32* %27)
%46 = icmp eq i64 %45, 0
br i1 %46, label %42, label %47
47: ; preds = %42, %36
%48 = call i32 @fflush(i32* %34)
%49 = call i32 @fclose(i32* %27)
%50 = call i32 @fileno(i32* %34)
%51 = call i32 @fstat(i32 %50, %struct.stat* %8)
%52 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 0
%55 = load i64, i64* %54
%56 = sub nsw i64 %53, %55
%57 = icmp eq i64 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %47
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @.str.6, i64 0, i64 0), i64 %56)
br label %60
60: ; preds = %58, %47
%61 = call i32 @rewind(i32* %34)
%62 = call i64 @feof(i32* %34)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %74
64: ; preds = %60, %68
%65 = call i32 @fgets(i8* %10, i32 1024, i32* %34)
%66 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %10)
%70 = call i64 @feof(i32* %34)
%71 = icmp eq i64 %70, 0
br i1 %71, label %64, label %74
72: ; preds = %64
%73 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %4)
br label %74
74: ; preds = %68, %60, %72
%75 = call i64 @feof(i32* %34)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %119
77: ; preds = %74
%78 = bitcast i32* %9 to i8*
br label %79
79: ; preds = %77, %114
%80 = phi i32* [ %34, %77 ], [ %115, %114 ]
%81 = call i64 @ftell(i32* %80)
%82 = call i32 @fgets(i8* %10, i32 1024, i32* %80)
%83 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %89
87: ; preds = %79
%88 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %5)
br label %89
89: ; preds = %87, %85
%90 = call i64 @ftell(i32* %80)
%91 = load double, double* %5
%92 = load double, double* %4
%93 = fsub double %91, %92
%94 = call float @fabs(double %93)
%95 = fcmp ogt float %94, %22
br i1 %95, label %96, label %114
96: ; preds = %89
%97 = sub nsw i64 %90, %81
%98 = icmp sgt i64 %97, 0
br i1 %98, label %99, label %114
99: ; preds = %96
%100 = load double, double* %4
%101 = fptosi double %100 to i32
store i32 %101, i32* %9
%102 = call i32 @ctime_r(i32* %9, i8* %13)
%103 = load double, double* %5
%104 = load double, double* %4
%105 = fsub double %103, %104
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), double %105, double %104, i8* %13)
%107 = load double, double* %5
%108 = call i32* @copySplitData(i32* %80, double %107, i64 %97)
%109 = call i64 @ftell(i32* %108)
%110 = icmp eq i64 %109, 0
br i1 %110, label %113, label %111
111: ; preds = %99
%112 = call i32 @rewind(i32* %108)
br label %114
113: ; preds = %99
br label %119
114: ; preds = %111, %96, %89
%115 = phi i32* [ %80, %96 ], [ %80, %89 ], [ %108, %111 ]
%116 = load double, double* %5
store double %116, double* %4
%117 = call i64 @feof(i32* %115)
%118 = icmp eq i64 %117, 0
br i1 %118, label %79, label %119
119: ; preds = %114, %74, %113
%120 = phi i32* [ %108, %113 ], [ %34, %74 ], [ %115, %114 ]
%121 = call i32 @fclose(i32* %120)
br label %122
122: ; preds = %119, %40, %29, %17
%123 = phi i32 [ -1, %17 ], [ -1, %40 ], [ 0, %119 ], [ -1, %29 ]
ret i32 %123
}