#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ parseQmailFromBytesLine(char *, int /*<<< orphan*/);
int /*<<< orphan*/ parseQmailToLocalLine(char *, int /*<<< orphan*/);
int /*<<< orphan*/ parseQmailToRemoteLine(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
scalar_t__ timeconvert(char *, int, int, int, int, int *);
void readSpecialLogFile(char *fn, int year, int month, int day) {
  FILE *fp = NULL;
  char buf[1024];
  int i = 0;
  if ((fp = fopen(fn, "r")) == NULL) {
    fprintf(stderr, "open file: %s %s\n", fn, strerror(errno));
    exit(-1);
  }
  while ((fgets(buf, 1024, fp)) != NULL)
    if ((timeconvert(buf, 1024, year, month, day, &i)) > 0) {
      if ((strstr(buf, " from ")) != NULL)
        parseQmailFromBytesLine(buf, strlen(buf));
      else if ((strstr(buf, " to remote")) != NULL)
        parseQmailToRemoteLine(buf, strlen(buf));
      else if ((strstr(buf, " to local")) != NULL)
        parseQmailToLocalLine(buf, strlen(buf));
    }
  fclose(fp);
}


x86 assembly (clang, -O0):
<readSpecialLogFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x424(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1256 <readSpecialLogFile+0x96>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x434(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rdx
mov    %rax,%rcx
lea    0xdbb(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
jmp    125b <readSpecialLogFile+0x9b>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1393 <readSpecialLogFile+0x1d3>
lea    -0x420(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    $0x400,%esi
lea    -0x424(%rbp),%r9
call   1080 <timeconvert@plt>
cmp    $0x0,%rax
jle    138e <readSpecialLogFile+0x1ce>
lea    -0x420(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     12f0 <readSpecialLogFile+0x130>
lea    -0x420(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x440(%rbp),%rdi
mov    %eax,%esi
call   1070 <parseQmailFromBytesLine@plt>
jmp    1389 <readSpecialLogFile+0x1c9>
lea    -0x420(%rbp),%rdi
lea    0xd1d(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     133a <readSpecialLogFile+0x17a>
lea    -0x420(%rbp),%rax
mov    %rax,-0x448(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x448(%rbp),%rdi
mov    %eax,%esi
call   1090 <parseQmailToRemoteLine@plt>
jmp    1384 <readSpecialLogFile+0x1c4>
lea    -0x420(%rbp),%rdi
lea    0xcde(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     137f <readSpecialLogFile+0x1bf>
lea    -0x420(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x450(%rbp),%rdi
mov    %eax,%esi
call   10b0 <parseQmailToLocalLine@plt>
jmp    1384 <readSpecialLogFile+0x1c4>
jmp    1389 <readSpecialLogFile+0x1c9>
jmp    138e <readSpecialLogFile+0x1ce>
jmp    125b <readSpecialLogFile+0x9b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readSpecialLogFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xe14(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12f8 <readSpecialLogFile+0x138>
mov    %rax,%rbp
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12de <readSpecialLogFile+0x11e>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r13
jmp    1258 <readSpecialLogFile+0x98>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <parseQmailFromBytesLine@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12de <readSpecialLogFile+0x11e>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
mov    %r13,%r9
call   1080 <timeconvert@plt>
test   %rax,%rax
jle    123f <readSpecialLogFile+0x7f>
mov    %rbx,%rdi
lea    0xd94(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rbx,%rdi
test   %rax,%rax
jne    1230 <readSpecialLogFile+0x70>
lea    0xd87(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     12b2 <readSpecialLogFile+0xf2>
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <parseQmailToRemoteLine@plt>
jmp    123f <readSpecialLogFile+0x7f>
lea    0xd6d(%rip),%rsi
call   10e0 <strstr@plt>
test   %rax,%rax
je     123f <readSpecialLogFile+0x7f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10b0 <parseQmailToLocalLine@plt>
jmp    123f <readSpecialLogFile+0x7f>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ce1(%rip),%rax
mov    (%rax),%ebp
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcec(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"open file: %s %s\0A\00"
@errno = global i32 0
@.str.2 = [7 x i8] c" from \00"
@.str.3 = [11 x i8] c" to remote\00"
@.str.4 = [10 x i8] c" to local\00"
define void @readSpecialLogFile(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [1024 x i8]
%11 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32* null, i32** %9
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %22
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %5
%18 = load i32, i32* @errno
%19 = call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %4
br label %23
23: ; preds = %65, %22
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%25 = load i32*, i32** %9
%26 = call i32* @fgets(i8* %24, i32 1024, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %66
28: ; preds = %23
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i64 @timeconvert(i8* %29, i32 1024, i32 %30, i32 %31, i32 %32, i32* %11)
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %65
35: ; preds = %28
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%37 = call i32* @strstr(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
%43 = call i32 @parseQmailFromBytesLine(i8* %40, i32 %42)
br label %64
44: ; preds = %35
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%46 = call i32* @strstr(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = call i32 @parseQmailToRemoteLine(i8* %49, i32 %51)
br label %63
53: ; preds = %44
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%55 = call i32* @strstr(i8* %54, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%56 = icmp ne i32* %55, null
br i1 %56, label %57, label %62
57: ; preds = %53
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @parseQmailToLocalLine(i8* %58, i32 %60)
br label %62
62: ; preds = %57, %53
br label %63
63: ; preds = %62, %48
br label %64
64: ; preds = %63, %39
br label %65
65: ; preds = %64, %28
br label %23
66: ; preds = %23
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"open file: %s %s\0A\00"
@errno = global i32 0
@.str.2 = [7 x i8] c" from \00"
@.str.3 = [11 x i8] c" to remote\00"
@.str.4 = [10 x i8] c" to local\00"
define void @readSpecialLogFile(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = call i32* @fgets(i8* %7, i32 1024, i32* %9)
%13 = icmp eq i32* %12, null
br i1 %13, label %44, label %20
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %17)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %11, %41
%21 = call i64 @timeconvert(i8* %7, i32 1024, i32 %1, i32 %2, i32 %3, i32* %6)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %41
23: ; preds = %20
%24 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i32 @strlen(i8* %7)
%28 = call i32 @parseQmailFromBytesLine(i8* %7, i32 %27)
br label %41
29: ; preds = %23
%30 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = call i32 @strlen(i8* %7)
%34 = call i32 @parseQmailToRemoteLine(i8* %7, i32 %33)
br label %41
35: ; preds = %29
%36 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = call i32 @strlen(i8* %7)
%40 = call i32 @parseQmailToLocalLine(i8* %7, i32 %39)
br label %41
41: ; preds = %26, %35, %38, %32, %20
%42 = call i32* @fgets(i8* %7, i32 1024, i32* %9)
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %20
44: ; preds = %41, %11
%45 = call i32 @fclose(i32* %9)
ret void
}