#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ rm_eo;
  scalar_t__ rm_so;
};
typedef TYPE_1__ regmatch_t;

/* Variables and functions */
char *d_s(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rematch(char *, char *, size_t, TYPE_1__ *);
int /*<<< orphan*/ stderr;
int main() {
  char *src, *re;
  size_t nmatch = 1;
  regmatch_t pmatch[nmatch];
  printf("Enter the source string: ");
  src = d_s(src);
  printf("Enter the regular expression: ");
  re = d_s(re);
  if (rematch(src, re, nmatch, pmatch)) {
    printf("rm_so = [%d], rm_eo = [%d]\n", (int)pmatch[0].rm_so,
           (int)pmatch[0].rm_eo);
  } else {
    fprintf(stderr, "No match:\n\tsource string = [%s]\n\tregex = [%s]\n", src,
            re);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
shl    $0x4,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <d_s@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <d_s@plt>
mov    -0x38(%rbp),%rcx
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <rematch@plt>
cmp    $0x0,%rax
je     11f1 <main+0xb1>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rcx
mov    %ecx,%esi
mov    (%rax),%rax
mov    %eax,%edx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120e <main+0xce>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
call   1050 <d_s@plt>
mov    %rax,%r14
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
call   1050 <d_s@plt>
mov    %rax,%rbx
mov    %rsp,%rcx
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <rematch@plt>
test   %rax,%rax
je     11a2 <main+0x62>
mov    (%rsp),%edx
mov    0x8(%rsp),%esi
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bd <main+0x7d>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64 }
@.str = [26 x i8] c"Enter the source string: \00"
@.str.1 = [31 x i8] c"Enter the regular expression: \00"
@.str.2 = [28 x i8] c"rm_so = [%d], rm_eo = [%d]\0A\00"
@stderr = global i32 0
@.str.3 = [47 x i8] c"No match:\0A\09source string = [%s]\0A\09regex = [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %4
%7 = load i64, i64* %4
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %5
%9 = alloca %struct.TYPE_3__, i64 %7
store i64 %7, i64* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i8* @d_s(i8* %11)
store i8* %12, i8** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8*, i8** %3
%15 = call i8* @d_s(i8* %14)
store i8* %15, i8** %3
%16 = load i8*, i8** %2
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = call i64 @rematch(i8* %16, i8* %17, i64 %18, %struct.TYPE_3__* %9)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %0
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i64 0
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 1
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i64 0
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %29)
br label %36
31: ; preds = %0
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %2
%34 = load i8*, i8** %3
%35 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %33, i8* %34)
br label %36
36: ; preds = %31, %21
store i32 0, i32* %1
%37 = load i8*, i8** %5
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64 }
@.str = [26 x i8] c"Enter the source string: \00"
@.str.1 = [31 x i8] c"Enter the regular expression: \00"
@.str.2 = [28 x i8] c"rm_so = [%d], rm_eo = [%d]\0A\00"
@stderr = global i32 0
@.str.3 = [47 x i8] c"No match:\0A\09source string = [%s]\0A\09regex = [%s]\0A\00"
define i32 @main() {
%1 = alloca %struct.TYPE_3__
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @d_s(i8* undef)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i8* @d_s(i8* undef)
%6 = call i64 @rematch(i8* %3, i8* %5, i64 1, %struct.TYPE_3__* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %0
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %14)
br label %19
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %5)
br label %19
19: ; preds = %16, %8
ret i32 0
}