#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 */
typedef scalar_t__ wmemcmp;
typedef int /*<<< orphan*/ const wchar_t;

/* Variables and functions */
size_t wcsclen(int /*<<< orphan*/ const *, int /*<<< orphan*/ const);
wchar_t *(wcscends)(const wchar_t *string, const wchar_t *desired,
                    wchar_t stop) {
  size_t n = wcsclen(string, stop);
  size_t m = wcsclen(desired, stop);
  if (n < m)
    return NULL;
  return (wmemcmp)(string + (n - m), desired, m) ? NULL : (string + n);
}


x86 assembly (clang, -O0):
<wcscends>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <wcsclen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <wcsclen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    115e <wcscends+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    118f <wcscends+0x7f>
cmpq   $0x0,-0x30(%rbp)
je     1174 <wcscends+0x64>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    1187 <wcscends+0x77>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscends>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%esi
call   1030 <wcsclen@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <wcsclen@plt>
xor    %edx,%edx
test   %rax,%rax
lea    (%r15,%r12,4),%rcx
cmovne %rdx,%rcx
cmp    %rax,%r12
cmovb  %rdx,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32* @wcscends(i32* %0, i32* %1, i32 %2) {
%4 = tail call i64 @wcsclen(i32* %0, i32 %2)
%5 = tail call i64 @wcsclen(i32* %1, i32 %2)
%6 = icmp ult i64 %4, %5
%7 = icmp eq i64 %5, 0
%8 = getelementptr inbounds i32, i32* %0, i64 %4
%9 = select i1 %7, i32* %8, i32* null
%10 = select i1 %6, i32* null, i32* %9
ret i32* %10
}