#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 *);
int isendword(char *w, char *ENDCHARS, int len) {
  char c = w[strlen(w) - 1];
  while (len-- > 0) {
    if (c == ENDCHARS[len])
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isendword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1183 <isendword+0x73>
movsbl -0x1d(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    117e <isendword+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    118a <isendword+0x7a>
jmp    1146 <isendword+0x36>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isendword>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <strlen@plt>
cltq
mov    -0x1(%rax,%rbp,1),%al
mov    %r14d,%ecx
nopl   0x0(%rax,%rax,1)
test   %ecx,%ecx
jle    1148 <isendword+0x38>
lea    -0x1(%rcx),%rdx
cmp    -0x1(%rbx,%rcx,1),%al
mov    %rdx,%rcx
jne    1130 <isendword+0x20>
mov    $0x1,%eax
jmp    114a <isendword+0x3a>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isendword(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %5
%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
%15 = load i8, i8* %14
store i8 %15, i8* %8
br label %16
16: ; preds = %31, %3
%17 = load i32, i32* %7
%18 = add nsw i32 %17, -1
store i32 %18, i32* %7
%19 = icmp sgt i32 %17, 0
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i8, i8* %8
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %22, %28
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 1, i32* %4
br label %33
31: ; preds = %20
br label %16
32: ; preds = %16
store i32 0, i32* %4
br label %33
33: ; preds = %32, %30
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @isendword(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %15, %3
%11 = phi i64 [ %12, %15 ], [ %9, %3 ]
%12 = add nsw i64 %11, -1
%13 = trunc i64 %11 to i32
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %1, i64 %12
%17 = load i8, i8* %16
%18 = icmp eq i8 %8, %17
br i1 %18, label %19, label %10
19: ; preds = %10, %15
%20 = phi i32 [ 1, %15 ], [ 0, %10 ]
ret i32 %20
}