#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 *);
void readQmailLogFile(char *fn) {
  FILE *fp = NULL;
  char buf[1024];
  if ((fp = fopen(fn, "r")) == NULL) {
    fprintf(stderr, "fopen: %s: %s\n", fn, strerror(errno));
    exit(-1);
  }
  while ((fgets(buf, 1024, fp)) != NULL) {
    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):
<readQmailLogFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1233 <readQmailLogFile+0x83>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x41c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x41c(%rbp),%edi
mov    -0x418(%rbp),%rdx
mov    %rax,%rcx
lea    0xdde(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
jmp    1238 <readQmailLogFile+0x88>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     133f <readQmailLogFile+0x18f>
lea    -0x410(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     12a1 <readQmailLogFile+0xf1>
lea    -0x410(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x428(%rbp),%rdi
mov    %eax,%esi
call   1070 <parseQmailFromBytesLine@plt>
jmp    133a <readQmailLogFile+0x18a>
lea    -0x410(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     12eb <readQmailLogFile+0x13b>
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x430(%rbp),%rdi
mov    %eax,%esi
call   1080 <parseQmailToRemoteLine@plt>
jmp    1335 <readQmailLogFile+0x185>
lea    -0x410(%rbp),%rdi
lea    0xd2b(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     1330 <readQmailLogFile+0x180>
lea    -0x410(%rbp),%rax
mov    %rax,-0x438(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x438(%rbp),%rdi
mov    %eax,%esi
call   10a0 <parseQmailToLocalLine@plt>
jmp    1335 <readQmailLogFile+0x185>
jmp    133a <readQmailLogFile+0x18a>
jmp    1238 <readQmailLogFile+0x88>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readQmailLogFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
lea    0xe35(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a3 <readQmailLogFile+0xf3>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1289 <readQmailLogFile+0xd9>
lea    0xe15(%rip),%r14
mov    %rsp,%rbx
lea    0xe12(%rip),%r12
lea    0xe17(%rip),%r13
jmp    1234 <readQmailLogFile+0x84>
nop
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <parseQmailFromBytesLine@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1289 <readQmailLogFile+0xd9>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10d0 <strstr@plt>
mov    %rbx,%rdi
test   %rax,%rax
jne    1210 <readQmailLogFile+0x60>
mov    %r12,%rsi
call   10d0 <strstr@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1268 <readQmailLogFile+0xb8>
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <parseQmailToRemoteLine@plt>
jmp    121f <readQmailLogFile+0x6f>
mov    %r13,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     121f <readQmailLogFile+0x6f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <parseQmailToLocalLine@plt>
jmp    121f <readQmailLogFile+0x6f>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d36(%rip),%rax
mov    (%rax),%ebp
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd41(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

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

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