#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 const *);
int /*<<< orphan*/ strncmp(char const *, char const *, int);
int airEndsWith(const char *s, const char *suff) {
  if (!(s && suff))
    return 0;
  if (!(strlen(s) >= strlen(suff)))
    return 0;
  if (!strncmp(s + strlen(s) - strlen(suff), suff, strlen(suff)))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<airEndsWith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <airEndsWith+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <airEndsWith+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11fb <airEndsWith+0xdb>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1180 <airEndsWith+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11fb <airEndsWith+0xdb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11f4 <airEndsWith+0xd4>
movl   $0x1,-0x4(%rbp)
jmp    11fb <airEndsWith+0xdb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<airEndsWith>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1186 <airEndsWith+0x66>
mov    %rsi,%r14
test   %rsi,%rsi
je     1186 <airEndsWith+0x66>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jl     1186 <airEndsWith+0x66>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
sub    %rax,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @airEndsWith(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = icmp slt i32 %7, %8
br i1 %9, label %22, label %10
10: ; preds = %6
%11 = tail call i32 @strlen(i8* %0)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = tail call i32 @strlen(i8* %1)
%15 = sext i32 %14 to i64
%16 = sub nsw i64 0, %15
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = tail call i32 @strlen(i8* %1)
%19 = tail call i32 @strncmp(i8* %17, i8* %1, i32 %18)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %10, %6, %2
%23 = phi i32 [ 0, %2 ], [ 0, %6 ], [ %21, %10 ]
ret i32 %23
}