#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 */
unsigned int strlen(char *);
unsigned strspn(char a[], char b[]) {
  unsigned i, j, match;
  for (i = 0; i < strlen(a); i++) {
    match = 0;
    for (j = 0; j < strlen(b); j++) {
      if (a[i] == b[j]) {
        match = 1;
        break;
      }
    }
    if (!match)
      return i;
  }
}


x86 assembly (clang, -O0):
<strspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jae    11d2 <strspn+0xc2>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jae    11aa <strspn+0x9a>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1197 <strspn+0x87>
movl   $0x1,-0x24(%rbp)
jmp    11aa <strspn+0x9a>
jmp    119c <strspn+0x8c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1151 <strspn+0x41>
cmpl   $0x0,-0x24(%rbp)
jne    11bf <strspn+0xaf>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <strspn+0xc2>
jmp    11c4 <strspn+0xb4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <strspn+0x17>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strspn>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r15
call   1030 <strlen@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1173 <strspn+0x63>
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1173 <strspn+0x63>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%r14,1),%eax
cmp    (%r12,%rbx,1),%al
je     1160 <strspn+0x50>
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1140 <strspn+0x30>
jmp    1173 <strspn+0x63>
add    $0x1,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%r14
jb     112a <strspn+0x1a>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @strspn(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %9
9: ; preds = %45, %2
%10 = load i32, i32* %6
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = icmp ult i32 %10, %12
br i1 %13, label %14, label %48
14: ; preds = %9
store i32 0, i32* %8
store i32 0, i32* %7
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %7
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = icmp ult i32 %16, %18
br i1 %19, label %20, label %39
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %26, %32
br i1 %33, label %34, label %35
34: ; preds = %20
store i32 1, i32* %8
br label %39
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add i32 %37, 1
store i32 %38, i32* %7
br label %15
39: ; preds = %34, %15
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = load i32, i32* %6
store i32 %43, i32* %3
br label %48
44: ; preds = %39
br label %45
45: ; preds = %44
%46 = load i32, i32* %6
%47 = add i32 %46, 1
store i32 %47, i32* %6
br label %9
48: ; preds = %42, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @strspn(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %32, label %5
5: ; preds = %2, %22
%6 = phi i64 [ %23, %22 ], [ 0, %2 ]
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %6
br label %15
11: ; preds = %15
%12 = tail call i32 @strlen(i8* %1)
%13 = zext i32 %12 to i64
%14 = icmp ult i64 %21, %13
br i1 %14, label %15, label %27
15: ; preds = %9, %11
%16 = phi i64 [ 0, %9 ], [ %21, %11 ]
%17 = load i8, i8* %10
%18 = getelementptr inbounds i8, i8* %1, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %17, %19
%21 = add nuw nsw i64 %16, 1
br i1 %20, label %22, label %11
22: ; preds = %15
%23 = add nuw nsw i64 %6, 1
%24 = tail call i32 @strlen(i8* %0)
%25 = zext i32 %24 to i64
%26 = icmp ult i64 %23, %25
br i1 %26, label %5, label %29
27: ; preds = %11
%28 = trunc i64 %6 to i32
br label %32
29: ; preds = %22, %5
%30 = phi i64 [ %6, %5 ], [ %23, %22 ]
%31 = trunc i64 %30 to i32
br label %32
32: ; preds = %29, %27, %2
%33 = phi i32 [ 0, %2 ], [ %28, %27 ], [ %31, %29 ]
ret i32 %33
}