int main(void) {
  char *s1 = "Adcbcrxcw4p08grdffredfddf";
  char *s2 = "acf";
  char *s3 = "g09";
  printf("%d\n", strcspn(s1, s2));
  printf("%d\n", strcspn(s1, s3));
  printf("%d\n", strpbrk(s1, s2) - s1);
  printf("%d\n", strpbrk(s1, s3) - s1);
  char *str = "Linux was first developed for 386/486-based pcs.";
  printf("%d\n", strspn(str, "Linux"));
  printf("%d\n", strspn(str, "/-"));
  printf("%d\n", strspn(str, "1234567890"));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xec0(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcspn@plt>
mov    %rax,%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcspn@plt>
mov    %rax,%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strpbrk@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
sub    %rax,%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strpbrk@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
sub    %rax,%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe30(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,%rsi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    $0x2,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xb,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xb,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x5,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Adcbcrxcw4p08grdffredfddf\00"
@.str.1 = [4 x i8] c"acf\00"
@.str.2 = [4 x i8] c"g09\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [49 x i8] c"Linux was first developed for 386/486-based pcs.\00"
@.str.5 = [6 x i8] c"Linux\00"
@.str.6 = [3 x i8] c"/-\00"
@.str.7 = [11 x i8] c"1234567890\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %1
%6 = load i8*, i8** %2
%7 = call i64 @strcspn(i8* %5, i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %7)
%9 = load i8*, i8** %1
%10 = load i8*, i8** %3
%11 = call i64 @strcspn(i8* %9, i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %11)
%13 = load i8*, i8** %1
%14 = load i8*, i8** %2
%15 = call i8* @strpbrk(i8* %13, i8* %14)
%16 = load i8*, i8** %1
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %19)
%21 = load i8*, i8** %1
%22 = load i8*, i8** %3
%23 = call i8* @strpbrk(i8* %21, i8* %22)
%24 = load i8*, i8** %1
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %27)
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8** %4
%29 = load i8*, i8** %4
%30 = call i64 @strspn(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %30)
%32 = load i8*, i8** %4
%33 = call i64 @strspn(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %33)
%35 = load i8*, i8** %4
%36 = call i64 @strspn(i8* %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %36)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 2)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 11)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 2)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 11)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 0)
ret i32 0
}