#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__ strlen(char *);
int astrend(char *s, char *q) {
  s += strlen(s) - strlen(q);
  while (*s != '\0')
    if (*s++ != *q++)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<astrend>:
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    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1195 <astrend+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1190 <astrend+0x80>
movl   $0x0,-0x4(%rbp)
jmp    119c <astrend+0x8c>
jmp    1148 <astrend+0x38>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astrend>:
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>
sub    %rax,%rbx
add    %r15,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx,%rax,1),%ecx
test   %cl,%cl
je     1159 <astrend+0x49>
lea    0x1(%rax),%rdx
cmp    (%r14,%rax,1),%cl
mov    %rdx,%rax
je     1140 <astrend+0x30>
xor    %eax,%eax
jmp    115e <astrend+0x4e>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @astrend(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 = sub nsw i64 %3, %4
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %12, %2
%8 = phi i8* [ %6, %2 ], [ %13, %12 ]
%9 = phi i8* [ %1, %2 ], [ %14, %12 ]
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %9
%16 = icmp eq i8 %10, %15
br i1 %16, label %7, label %17
17: ; preds = %7, %12
%18 = phi i32 [ 0, %12 ], [ 1, %7 ]
ret i32 %18
}