#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 */
scalar_t__ check_char(char const, char *);
int my_strspn(const char *str1, const char *str2) {
  int nbr_com;
  nbr_com = 0;
  while (*str1 && check_char(*str1, (char *)str2)) {
    nbr_com += 1;
    str1++;
  }
  return (nbr_com);
}


x86 assembly (clang, -O0):
<my_strspn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     1158 <my_strspn+0x48>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <check_char@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1168 <my_strspn+0x58>
jmp    1182 <my_strspn+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1127 <my_strspn+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strspn>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1150 <my_strspn+0x40>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <check_char@plt>
test   %rax,%rax
je     1152 <my_strspn+0x42>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <my_strspn+0x20>
jmp    1152 <my_strspn+0x42>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @my_strspn(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %19, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = load i8*, i8** %4
%15 = call i64 @check_char(i8 signext %13, i8* %14)
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %11, %6
%18 = phi i1 [ false, %6 ], [ %16, %11 ]
br i1 %18, label %19, label %24
19: ; preds = %17
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
br label %6
24: ; preds = %17
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
define i32 @my_strspn(i8* nocapture %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2, %11
%6 = phi i8 [ %14, %11 ], [ %3, %2 ]
%7 = phi i32 [ %12, %11 ], [ 0, %2 ]
%8 = phi i8* [ %13, %11 ], [ %0, %2 ]
%9 = tail call i64 @check_char(i8 signext %6, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = add nuw nsw i32 %7, 1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %11, %2
%17 = phi i32 [ 0, %2 ], [ %12, %11 ], [ %7, %5 ]
ret i32 %17
}