#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 /*<<< orphan*/ assert(int);
scalar_t__ endswith(char *, char *);
void test_endswith(void) {
  char *filename1 = "Makefile";
  char *filename2 = "autogen.sh";
  char *filename3 = "/Project/settings/__init__.py";
  char *suffix1 = "Makefile";
  char *suffix2 = "settings/__init__.py";
  assert(0 < endswith(filename1, suffix1));
  assert(0 == endswith(filename1, suffix2));
  assert(0 == endswith(filename2, suffix1));
  assert(0 == endswith(filename2, suffix2));
  assert(0 == endswith(filename3, suffix1));
  assert(0 < endswith(filename3, suffix2));
}


x86 assembly (clang, -O0):
<test_endswith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xecf(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xecf(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec2(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <endswith@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_endswith>:
push   %r15
push   %r14
push   %rbx
lea    0xed4(%rip),%r15
mov    %r15,%rdi
mov    %r15,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1040 <assert@plt>
lea    0xed1(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe6f(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <endswith@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Makefile\00"
@.str.1 = [11 x i8] c"autogen.sh\00"
@.str.2 = [30 x i8] c"/Project/settings/__init__.py\00"
@.str.3 = [21 x i8] c"settings/__init__.py\00"
define void @test_endswith() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %5
%6 = load i8*, i8** %1
%7 = load i8*, i8** %4
%8 = call i64 @endswith(i8* %6, i8* %7)
%9 = icmp slt i64 0, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %1
%13 = load i8*, i8** %5
%14 = call i64 @endswith(i8* %12, i8* %13)
%15 = icmp eq i64 0, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %2
%19 = load i8*, i8** %4
%20 = call i64 @endswith(i8* %18, i8* %19)
%21 = icmp eq i64 0, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %2
%25 = load i8*, i8** %5
%26 = call i64 @endswith(i8* %24, i8* %25)
%27 = icmp eq i64 0, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8*, i8** %3
%31 = load i8*, i8** %4
%32 = call i64 @endswith(i8* %30, i8* %31)
%33 = icmp eq i64 0, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i8*, i8** %3
%37 = load i8*, i8** %5
%38 = call i64 @endswith(i8* %36, i8* %37)
%39 = icmp slt i64 0, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Makefile\00"
@.str.1 = [11 x i8] c"autogen.sh\00"
@.str.2 = [30 x i8] c"/Project/settings/__init__.py\00"
@.str.3 = [21 x i8] c"settings/__init__.py\00"
define void @test_endswith() {
%1 = tail call i64 @endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = icmp sgt i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i64 @endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i64 @endswith(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i64 @endswith(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i64 @endswith(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i64 @endswith(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp sgt i64 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
ret void
}