#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 */
size_t strspn(const char *s1, const char *s2) {
  const char *p = s1, *spanp;
  char c, sc;
cont:
  c = *p++;
  for (spanp = s2; (sc = *spanp++) != 0;)
    if (sc == c)
      goto cont;
  return (p - 1 - s1);
}


x86 assembly (clang, -O0):
<strspn>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x22(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     116a <strspn+0x6a>
movsbl -0x22(%rbp),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    1165 <strspn+0x65>
jmp    1114 <strspn+0x14>
jmp    1130 <strspn+0x30>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strspn>:
mov    %rdi,%rax
lea    0x1(%rax),%r8
mov    (%rax),%r9b
mov    %rsi,%rcx
nopl   (%rax)
movzbl (%rcx),%edx
test   %dl,%dl
je     1125 <strspn+0x25>
add    $0x1,%rcx
cmp    %r9b,%dl
jne    1110 <strspn+0x10>
mov    %r8,%rax
jmp    1103 <strspn+0x3>
sub    %rdi,%rax
ret

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

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