#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 strlen(char *);
char *strstr(char *, char *);
int matches_next(const int size, char *string, char *regex, int qte,
                 int *size_of_del) {
  int i;
  char *ptr, *ptr2 = regex;
  for (i = 0; i < qte; i++) {
    ptr = strstr(string, ptr2);
    if (ptr != NULL && ptr == string) {
      *size_of_del = strlen(ptr2);
      return 1;
    }
    ptr2 += size;
  }
  return 0;
}


x86 assembly (clang, -O0):
<matches_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bb <matches_next+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     119c <matches_next+0x7c>
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    119c <matches_next+0x7c>
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c2 <matches_next+0xa2>
mov    -0x8(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1149 <matches_next+0x29>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matches_next>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
test   %ecx,%ecx
jle    117e <matches_next+0x5e>
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r12
movslq %edi,%r13
jmp    1158 <matches_next+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %r13,%rbx
add    $0xffffffff,%ebp
je     117e <matches_next+0x5e>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1150 <matches_next+0x30>
cmp    %r12,%rax
jne    1150 <matches_next+0x30>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @matches_next(i32 %0, i8* %1, i8* %2, i32 %3, i32* nocapture writeonly %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = sext i32 %0 to i64
br label %9
9: ; preds = %7, %18
%10 = phi i8* [ %2, %7 ], [ %19, %18 ]
%11 = phi i32 [ 0, %7 ], [ %20, %18 ]
%12 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %10)
%13 = icmp ne i8* %12, null
%14 = icmp eq i8* %12, %1
%15 = and i1 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @strlen(i8* %10)
store i32 %17, i32* %4
br label %22
18: ; preds = %9
%19 = getelementptr inbounds i8, i8* %10, i64 %8
%20 = add nuw nsw i32 %11, 1
%21 = icmp eq i32 %20, %3
br i1 %21, label %22, label %9
22: ; preds = %18, %5, %16
%23 = phi i32 [ 1, %16 ], [ 0, %5 ], [ 0, %18 ]
ret i32 %23
}