#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 strcmp(char const *, char const *);
int strlen(char const *);
int check_end(const char *str, const char *end) {
  int elen, slen;
  const char *tmp;
  elen = strlen(end);
  slen = strlen(str);
  if (elen > slen)
    return 1;
  tmp = str + slen - elen;
  return strcmp(tmp, end);
}


x86 assembly (clang, -O0):
<check_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1160 <check_end+0x40>
movl   $0x1,-0x4(%rbp)
jmp    118b <check_end+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_end>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jle    114a <check_end+0x2a>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
cltq
add    %rax,%rbx
movslq %ebp,%rax
sub    %rax,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <strcmp@plt>

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

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