#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 */
size_t strlen(char *);
int strend(char *str, char *tail) {
  while ((str[strlen(str)] == tail[strlen(tail)]) && (strlen(tail) != 0) &&
         (strlen(str) != 0)) {
    str--;
    tail--;
  }
  if (strlen(tail) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<strend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c(%rbp),%ecx
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movsbl (%rax,%rdx,1),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
jne    1199 <strend+0x89>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     1199 <strend+0x89>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a9 <strend+0x99>
jmp    11c6 <strend+0xb6>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <strend+0x10>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11e5 <strend+0xd5>
movl   $0x1,-0x4(%rbp)
jmp    11ec <strend+0xdc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strend>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    (%r15,%rax,1),%bpl
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    (%r14,%rax,1),%bpl
jne    118a <strend+0x7a>
test   %rax,%rax
je     118a <strend+0x7a>
test   %rbx,%rbx
je     118a <strend+0x7a>
add    $0xffffffffffffffff,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rbp
add    $0xffffffffffffffff,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
movzbl (%r15,%rax,1),%r12d
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    $0x1,%rax
setb   %cl
cmp    0x0(%rbp,%rax,1),%r12b
jne    118a <strend+0x7a>
test   %cl,%cl
jne    118a <strend+0x7a>
add    $0xffffffffffffffff,%r15
test   %rbx,%rbx
jne    1150 <strend+0x40>
xor    %eax,%eax
cmpb   $0x0,(%r14)
sete   %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strend(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %30, %2
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = load i8*, i8** %5
%14 = load i8*, i8** %5
%15 = call i64 @strlen(i8* %14)
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %12, %18
br i1 %19, label %20, label %28
20: ; preds = %6
%21 = load i8*, i8** %5
%22 = call i64 @strlen(i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = call i64 @strlen(i8* %25)
%27 = icmp ne i64 %26, 0
br label %28
28: ; preds = %24, %20, %6
%29 = phi i1 [ false, %20 ], [ false, %6 ], [ %27, %24 ]
br i1 %29, label %30, label %35
30: ; preds = %28
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %4
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 -1
store i8* %34, i8** %5
br label %6
35: ; preds = %28
%36 = load i8*, i8** %5
%37 = call i64 @strlen(i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 1, i32* %3
br label %41
40: ; preds = %35
store i32 0, i32* %3
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @strend(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = icmp ne i8 %5, %8
%10 = icmp eq i64 %6, 0
%11 = select i1 %9, i1 true, i1 %10
%12 = icmp eq i64 %3, 0
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %30, label %14
14: ; preds = %2, %14
%15 = phi i8* [ %18, %14 ], [ %1, %2 ]
%16 = phi i8* [ %17, %14 ], [ %0, %2 ]
%17 = getelementptr inbounds i8, i8* %16, i64 -1
%18 = getelementptr inbounds i8, i8* %15, i64 -1
%19 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = tail call i64 @strlen(i8* dereferenceable(1) %18)
%23 = getelementptr inbounds i8, i8* %18, i64 %22
%24 = load i8, i8* %23
%25 = icmp ne i8 %21, %24
%26 = icmp eq i64 %22, 0
%27 = select i1 %25, i1 true, i1 %26
%28 = icmp eq i64 %19, 0
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %30, label %14
30: ; preds = %14, %2
%31 = phi i8* [ %1, %2 ], [ %18, %14 ]
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
%34 = zext i1 %33 to i32
ret i32 %34
}