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

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
unsigned int find_repetition_score(char *, unsigned int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
unsigned int strlen(char *);
int main() {
  char line[512];
  char possible_line[512];
  unsigned int max_repetition_score = 0;
  FILE *file = fopen("8.txt", "r");
  while (fgets(line, sizeof(line), file)) {
    unsigned int line_size = strlen(line);
    unsigned int current_repetition_score =
        find_repetition_score(line, line_size);
    if (current_repetition_score > max_repetition_score) {
      strcpy(possible_line, line);
      max_repetition_score = current_repetition_score;
    }
  }
  if (max_repetition_score > 0) {
    printf("%s", possible_line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x414(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x420(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x420(%rbp),%rdx
mov    $0x200,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1218 <main+0xb8>
lea    -0x210(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x424(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x424(%rbp),%esi
call   1040 <find_repetition_score@plt>
mov    %eax,-0x428(%rbp)
mov    -0x428(%rbp),%eax
cmp    -0x414(%rbp),%eax
jbe    1213 <main+0xb3>
lea    -0x410(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x428(%rbp),%eax
mov    %eax,-0x414(%rbp)
jmp    1196 <main+0x36>
cmpl   $0x0,-0x414(%rbp)
jbe    1238 <main+0xd8>
lea    -0x410(%rbp),%rsi
lea    0xdd5(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
lea    0xe8a(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0x200(%rsp),%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1202 <main+0xa2>
xor    %r12d,%r12d
lea    0x200(%rsp),%rbx
mov    %rsp,%r15
jmp    11c5 <main+0x65>
nop
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11ee <main+0x8e>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <find_repetition_score@plt>
cmp    %r12d,%eax
jbe    11b0 <main+0x50>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %ebp,%r12d
jmp    11b0 <main+0x50>
test   %r12d,%r12d
je     1202 <main+0xa2>
lea    0xe0e(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"8.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%8 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %5
br label %9
9: ; preds = %28, %0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %5
%12 = call i64 @fgets(i8* %10, i32 512, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %6
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* %6
%19 = call i32 @find_repetition_score(i8* %17, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp ugt i32 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i32, i32* %7
store i32 %27, i32* %4
br label %28
28: ; preds = %23, %14
br label %9
29: ; preds = %9
%30 = load i32, i32* %4
%31 = icmp ugt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %32, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"8.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i64 @fgets(i8* %3, i32 512, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %0, %15
%9 = phi i32 [ %16, %15 ], [ 0, %0 ]
%10 = call i32 @strlen(i8* %3)
%11 = call i32 @find_repetition_score(i8* %3, i32 %10)
%12 = icmp ugt i32 %11, %9
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @strcpy(i8* %4, i8* %3)
br label %15
15: ; preds = %13, %8
%16 = phi i32 [ %11, %13 ], [ %9, %8 ]
%17 = call i64 @fgets(i8* %3, i32 512, i32* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %8
19: ; preds = %15
%20 = icmp eq i32 %16, 0
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %23
23: ; preds = %0, %21, %19
ret i32 0
}