#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 */
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int find_number_of_suffixs(char **strings, int size) {
  int i = 0;
  int count = 0;
  for (; i < size; ++i) {
    int lensuffix = strlen("an");
    int lenstr = strlen(strings[i]);
    if (lensuffix > lenstr) {
      continue;
    }
    if (strncmp(strings[i] + lenstr - lensuffix, "an", lensuffix) == 0) {
      count++;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<find_number_of_suffixs>:
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    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d1 <find_number_of_suffixs+0xb1>
lea    0xeb0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    117d <find_number_of_suffixs+0x5d>
jmp    11c3 <find_number_of_suffixs+0xa3>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
movslq -0x18(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%edx
lea    0xe5a(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11be <find_number_of_suffixs+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <find_number_of_suffixs+0xa3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <find_number_of_suffixs+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_number_of_suffixs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1193 <find_number_of_suffixs+0x73>
mov    %rdi,%r13
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xec2(%rip),%r14
xor    %r15d,%r15d
jmp    1159 <find_number_of_suffixs+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1196 <find_number_of_suffixs+0x76>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    0x0(%r13,%rbx,8),%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jg     1150 <find_number_of_suffixs+0x30>
movslq %eax,%rdi
add    0x0(%r13,%rbx,8),%rdi
movslq %ebp,%rax
sub    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%rax
adc    $0x0,%r15d
jmp    1150 <find_number_of_suffixs+0x30>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"an\00"
define i32 @find_number_of_suffixs(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %45, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %48
13: ; preds = %9
%14 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %7
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %13
br label %45
25: ; preds = %13
%26 = load i8**, i8*** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = sub i64 0, %35
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i32, i32* %7
%39 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %25
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %44
44: ; preds = %41, %25
br label %45
45: ; preds = %44, %24
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %9
48: ; preds = %9
%49 = load i32, i32* %6
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"an\00"
define i32 @find_number_of_suffixs(i8** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %25
%7 = phi i64 [ 0, %4 ], [ %27, %25 ]
%8 = phi i32 [ 0, %4 ], [ %26, %25 ]
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %0, i64 %7
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %9, %12
br i1 %13, label %25, label %14
14: ; preds = %6
%15 = load i8*, i8** %10
%16 = sext i32 %12 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = sext i32 %9 to i64
%19 = sub nsw i64 0, %18
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = add nsw i32 %8, %23
br label %25
25: ; preds = %6, %14
%26 = phi i32 [ %24, %14 ], [ %8, %6 ]
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, %5
br i1 %28, label %29, label %6
29: ; preds = %25, %2
%30 = phi i32 [ 0, %2 ], [ %26, %25 ]
ret i32 %30
}