#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 */
int /*<<< orphan*/ *strchr(char const *, char const);
size_t strcspn(const char *s1, const char *s2) {
  const char *sc1;
  for (sc1 = s1; *sc1 != '\0'; sc1++)
    if (strchr(s2, *sc1) != NULL)
      return (sc1 - s1);
  return sc1 - s1;
}


x86 assembly (clang, -O0):
<strcspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117c <strcspn+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1166 <strcspn+0x56>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    118b <strcspn+0x7b>
jmp    116b <strcspn+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <strcspn+0x18>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcspn>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%al
mov    %rdi,%rbx
test   %al,%al
je     114c <strcspn+0x3c>
mov    %rsi,%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    114c <strcspn+0x3c>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <strcspn+0x20>
sub    %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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