#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *split_space(char *);
char *strchr(char const *, char);
char *strrchr(char *, char const);
int readlog(FILE *fp, char filename[]) {
  const char *pattern = "()<>=";
  const char *tpattern = ")(><=";
  char *time, *mode;
  char *line;
  char *pat, *tpat;
  char *chan;
  char *nick;
  size_t fileline;
  char *r;
  char buf[1024];
  fileline = 0;
  while (fgets(buf, 1024, fp) != NULL) {
    fileline++;
    r = strrchr(buf, '\n');
    if (*r == '\n')
      *r = '\0';
    line = buf;
    time = line;
    if ((line = split_space(line)) == NULL)
      continue;
    printf("\033[1m"
           "\033[34m"
           "%s:%s ",
           filename, time);
    mode = line;
    if ((line = split_space(line)) == NULL)
      continue;
    pat = strchr(pattern, mode[0]);
    if (pat != NULL) {
      chan = &mode[1];
      tpat = strrchr(chan, tpattern[pat - pattern]);
      if (tpat == NULL) {
        goto DUMP;
        ;
      }
      tpat = '\0';
      tpat++;
      nick = strchr(chan, ':');
      printf("\033[1m"
             "\033[31m"
             "%c",
             *pat);
      if (nick) {
        nick = '\0';
        nick++;
        printf("%s:%s", chan, nick);
      } else {
        printf("%s", chan);
      }
      printf("%c"
             "\033[0m",
             *tpat);
      printf(" ");
      printf("\033[39m"
             "%s"
             "\033[0m",
             line);
    } else {
    DUMP:
      printf("\033[1m"
             "\033[32m"
             "%s %s",
             mode, line);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<readlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe91(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x60(%rbp)
lea    -0x470(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     138b <readlog+0x23b>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
lea    -0x470(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11d8 <readlog+0x88>
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x470(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <split_space@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1207 <readlog+0xb7>
jmp    1181 <readlog+0x31>
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <split_space@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1241 <readlog+0xf1>
jmp    1181 <readlog+0x31>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     135d <readlog+0x20d>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    129c <readlog+0x14c>
jmp    1362 <readlog+0x212>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%esi
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x58(%rbp)
je     1311 <readlog+0x1c1>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1323 <readlog+0x1d3>
mov    -0x50(%rbp),%rsi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rax
movsbl (%rax),%esi
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1378 <readlog+0x228>
jmp    1362 <readlog+0x212>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1181 <readlog+0x31>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readlog>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1308 <readlog+0x1a8>
lea    0x10(%rsp),%r15
lea    0xe60(%rip),%r14
mov    %rbx,(%rsp)
jmp    11ee <readlog+0x8e>
cs nopw 0x0(%rax,%rax,1)
lea    0xe8a(%rip),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%r14
mov    (%rsp),%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1308 <readlog+0x1a8>
mov    %r15,%rdi
mov    $0xa,%esi
call   1060 <strrchr@plt>
cmpb   $0xa,(%rax)
jne    1203 <readlog+0xa3>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1080 <split_space@plt>
test   %rax,%rax
je     11d5 <readlog+0x75>
mov    %rax,%r12
lea    0xdf2(%rip),%rdi
mov    0x8(%rsp),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1080 <split_space@plt>
test   %rax,%rax
je     11d5 <readlog+0x75>
mov    %rax,%rbp
movsbl (%r12),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
mov    %r14,%rbx
test   %rax,%rax
je     11b0 <readlog+0x50>
mov    %rax,%r14
mov    %r12,%r13
add    $0x1,%r13
sub    %rbx,%rax
lea    0xda0(%rip),%rcx
movsbl (%rax,%rcx,1),%esi
mov    %r13,%rdi
call   1060 <strrchr@plt>
test   %rax,%rax
je     11b0 <readlog+0x50>
mov    %r13,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,%r12
movsbl (%r14),%esi
lea    0xd86(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12,%r12
je     12ba <readlog+0x15a>
mov    $0x1,%edx
lea    0xd7a(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12cb <readlog+0x16b>
lea    0xd8c(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%r14
mov    (%rsp),%rbx
movsbl 0x1,%esi
lea    0xd4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xd3c(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cb <readlog+0x6b>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"()<>=\00"
@.str.1 = [6 x i8] c")(><=\00"
@.str.2 = [16 x i8] c"\1B[1m\1B[34m%s:%s \00"
@.str.3 = [12 x i8] c"\1B[1m\1B[31m%c\00"
@.str.4 = [6 x i8] c"%s:%s\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [7 x i8] c"%c\1B[0m\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [12 x i8] c"\1B[39m%s\1B[0m\00"
@.str.9 = [15 x i8] c"\1B[1m\1B[32m%s %s\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @readlog(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca [1024 x i8]
store i32* %0, i32** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i64 0, i64* %14
br label %17
17: ; preds = %106, %48, %39, %2
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i32* @fgets(i8* %18, i32 1024, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %108
22: ; preds = %17
%23 = load i64, i64* %14
%24 = add i64 %23, 1
store i64 %24, i64* %14
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%26 = call i8* @strrchr(i8* %25, i8 signext 10)
store i8* %26, i8** %15
%27 = load i8*, i8** %15
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %33
31: ; preds = %22
%32 = load i8*, i8** %15
store i8 0, i8* %32
br label %33
33: ; preds = %31, %22
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
store i8* %34, i8** %9
%35 = load i8*, i8** %9
store i8* %35, i8** %7
%36 = load i8*, i8** %9
%37 = call i8* @split_space(i8* %36)
store i8* %37, i8** %9
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %40
39: ; preds = %33
br label %17
40: ; preds = %33
%41 = load i8*, i8** %4
%42 = load i8*, i8** %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* %42)
%44 = load i8*, i8** %9
store i8* %44, i8** %8
%45 = load i8*, i8** %9
%46 = call i8* @split_space(i8* %45)
store i8* %46, i8** %9
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %40
br label %17
49: ; preds = %40
%50 = load i8*, i8** %5
%51 = load i8*, i8** %8
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = call i8* @strchr(i8* %50, i8 signext %53)
store i8* %54, i8** %10
%55 = load i8*, i8** %10
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %101
57: ; preds = %49
%58 = load i8*, i8** %8
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8* %59, i8** %12
%60 = load i8*, i8** %12
%61 = load i8*, i8** %6
%62 = load i8*, i8** %10
%63 = load i8*, i8** %5
%64 = ptrtoint i8* %62 to i64
%65 = ptrtoint i8* %63 to i64
%66 = sub i64 %64, %65
%67 = getelementptr inbounds i8, i8* %61, i64 %66
%68 = load i8, i8* %67
%69 = call i8* @strrchr(i8* %60, i8 signext %68)
store i8* %69, i8** %11
%70 = load i8*, i8** %11
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %73
72: ; preds = %57
br label %102
73: ; preds = %57
store i8* null, i8** %11
%74 = load i8*, i8** %11
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %11
%76 = load i8*, i8** %12
%77 = call i8* @strchr(i8* %76, i8 signext 58)
store i8* %77, i8** %13
%78 = load i8*, i8** %10
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %80)
%82 = load i8*, i8** %13
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %90
84: ; preds = %73
store i8* null, i8** %13
%85 = load i8*, i8** %13
%86 = getelementptr inbounds i8, i8* %85, i32 1
store i8* %86, i8** %13
%87 = load i8*, i8** %12
%88 = load i8*, i8** %13
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %87, i8* %88)
br label %93
90: ; preds = %73
%91 = load i8*, i8** %12
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %90, %84
%94 = load i8*, i8** %11
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%99 = load i8*, i8** %9
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %99)
br label %106
101: ; preds = %49
br label %102
102: ; preds = %101, %72
%103 = load i8*, i8** %8
%104 = load i8*, i8** %9
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %103, i8* %104)
br label %106
106: ; preds = %102, %93
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %17
108: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"()<>=\00"
@.str.1 = [6 x i8] c")(><=\00"
@.str.2 = [16 x i8] c"\1B[1m\1B[34m%s:%s \00"
@.str.3 = [12 x i8] c"\1B[1m\1B[31m%c\00"
@.str.4 = [6 x i8] c"%s:%s\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [7 x i8] c"%c\1B[0m\00"
@.str.8 = [12 x i8] c"\1B[39m%s\1B[0m\00"
@.str.9 = [15 x i8] c"\1B[1m\1B[32m%s %s\00"
define i32 @readlog(i32* nocapture %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 1024, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %54, label %7
7: ; preds = %2, %51
%8 = call i8* @strrchr(i8* %4, i8 signext 10)
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %12
11: ; preds = %7
store i8 0, i8* %8
br label %12
12: ; preds = %11, %7
%13 = call i8* @split_space(i8* %4)
%14 = icmp eq i8* %13, null
br i1 %14, label %51, label %15
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %4)
%17 = call i8* @split_space(i8* %13)
%18 = icmp eq i8* %17, null
br i1 %18, label %51, label %19
19: ; preds = %15
%20 = load i8, i8* %13
%21 = call i8* @strchr(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %47, label %23
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %13, i64 1
%25 = ptrtoint i8* %21 to i64
%26 = sub i64 %25, ptrtoint ([6 x i8]* @.str to i64)
%27 = getelementptr inbounds [6 x i8], [6 x i8]* @.str.1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i8* @strrchr(i8* %24, i8 signext %28)
%30 = icmp eq i8* %29, null
br i1 %30, label %47, label %31
31: ; preds = %23
%32 = call i8* @strchr(i8* %24, i8 signext 58)
%33 = load i8, i8* %21
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = icmp eq i8* %32, null
br i1 %36, label %39, label %37
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %24, i8* inttoptr (i64 1 to i8*))
br label %41
39: ; preds = %31
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %24)
br label %41
41: ; preds = %39, %37
%42 = load i8, i8* inttoptr (i64 1 to i8*)
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = call i32 @putchar(i32 32)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %17)
br label %49
47: ; preds = %19, %23
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %13, i8* %17)
br label %49
49: ; preds = %47, %41
%50 = call i32 @putchar(i32 10)
br label %51
51: ; preds = %49, %12, %15
%52 = call i32* @fgets(i8* %4, i32 1024, i32* %0)
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %7
54: ; preds = %51, %2
ret i32 0
}