#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 */
scalar_t__ strcmp(char const *, char const *);
int strlen(char const *);
bool strends(const char *str, const char *postfix) {
  if (strlen(str) < strlen(postfix))
    return false;
  return (strcmp((str + strlen(str) - strlen(postfix)), (postfix)) == 0);
}


x86 assembly (clang, -O0):
<strends>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    115e <strends+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11af <strends+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
movslq %eax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strends>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%ebp
jl     1172 <strends+0x52>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
sub    %rax,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strends(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 = call i32 @strlen(i8* %6)
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %27
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = sub i64 0, %20
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8*, i8** %5
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %3
br label %27
27: ; preds = %12, %11
%28 = load i32, i32* %3
ret i32 %28
}

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