#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 endsInED(char *toCheck) {
  int len = strlen(toCheck);
  if (len <= 1)
    return -1;
  if (toCheck[len - 2] == 'E' && toCheck[len - 1] == 'D')
    return 1;
  return -1;
}


x86 assembly (clang, -O0):
<endsInED>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     113e <endsInED+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <endsInED+0x75>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x45,%eax
jne    117e <endsInED+0x6e>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x44,%eax
jne    117e <endsInED+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1185 <endsInED+0x75>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endsInED>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0xffffffff,%ecx
cmp    $0x2,%eax
jl     113f <endsInED+0x2f>
lea    -0x2(%rax),%ecx
cmpb   $0x45,(%rbx,%rcx,1)
jne    113a <endsInED+0x2a>
add    $0xffffffff,%eax
mov    $0x1,%ecx
cmpb   $0x44,(%rbx,%rax,1)
je     113f <endsInED+0x2f>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
pop    %rbx
ret

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

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