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

/* Variables and functions */
scalar_t__ strncmp(char *, char *, int);
unsigned int find_repetition_score(char *line, unsigned int size) {
  unsigned int rep_score = 0;
  for (unsigned int i = 0; i < size; i += 32) {
    for (unsigned int j = i + 32; j < (size - 32); j += 32) {
      if (strncmp(line + i, line + j, 32) == 0) {
        rep_score++;
      }
    }
  }
  return rep_score;
}


x86 assembly (clang, -O0):
<find_repetition_score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11aa <find_repetition_score+0x9a>
mov    -0x14(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x20,%ecx
cmp    %ecx,%eax
jae    1197 <find_repetition_score+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%eax
add    %rax,%rsi
mov    $0x20,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1184 <find_repetition_score+0x74>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1189 <find_repetition_score+0x79>
mov    -0x18(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <find_repetition_score+0x32>
jmp    119c <find_repetition_score+0x8c>
mov    -0x14(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <find_repetition_score+0x1d>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_repetition_score>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1185 <find_repetition_score+0x75>
mov    %rdi,%r15
lea    -0x20(%rsi),%r12d
xor    %r14d,%r14d
xor    %ebp,%ebp
mov    %rsi,(%rsp)
jmp    1149 <find_repetition_score+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rsi
cmp    %esi,%r14d
jae    1187 <find_repetition_score+0x77>
mov    %r14d,%eax
lea    0x20(%rax),%r14d
cmp    %r12d,%r14d
jae    1140 <find_repetition_score+0x30>
mov    %eax,%ebx
add    %r15,%rbx
mov    %r14d,%r13d
nopl   (%rax)
mov    %r13d,%esi
add    %r15,%rsi
mov    %rbx,%rdi
mov    $0x20,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%rax
adc    $0x0,%ebp
add    $0x20,%r13d
cmp    %r12d,%r13d
jb     1160 <find_repetition_score+0x50>
jmp    1140 <find_repetition_score+0x30>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_repetition_score(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %39, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %42
12: ; preds = %8
%13 = load i32, i32* %6
%14 = add i32 %13, 32
store i32 %14, i32* %7
br label %15
15: ; preds = %35, %12
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = sub i32 %17, 32
%19 = icmp ult i32 %16, %18
br i1 %19, label %20, label %38
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i32, i32* %6
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8*, i8** %3
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = call i64 @strncmp(i8* %24, i8* %28, i32 32)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %20
%32 = load i32, i32* %5
%33 = add i32 %32, 1
store i32 %33, i32* %5
br label %34
34: ; preds = %31, %20
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add i32 %36, 32
store i32 %37, i32* %7
br label %15
38: ; preds = %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %6
%41 = add i32 %40, 32
store i32 %41, i32* %6
br label %8
42: ; preds = %8
%43 = load i32, i32* %5
ret i32 %43
}

LLVM IR (-O2):
define i32 @find_repetition_score(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = add i32 %1, -32
br label %11
6: ; preds = %19, %11
%7 = phi i32 [ %13, %11 ], [ %27, %19 ]
%8 = icmp ult i32 %14, %1
br i1 %8, label %11, label %9
9: ; preds = %6, %2
%10 = phi i32 [ 0, %2 ], [ %7, %6 ]
ret i32 %10
11: ; preds = %4, %6
%12 = phi i32 [ 0, %4 ], [ %14, %6 ]
%13 = phi i32 [ 0, %4 ], [ %7, %6 ]
%14 = add i32 %12, 32
%15 = icmp ult i32 %14, %5
br i1 %15, label %16, label %6
16: ; preds = %11
%17 = zext i32 %12 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
br label %19
19: ; preds = %16, %19
%20 = phi i32 [ %14, %16 ], [ %28, %19 ]
%21 = phi i32 [ %13, %16 ], [ %27, %19 ]
%22 = zext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = tail call i64 @strncmp(i8* %18, i8* %23, i32 32)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
%27 = add i32 %21, %26
%28 = add i32 %20, 32
%29 = icmp ult i32 %28, %5
br i1 %29, label %19, label %6
}