#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_NOSUB;
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                   int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int check_filter(char *filtername, char *val) {
  regex_t tmp;
  regcomp(&tmp, "^\\(0x\\)\\?[0-9]\\+$", REG_NOSUB);
  if (regexec(&tmp, val, 0, 0, 0)) {
    regfree(&tmp);
    return -1;
  } else {
    regfree(&tmp);
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1040 <regcomp@plt>
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <regexec@plt>
cmp    $0x0,%rax
je     118e <check_filter+0x5e>
lea    -0x1c(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <check_filter+0x6e>
lea    -0x1c(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_filter>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
lea    0xeb9(%rip),%rsi
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <regcomp@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <regfree@plt>
neg    %rbx
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"^\\(0x\\)\\?[0-9]\\+$\00"
@REG_NOSUB = global i32 0
define i32 @check_filter(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i32, i32* @REG_NOSUB
%8 = call i32 @regcomp(i32* %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %5
%10 = call i64 @regexec(i32* %6, i8* %9, i32 0, i32 0, i32 0)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @regfree(i32* %6)
store i32 -1, i32* %3
br label %16
14: ; preds = %2
%15 = call i32 @regfree(i32* %6)
store i32 0, i32* %3
br label %16
16: ; preds = %14, %12
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@.str = [18 x i8] c"^\\(0x\\)\\?[0-9]\\+$\00"
@REG_NOSUB = global i32 0
define i32 @check_filter(i8* nocapture readnone %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @REG_NOSUB
%6 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i64 @regexec(i32* %3, i8* %1, i32 0, i32 0, i32 0)
%8 = icmp ne i64 %7, 0
%9 = call i32 @regfree(i32* %3)
%10 = sext i1 %8 to i32
ret i32 %10
}