#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ regex_search_at_offset(char const *, int, int);
scalar_t__ strlen(char const *);
int main(int argc, char *argv[]) {
  const char *str = "abcokokazodkaozkdazkdcdeff";
  int str_len = (int)strlen(str);
  printf("Let's try to match the string '%s' with the regex 'ab.*d.*f'\n", str);
  for (int offset = 0; offset < str_len; offset++) {
    if (regex_search_at_offset(str, str_len, offset) == 0) {
      exit(0);
    }
  }
  printf("No match Found!\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c5 <main+0x85>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <regex_search_at_offset@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x72>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    11b7 <main+0x77>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1186 <main+0x46>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
lea    0xeaf(%rip),%rbx
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x1a,%esi
mov    %ebp,%edx
call   1030 <regex_search_at_offset@plt>
test   %rax,%rax
je     1194 <main+0x54>
add    $0x1,%ebp
cmp    $0x1a,%ebp
jne    1160 <main+0x20>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"abcokokazodkaozkdazkdcdeff\00"
@.str.1 = [62 x i8] c"Let's try to match the string '%s' with the regex 'ab.*d.*f'\0A\00"
@.str.2 = [17 x i8] c"No match Found!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %6
%9 = load i8*, i8** %6
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %7
%12 = load i8*, i8** %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %8
br label %14
14: ; preds = %27, %2
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i64 @regex_search_at_offset(i8* %19, i32 %20, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %18
br label %27
27: ; preds = %26
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %14
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [27 x i8] c"abcokokazodkaozkdazkdcdeff\00"
@.str.1 = [62 x i8] c"Let's try to match the string '%s' with the regex 'ab.*d.*f'\0A\00"
@str = [16 x i8] c"No match Found!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %9
4: ; preds = %9
%5 = add nuw nsw i32 %10, 1
%6 = icmp eq i32 %5, 26
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
ret i32 1
9: ; preds = %2, %4
%10 = phi i32 [ 0, %2 ], [ %5, %4 ]
%11 = tail call i64 @regex_search_at_offset(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %9
%14 = tail call i32 @exit(i32 0)
unreachable
}