#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 *);
size_t strlen(char const *);
int spx_utils_str_ends_with(const char *str, const char *suffix) {
  const size_t str_len = strlen(str);
  const size_t suffix_len = strlen(suffix);
  if (str_len < suffix_len) {
    return 0;
  }
  if (strcmp(str + str_len - suffix_len, suffix) == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<spx_utils_str_ends_with>:
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    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1164 <spx_utils_str_ends_with+0x44>
movl   $0x0,-0x4(%rbp)
jmp    119b <spx_utils_str_ends_with+0x7b>
mov    -0x10(%rbp),%rdi
add    -0x20(%rbp),%rdi
xor    %eax,%eax
sub    -0x28(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1194 <spx_utils_str_ends_with+0x74>
movl   $0x1,-0x4(%rbp)
jmp    119b <spx_utils_str_ends_with+0x7b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spx_utils_str_ends_with>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
jb     1161 <spx_utils_str_ends_with+0x41>
add    %r15,%rbx
sub    %rcx,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @spx_utils_str_ends_with(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %6
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %7
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %28
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i64, i64* %6
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i64, i64* %7
%21 = sub i64 0, %20
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8*, i8** %5
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %16
store i32 1, i32* %3
br label %28
27: ; preds = %16
store i32 0, i32* %3
br label %28
28: ; preds = %27, %26, %15
%29 = load i32, i32* %3
ret i32 %29
}

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