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


x86 assembly (clang, -O0):
<my_strcspn>:
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     1159 <my_strcspn+0x49>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <check_char@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1169 <my_strcspn+0x59>
jmp    1183 <my_strcspn+0x73>
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_strcspn+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strcspn>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     114f <my_strcspn+0x3f>
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   %eax,%eax
jne    1151 <my_strcspn+0x41>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <my_strcspn+0x20>
jmp    1151 <my_strcspn+0x41>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @my_strcspn(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 = %20, %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 %18
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = load i8*, i8** %4
%15 = call i32 @check_char(i8 signext %13, i8* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br label %18
18: ; preds = %11, %6
%19 = phi i1 [ false, %6 ], [ %17, %11 ]
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
br label %6
25: ; preds = %18
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
define i32 @my_strcspn(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 i32 @check_char(i8 signext %6, i8* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
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
}