#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 __strxspn(const char *s, const char *map, int parity) {
  char matchmap[255U + 1];
  size_t n = 0;
  memset(matchmap, 0, sizeof matchmap);
  while (*map)
    matchmap[(unsigned char)*map++] = 1;
  matchmap[0] = parity;
  while (matchmap[(unsigned char)*s++] ^ parity)
    n++;
  return n;
}


x86 assembly (clang, -O0):
<__strxspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1170 <__strxspn+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
movb   $0x1,-0x120(%rbp,%rax,1)
01
jmp    1144 <__strxspn+0x34>
mov    -0x14(%rbp),%eax
mov    %al,-0x120(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%eax
movsbl -0x120(%rbp,%rax,1),%eax
ff
xor    -0x14(%rbp),%eax
cmp    $0x0,%eax
je     11b6 <__strxspn+0xa6>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    1179 <__strxspn+0x69>
mov    -0x128(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__strxspn>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edx,%ebp
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     1152 <__strxspn+0x42>
add    $0x1,%rbx
nopl   0x0(%rax)
movzbl %al,%eax
movb   $0x1,(%rsp,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <__strxspn+0x30>
mov    %bpl,(%rsp)
movzbl (%r14),%eax
movsbl (%rsp,%rax,1),%eax
cmp    %ebp,%eax
jne    1166 <__strxspn+0x56>
xor    %eax,%eax
jmp    1182 <__strxspn+0x72>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r14,%rax,1),%ecx
add    $0x1,%rax
movsbl (%rsp,%rcx,1),%ecx
cmp    %ebp,%ecx
jne    1170 <__strxspn+0x60>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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