#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);
size_t strspn(const char *s1, const char *s2) {
  char *s = (char *)s1;
  while (*s != 0) {
    if (!strchr(s2, *s)) {
      break;
    }
    s++;
  }
  return (size_t)(s - s1);
}


x86 assembly (clang, -O0):
<strspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1167 <strspn+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    1156 <strspn+0x46>
jmp    1167 <strspn+0x57>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <strspn+0x18>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i64 @strspn(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, 0
br i1 %9, label %14, label %10
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
}