#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 *, char *);
scalar_t__ strlen(char *);
int strcmp_end(char *str, char *end) {
  if (strlen(str) < strlen(end))
    return 1;
  int pos = strlen(str) - strlen(end);
  return strcmp((char *)(str + pos), end);
}


x86 assembly (clang, -O0):
<strcmp_end>:
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,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    1162 <strcmp_end+0x42>
movl   $0x1,-0x4(%rbp)
jmp    119c <strcmp_end+0x7c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%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):
<strcmp_end>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jge    114b <strcmp_end+0x2b>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
sub    %eax,%ebx
movslq %ebx,%rax
add    %rax,%r15
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strcmp@plt>

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

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