#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 *s, const char *b) {
  char map[256], *os;
  memset(map, 0, 256);
  for (;;) {
    map[*(unsigned char *)b] = 1;
    if (*b++ == 0)
      break;
  }
  os = (char *)s;
  while (map[*(unsigned char *)s++] == 0)
    ;
  return s - os - 1;
}


x86 assembly (clang, -O0):
<strcspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
movb   $0x1,-0x110(%rbp,%rax,1)
01
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1165 <strcspn+0x55>
jmp    116a <strcspn+0x5a>
jmp    1136 <strcspn+0x26>
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%eax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    119d <strcspn+0x8d>
jmp    1175 <strcspn+0x65>
mov    -0x8(%rbp),%rax
mov    -0x118(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%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>
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
movb   $0x1,(%rsp,%rax,1)
test   %rax,%rax
jne    1130 <strcspn+0x20>
mov    $0xffffffffffffffff,%rax
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%r14,%rax,1),%ecx
add    $0x1,%rax
cmpb   $0x0,(%rsp,%rcx,1)
je     1150 <strcspn+0x40>
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*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 256)
br label %9
9: ; preds = %20, %2
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = zext i8 %11 to i64
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %12
store i8 1, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
%16 = load i8, i8* %14
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %9
br label %21
20: ; preds = %9
br label %9
21: ; preds = %19
%22 = load i8*, i8** %3
store i8* %22, i8** %6
br label %23
23: ; preds = %32, %21
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
%26 = load i8, i8* %24
%27 = zext i8 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %23
br label %23
33: ; preds = %23
%34 = load i8*, i8** %3
%35 = load i8*, i8** %6
%36 = ptrtoint i8* %34 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = sub nsw i64 %38, 1
ret i64 %39
}

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)
br label %6
6: ; preds = %6, %2
%7 = phi i8* [ %1, %2 ], [ %11, %6 ]
%8 = load i8, i8* %7
%9 = zext i8 %8 to i64
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %9
store i8 1, i8* %10
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = icmp eq i8 %8, 0
br i1 %12, label %13, label %6
13: ; preds = %6, %13
%14 = phi i8* [ %15, %13 ], [ %0, %6 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %14
%17 = zext i8 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %13, label %21
21: ; preds = %13
%22 = ptrtoint i8* %15 to i64
%23 = ptrtoint i8* %0 to i64
%24 = xor i64 %23, -1
%25 = add i64 %22, %24
ret i64 %25
}