#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__ const wchar_t;

/* Variables and functions */
int /*<<< orphan*/ _DIAGASSERT(int /*<<< orphan*/);
scalar_t__ const *__UNCONST(scalar_t__ const *);
wchar_t *wcschr(const wchar_t *p, wchar_t c) {
  _DIAGASSERT(p != NULL);
  for (;; ++p) {
    if (*p == c) {
      return __UNCONST(p);
    }
    if (!*p)
      return NULL;
  }
}


x86 assembly (clang, -O0):
<wcschr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <_DIAGASSERT@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jne    1165 <wcschr+0x45>
mov    -0x10(%rbp),%rdi
call   1040 <__UNCONST@plt>
mov    %rax,-0x8(%rbp)
jmp    1196 <wcschr+0x76>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1180 <wcschr+0x60>
movq   $0x0,-0x8(%rbp)
jmp    1196 <wcschr+0x76>
jmp    1185 <wcschr+0x65>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1142 <wcschr+0x22>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcschr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <_DIAGASSERT@plt>
mov    (%rbx),%rax
cmp    %r14,%rax
je     1152 <wcschr+0x32>
test   %rax,%rax
je     1161 <wcschr+0x41>
mov    0x8(%rbx),%rax
add    $0x8,%rbx
cmp    %r14,%rax
jne    1140 <wcschr+0x20>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <__UNCONST@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64* @wcschr(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64*
%5 = alloca i64
store i64* %0, i64** %4
store i64 %1, i64* %5
%6 = load i64*, i64** %4
%7 = icmp ne i64* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @_DIAGASSERT(i32 %8)
br label %10
10: ; preds = %24, %2
%11 = load i64*, i64** %4
%12 = load i64, i64* %11
%13 = load i64, i64* %5
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i64*, i64** %4
%17 = call i64* @__UNCONST(i64* %16)
store i64* %17, i64** %3
br label %27
18: ; preds = %10
%19 = load i64*, i64** %4
%20 = load i64, i64* %19
%21 = icmp ne i64 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i64* null, i64** %3
br label %27
23: ; preds = %18
br label %24
24: ; preds = %23
%25 = load i64*, i64** %4
%26 = getelementptr inbounds i64, i64* %25, i32 1
store i64* %26, i64** %4
br label %10
27: ; preds = %22, %15
%28 = load i64*, i64** %3
ret i64* %28
}

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