#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*/ memset(char *, int /*<<< orphan*/, int);
size_t strcspn(const char *string, const char *stopset) {
  char set[256];
  char c;
  const char *s = string;
  memset(set, 0, 256);
  while ((c = *stopset++))
    set[(size_t)c] = 1;
  while ((c = *s++))
    if (!set[(size_t)c])
      break;
  return (size_t)(s - 1 - string);
}


x86 assembly (clang, -O0):
<strcspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x111(%rbp)
cmp    $0x0,%al
je     1175 <strcspn+0x65>
movsbq -0x111(%rbp),%rax
ff
movb   $0x1,-0x110(%rbp,%rax,1)
01
jmp    1141 <strcspn+0x31>
jmp    117a <strcspn+0x6a>
mov    -0x120(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x120(%rbp)
mov    (%rax),%al
mov    %al,-0x111(%rbp)
cmp    $0x0,%al
je     11bf <strcspn+0xaf>
movsbq -0x111(%rbp),%rax
ff
cmpb   $0x0,-0x110(%rbp,%rax,1)
jne    11ba <strcspn+0xaa>
jmp    11bf <strcspn+0xaf>
jmp    117a <strcspn+0x6a>
mov    -0x120(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcspn>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     1153 <strcspn+0x43>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbq %al,%rax
movb   $0x1,(%rsp,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <strcspn+0x30>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rcx,%rax
movsbq (%r14,%rcx,1),%rdx
test   %rdx,%rdx
je     1177 <strcspn+0x67>
lea    0x1(%rax),%rcx
cmpb   $0x0,(%rsp,%rdx,1)
jne    1160 <strcspn+0x50>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i64 @strcspn(i8* %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 256)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = phi i8 [ %14, %8 ], [ %6, %2 ]
%10 = phi i8* [ %11, %8 ], [ %1, %2 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = sext i8 %9 to i64
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %12
store i8 1, i8* %13
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %8, %2
br label %17
17: ; preds = %16, %21
%18 = phi i8* [ %22, %21 ], [ %0, %16 ]
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %18, i64 1
%23 = sext i8 %19 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %17
27: ; preds = %21, %17
%28 = ptrtoint i8* %18 to i64
%29 = ptrtoint i8* %0 to i64
%30 = sub i64 %28, %29
ret i64 %30
}