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

/* Variables and functions */
int /*<<< orphan*/ *wcschr(int const *, int /*<<< orphan*/);
size_t wcscspn(const wchar_t *wcs, const wchar_t *reject) {
  size_t count = 0;
  while (*wcs != L'\0')
    if (wcschr(reject, *wcs++) == NULL)
      ++count;
    else
      return count;
  return count;
}


x86 assembly (clang, -O0):
<wcscspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     117c <wcscspn+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
call   1030 <wcschr@plt>
cmp    $0x0,%rax
jne    116a <wcscspn+0x5a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1177 <wcscspn+0x67>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <wcscspn+0x74>
jmp    1128 <wcscspn+0x18>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscspn>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%esi
test   %esi,%esi
je     114c <wcscspn+0x3c>
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <wcschr@plt>
test   %rax,%rax
jne    114e <wcscspn+0x3e>
mov    0x4(%r15,%rbx,4),%esi
add    $0x1,%rbx
test   %esi,%esi
jne    1130 <wcscspn+0x20>
jmp    114e <wcscspn+0x3e>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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