#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 pl_endswith(char *, char *);
int /*<<< orphan*/ printf(char *);
int main() {
  char the_string[] = "http://google.com";
  int ret_val;
  ret_val = pl_endswith(the_string, ".com");
  if (ret_val) {
    printf("the_string, does indeed end with .com\n");
  }
  ret_val = pl_endswith(the_string, ".net");
  if (!ret_val) {
    printf("And it does not end with .net\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <pl_endswith@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1179 <main+0x59>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xeba(%rip),%rsi
call   1040 <pl_endswith@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11a2 <main+0x82>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x6d,0x10(%rsp)
lea    0xf14(%rip),%rsi
mov    %rsp,%rdi
call   1040 <pl_endswith@plt>
test   %eax,%eax
je     1155 <main+0x35>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rsi
mov    %rsp,%rdi
call   1040 <pl_endswith@plt>
test   %eax,%eax
jne    1174 <main+0x54>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.the_string = [18 x i8] c"http://google.com\00"
@.str = [5 x i8] c".com\00"
@.str.1 = [39 x i8] c"the_string, does indeed end with .com\0A\00"
@.str.2 = [5 x i8] c".net\00"
@.str.3 = [31 x i8] c"And it does not end with .net\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [18 x i8]* %2 to i8*
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%6 = call i32 @pl_endswith(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%13 = call i32 @pl_endswith(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.the_string = [18 x i8] c"http://google.com\00"
@.str = [5 x i8] c".com\00"
@.str.2 = [5 x i8] c".net\00"
@str = [30 x i8] c"And it does not end with .net\00"
@str.4 = [38 x i8] c"the_string, does indeed end with .com\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 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 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.4, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i32 @pl_endswith(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
ret i32 0
}