#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 RegExtractAll(char *, char *, char **);
int /*<<< orphan*/ free(char **);
scalar_t__ malloc(int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  int cn;
  char test[] = "Jan Nicolas Jonas Helbling Nolaci Nilillic";
  char pattern[] = "N[icolas]+";
  char **buffer = (char **)malloc(4096);
  cn = RegExtractAll(test, pattern, buffer);
  int i;
  for (i = 0; i != cn; i++) {
    puts(buffer[i]);
  }
  free(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x2b,%edx
call   1050 <memcpy@plt>
mov    0xea9(%rip),%rax
mov    %rax,-0x4b(%rbp)
mov    0xea6(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xe9e(%rip),%al
mov    %al,-0x41(%rbp)
mov    $0x1000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x4b(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1060 <RegExtractAll@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11ee <main+0x9e>
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <puts@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11c3 <main+0x73>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movups 0xecb(%rip),%xmm0
movups %xmm0,0x2b(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x73616c6f63695b4e,%rax
6c 61 73
mov    %rax,(%rsp)
movl   $0x2b5d73,0x7(%rsp)
mov    $0x1000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    %rax,%rdx
call   1050 <RegExtractAll@plt>
test   %eax,%eax
je     11c2 <main+0x82>
mov    %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <main+0x70>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.test = [43 x i8] c"Jan Nicolas Jonas Helbling Nolaci Nilillic\00"
@__const.main.pattern = [11 x i8] c"N[icolas]+\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [43 x i8]
%8 = alloca [11 x i8]
%9 = alloca i8**
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [43 x i8]* %7 to i8*
%12 = bitcast [11 x i8]* %8 to i8*
%13 = call i64 @malloc(i32 4096)
%14 = inttoptr i64 %13 to i8**
store i8** %14, i8*** %9
%15 = getelementptr inbounds [43 x i8], [43 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%17 = load i8**, i8*** %9
%18 = call i32 @RegExtractAll(i8* %15, i8* %16, i8** %17)
store i32 %18, i32* %6
store i32 0, i32* %10
br label %19
19: ; preds = %30, %2
%20 = load i32, i32* %10
%21 = load i32, i32* %6
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8**, i8*** %9
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @puts(i8* %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
br label %19
33: ; preds = %19
%34 = load i8**, i8*** %9
%35 = call i32 @free(i8** %34)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test = [43 x i8] c"Jan Nicolas Jonas Helbling Nolaci Nilillic\00"
@__const.main.pattern = [11 x i8] c"N[icolas]+\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [43 x i8]
%4 = alloca [11 x i8]
%5 = getelementptr inbounds [43 x i8], [43 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%7 = tail call i64 @malloc(i32 4096)
%8 = inttoptr i64 %7 to i8**
%9 = call i32 @RegExtractAll(i8* %5, i8* %6, i8** %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %2
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %18, %13 ]
%15 = getelementptr inbounds i8*, i8** %8, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @puts(i8* dereferenceable(1) %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %12
br i1 %19, label %20, label %13
20: ; preds = %13, %2
%21 = call i32 @free(i8** %8)
ret i32 0
}