#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*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ compile_regex(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ match_regex(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ printf(char *, char const *, char const *);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  regex_t r;
  const char *regex_text;
  const char *find_text;
  if (argc != 3) {
    regex_text = "([[:digit:]]+)[^[:digit:]]+([[:digit:]]+)";
    find_text = "This 1 is nice 2 so 33 for 4254";
  } else {
    regex_text = argv[1];
    find_text = argv[2];
  }
  printf("Trying to find '%s' in '%s'\n", regex_text, find_text);
  compile_regex(&r, regex_text);
  match_regex(&r, find_text);
  regfree(&r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     117b <main+0x3b>
lea    0xe99(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeb8(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1193 <main+0x53>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   1060 <compile_regex@plt>
mov    -0x28(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   1050 <match_regex@plt>
lea    -0x14(%rbp),%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x3,%edi
jne    1158 <main+0x18>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
jmp    1166 <main+0x26>
lea    0xecb(%rip),%r14
lea    0xe9a(%rip),%rbx
lea    0xedd(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
lea    0xc(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <compile_regex@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <match_regex@plt>
mov    %r15,%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"([[:digit:]]+)[^[:digit:]]+([[:digit:]]+)\00"
@.str.1 = [32 x i8] c"This 1 is nice 2 so 33 for 4254\00"
@.str.2 = [29 x i8] c"Trying to find '%s' in '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %19
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
store i8* %18, i8** %8
br label %19
19: ; preds = %12, %11
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %20, i8* %21)
%23 = load i8*, i8** %7
%24 = call i32 @compile_regex(i32* %6, i8* %23)
%25 = load i8*, i8** %8
%26 = call i32 @match_regex(i32* %6, i8* %25)
%27 = call i32 @regfree(i32* %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"([[:digit:]]+)[^[:digit:]]+([[:digit:]]+)\00"
@.str.1 = [32 x i8] c"This 1 is nice 2 so 33 for 4254\00"
@.str.2 = [29 x i8] c"Trying to find '%s' in '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
br label %11
11: ; preds = %2, %6
%12 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), %2 ]
%13 = phi i8* [ %10, %6 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %2 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%15 = call i32 @compile_regex(i32* %3, i8* %12)
%16 = call i32 @match_regex(i32* %3, i8* %13)
%17 = call i32 @regfree(i32* %3)
ret i32 0
}