#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 */
typedef int /*<<< orphan*/ regmatch_t;

/* Variables and functions */
char *d_s(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ rematch(char *, char *, size_t, int /*<<< orphan*/ *);
int main() {
  size_t nm = 2;
  regmatch_t pm[2];
  char *s;
  printf("Enter string: ");
  s = d_s(s);
  char *re;
  printf("Enter regex: ");
  re = d_s(re);
  if (rematch(re, s, nm, pm))
    puts("Match!");
  else
    puts("No match...");
  free(s);
  free(re);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x2,-0x10(%rbp)
lea    0xe92(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <d_s@plt>
mov    %rax,-0x20(%rbp)
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <d_s@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1070 <rematch@plt>
cmp    $0x0,%rax
je     11c9 <main+0x79>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
jmp    11d5 <main+0x85>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1050 <printf@plt>
call   1060 <d_s@plt>
mov    %rax,%r14
lea    0xea0(%rip),%rdi
call   1050 <printf@plt>
call   1060 <d_s@plt>
mov    %rax,%rbx
mov    %rsp,%rcx
mov    $0x2,%edx
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <rematch@plt>
test   %rax,%rax
lea    0xe8b(%rip),%rax
lea    0xe7d(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter string: \00"
@.str.1 = [14 x i8] c"Enter regex: \00"
@.str.2 = [7 x i8] c"Match!\00"
@.str.3 = [12 x i8] c"No match...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [2 x i32]
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i64 2, i64* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %4
%8 = call i8* @d_s(i8* %7)
store i8* %8, i8** %4
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %5
%11 = call i8* @d_s(i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = load i64, i64* %2
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%16 = call i64 @rematch(i8* %12, i8* %13, i64 %14, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %22
20: ; preds = %0
%21 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = load i8*, i8** %4
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @free(i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter string: \00"
@.str.1 = [14 x i8] c"Enter regex: \00"
@.str.2 = [7 x i8] c"Match!\00"
@.str.3 = [12 x i8] c"No match...\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @d_s(i8* undef)
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i8* @d_s(i8* undef)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i64 @rematch(i8* %6, i8* %4, i64 2, i32* %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
%12 = call i32 @free(i8* %4)
%13 = call i32 @free(i8* %6)
ret i32 0
}