#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_equal_int(int, int, char *, char *);
int pl_endswith(char *, char *);
void test_endswith() {
  char the_string[] = "http://yahoo.com";
  int ret_val = pl_endswith(the_string, ".com");
  assert_equal_int(1, ret_val, "test_endswith",
                   "Test 1: The strings does not end with .com");
  ret_val = pl_endswith(the_string, ".net");
  assert_equal_int(0, ret_val, "test_endswith",
                   "Test 2: The string does end with .net");
}


x86 assembly (clang, -O0):
<test_endswith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecc(%rip),%al
mov    %al,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xef3(%rip),%rsi
call   1030 <pl_endswith@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    $0x1,%edi
lea    0xea8(%rip),%rdx
lea    0xeaf(%rip),%rcx
call   1040 <assert_equal_int@plt>
lea    -0x20(%rbp),%rdi
lea    0xeeb(%rip),%rsi
call   1030 <pl_endswith@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
xor    %edi,%edi
lea    0xe7d(%rip),%rdx
lea    0xeaf(%rip),%rcx
call   1040 <assert_equal_int@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_endswith>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xf07(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <pl_endswith@plt>
lea    0xec1(%rip),%r14
lea    0xec8(%rip),%rcx
mov    $0x1,%edi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <assert_equal_int@plt>
lea    0xefe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <pl_endswith@plt>
lea    0xece(%rip),%rcx
xor    %edi,%edi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <assert_equal_int@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_endswith.the_string = [17 x i8] c"http://yahoo.com\00"
@.str = [5 x i8] c".com\00"
@.str.1 = [14 x i8] c"test_endswith\00"
@.str.2 = [43 x i8] c"Test 1: The strings does not end with .com\00"
@.str.3 = [5 x i8] c".net\00"
@.str.4 = [38 x i8] c"Test 2: The string does end with .net\00"
define void @test_endswith() {
%1 = alloca [17 x i8]
%2 = alloca i32
%3 = bitcast [17 x i8]* %1 to i8*
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%5 = call i32 @pl_endswith(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @assert_equal_int(i32 1, i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%9 = call i32 @pl_endswith(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @assert_equal_int(i32 0, i32 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_endswith.the_string = [17 x i8] c"http://yahoo.com\00"
@.str = [5 x i8] c".com\00"
@.str.1 = [14 x i8] c"test_endswith\00"
@.str.2 = [43 x i8] c"Test 1: The strings does not end with .com\00"
@.str.3 = [5 x i8] c".net\00"
@.str.4 = [38 x i8] c"Test 2: The string does end with .net\00"
define void @test_endswith() {
%1 = alloca [17 x i8]
%2 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%3 = call i32 @pl_endswith(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @assert_equal_int(i32 1, i32 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @pl_endswith(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @assert_equal_int(i32 0, i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
ret void
}