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

/* Variables and functions */
int REG_EXTENDED;
int REG_ICASE;
int REG_NOSUB;
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, size_t const, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
bool Command_Test(char *cmdText) {
  int result;
  regex_t reg;
  regmatch_t pmatch[1];
  const size_t nmatch = 1;
  regcomp(&reg,
          "^(open\\s\\w+\\.\\w{2,5})|close|quit|((get|delete)\\s[0-9]+)|("
          "set\\s[0-9]+\\s.+)$",
          REG_EXTENDED | REG_ICASE | REG_NOSUB);
  result = regexec(&reg, cmdText, nmatch, pmatch, 0);
  if (result == 0) {
    regfree(&reg);
    return true;
  } else {
    regfree(&reg);
    return false;
  }
}


x86 assembly (clang, -O0):
<Command_Test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x1,-0x28(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    0x2e94(%rip),%rax
or     (%rax),%edx
mov    0x2e7b(%rip),%rax
or     (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <regcomp@plt>
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11aa <Command_Test+0x7a>
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ba <Command_Test+0x8a>
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Command_Test>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    0x2ea6(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rdi,%rbx
mov    0x2e88(%rip),%rax
or     (%rax),%edx
lea    0xea7(%rip),%rsi
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <regcomp@plt>
mov    %rsp,%rcx
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %r8d,%r8d
call   1050 <regexec@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %r14,%rdi
call   1030 <regfree@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [75 x i8] c"^(open\\s\\w+\\.\\w{2,5})|close|quit|((get|delete)\\s[0-9]+)|(set\\s[0-9]+\\s.+)$\00"
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
@REG_NOSUB = global i32 0
define i32 @Command_Test(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1 x i32]
%7 = alloca i64
store i8* %0, i8** %3
store i64 1, i64* %7
%8 = load i32, i32* @REG_EXTENDED
%9 = load i32, i32* @REG_ICASE
%10 = or i32 %8, %9
%11 = load i32, i32* @REG_NOSUB
%12 = or i32 %10, %11
%13 = call i32 @regcomp(i32* %5, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %3
%15 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%16 = call i32 @regexec(i32* %5, i8* %14, i64 1, i32* %15, i32 0)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %1
%20 = call i32 @regfree(i32* %5)
store i32 1, i32* %2
br label %23
21: ; preds = %1
%22 = call i32 @regfree(i32* %5)
store i32 0, i32* %2
br label %23
23: ; preds = %21, %19
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [75 x i8] c"^(open\\s\\w+\\.\\w{2,5})|close|quit|((get|delete)\\s[0-9]+)|(set\\s[0-9]+\\s.+)$\00"
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
@REG_NOSUB = global i32 0
define i32 @Command_Test(i8* %0) {
%2 = alloca i32
%3 = alloca [1 x i32]
%4 = bitcast i32* %2 to i8*
%5 = bitcast [1 x i32]* %3 to i8*
%6 = load i32, i32* @REG_EXTENDED
%7 = load i32, i32* @REG_ICASE
%8 = or i32 %7, %6
%9 = load i32, i32* @REG_NOSUB
%10 = or i32 %8, %9
%11 = call i32 @regcomp(i32* %2, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%13 = call i32 @regexec(i32* %2, i8* %0, i64 1, i32* %12, i32 0)
%14 = icmp eq i32 %13, 0
%15 = call i32 @regfree(i32* %2)
%16 = zext i1 %14 to i32
ret i32 %16
}