#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(unsigned char *, unsigned char *);
int strlen(unsigned char *);
int compare_end_str(unsigned char *s1, unsigned char *s2) {
  int l1, l2;
  l1 = strlen(s1);
  l2 = strlen(s2);
  if (l1 >= l2) {
    if (strcmp(s1 + l1 - l2, s2) == 0)
      return (!(((int)(0))));
    else
      return ((int)(0));
  } else {
    if (strcmp(s2 + l2 - l1, s1) == 0)
      return (!(((int)(0))));
    else
      return ((int)(0));
  }
}


x86 assembly (clang, -O0):
<compare_end_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     1196 <compare_end_str+0x76>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
movslq -0x20(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <compare_end_str+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <compare_end_str+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <compare_end_str+0xb3>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
movslq -0x1c(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cc <compare_end_str+0xac>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <compare_end_str+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_end_str>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
mov    %ebp,%ecx
cmovl  %eax,%ecx
mov    %r14,%rdx
cmovl  %rbx,%rdx
cmovl  %ebp,%eax
cmovl  %r14,%rbx
movslq %ecx,%rdi
add    %rdx,%rdi
cltq
sub    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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