#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*/ REG_EXTENDED;
int REG_NOMATCH;
int /*<<< orphan*/ printf(char *, char const *);
int regcomp(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int regexec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
bool route_match(const char *matcher, const char *path) {
  regex_t regex;
  int err = regcomp(&regex, path, REG_EXTENDED);
  if (err) {
    printf("Cannot compile regex: %s\n", matcher);
    return false;
  }
  int match = regexec(&regex, matcher, 0, NULL, 0);
  regfree(&regex);
  return match != REG_NOMATCH;
}


x86 assembly (clang, -O0):
<route_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rdi
call   1050 <regcomp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     118f <route_match+0x4f>
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <route_match+0x89>
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1060 <regexec@plt>
mov    %eax,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <regfree@plt>
mov    -0x24(%rbp),%eax
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<route_match>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rdi
call   1050 <regcomp@plt>
test   %eax,%eax
je     1171 <route_match+0x31>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
jmp    11a0 <route_match+0x60>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <regfree@plt>
mov    0x2e4f(%rip),%rcx
xor    %eax,%eax
cmp    (%rcx),%ebx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@.str = [26 x i8] c"Cannot compile regex: %s\0A\00"
@REG_NOMATCH = global i32 0
define i32 @route_match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = load i32, i32* @REG_EXTENDED
%11 = call i32 @regcomp(i32* %6, i8* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %3
br label %25
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @regexec(i32* %6, i8* %18, i32 0, i32* null, i32 0)
store i32 %19, i32* %8
%20 = call i32 @regfree(i32* %6)
%21 = load i32, i32* %8
%22 = load i32, i32* @REG_NOMATCH
%23 = icmp ne i32 %21, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %25
25: ; preds = %17, %14
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@.str = [26 x i8] c"Cannot compile regex: %s\0A\00"
@REG_NOMATCH = global i32 0
define i32 @route_match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @REG_EXTENDED
%6 = call i32 @regcomp(i32* %3, i8* %1, i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
10: ; preds = %2
%11 = call i32 @regexec(i32* %3, i8* %0, i32 0, i32* null, i32 0)
%12 = call i32 @regfree(i32* %3)
%13 = load i32, i32* @REG_NOMATCH
%14 = icmp ne i32 %11, %13
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %10, %8
%17 = phi i32 [ 0, %8 ], [ %15, %10 ]
ret i32 %17
}