#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 */
char *score_one(char *, char const *, char *, char *);
int strlen(char *);
void find_and_score_matches(char *filenames, char *filenames_end, char *pat) {
  char *pat_end = pat + (strlen(pat) - 1);
  const char *filenames_pos = filenames_end;
  while (filenames_pos >= filenames) {
    filenames_pos = score_one(filenames, filenames_pos, pat, pat_end);
  }
}


x86 assembly (clang, -O0):
<find_and_score_matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     118c <find_and_score_matches+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <score_one@plt>
mov    %rax,-0x28(%rbp)
jmp    1160 <find_and_score_matches+0x40>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_and_score_matches>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <strlen@plt>
cmp    %r15,%rbx
jb     1169 <find_and_score_matches+0x49>
cltq
lea    (%rax,%r14,1),%r12
add    $0xffffffffffffffff,%r12
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1040 <score_one@plt>
mov    %rax,%rbx
cmp    %r15,%rax
jae    1150 <find_and_score_matches+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @find_and_score_matches(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
store i8* %14, i8** %7
%15 = load i8*, i8** %5
store i8* %15, i8** %8
br label %16
16: ; preds = %20, %3
%17 = load i8*, i8** %8
%18 = load i8*, i8** %4
%19 = icmp uge i8* %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i8*, i8** %8
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = call i8* @score_one(i8* %21, i8* %22, i8* %23, i8* %24)
store i8* %25, i8** %8
br label %16
26: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @find_and_score_matches(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %2, i64 %6
%8 = icmp ult i8* %1, %0
br i1 %8, label %13, label %9
9: ; preds = %3, %9
%10 = phi i8* [ %11, %9 ], [ %1, %3 ]
%11 = tail call i8* @score_one(i8* %0, i8* %10, i8* %2, i8* %7)
%12 = icmp ult i8* %11, %0
br i1 %12, label %13, label %9
13: ; preds = %9, %3
ret void
}