#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 int /*<<< orphan*/ wchar_t;

/* Variables and functions */
int /*<<< orphan*/ *wcschr(int /*<<< orphan*/ const *, int /*<<< orphan*/);
size_t wcslen(int /*<<< orphan*/ const *);
int /*<<< orphan*/ wmemcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                           size_t);
wchar_t *wcsstr(const wchar_t *s, const wchar_t *find) {
  wchar_t find_c;
  find_c = *find++;
  if (!find_c)
    return (wchar_t *)s;
  size_t find_len = wcslen(find);
  for (;;) {
    wchar_t *p = wcschr(s, find_c);
    if (p == NULL)
      return NULL;
    if (!wmemcmp(p, find, find_len))
      return p;
    s = p + 1;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<wcsstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    116b <wcsstr+0x3b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d8 <wcsstr+0xa8>
mov    -0x18(%rbp),%rdi
call   1030 <wcslen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <wcschr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a0 <wcsstr+0x70>
movq   $0x0,-0x8(%rbp)
jmp    11d8 <wcsstr+0xa8>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <wmemcmp@plt>
cmp    $0x0,%eax
jne    11c7 <wcsstr+0x97>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d8 <wcsstr+0xa8>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1178 <wcsstr+0x48>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsstr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rsi),%ebp
test   %ebp,%ebp
je     119a <wcsstr+0x6a>
mov    %rsi,%r14
add    $0x4,%r14
mov    %r14,%rdi
call   1030 <wcslen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <wcschr@plt>
test   %rax,%rax
je     1198 <wcsstr+0x68>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <wmemcmp@plt>
test   %eax,%eax
je     119a <wcsstr+0x6a>
add    $0x4,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <wcschr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <wcsstr+0x40>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32* @wcsstr(i32* %0, i32* %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = tail call i64 @wcslen(i32* %3)
%8 = tail call i32* @wcschr(i32* %0, i32 %4)
%9 = icmp eq i32* %8, null
br i1 %9, label %18, label %10
10: ; preds = %6, %14
%11 = phi i32* [ %16, %14 ], [ %8, %6 ]
%12 = tail call i32 @wmemcmp(i32* %11, i32* %3, i64 %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = getelementptr inbounds i32, i32* %11, i64 1
%16 = tail call i32* @wcschr(i32* %15, i32 %4)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %10
18: ; preds = %14, %10, %6, %2
%19 = phi i32* [ %0, %2 ], [ null, %6 ], [ null, %14 ], [ %11, %10 ]
ret i32* %19
}