#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 REG_EXTENDED;
int REG_NOSUB;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int);
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                   int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
bool validarCadena(char *pCadena) {
  regex_t expresion;
  if (regcomp(&expresion, "[ |\n|\t]*[+|-]?[[:digit:]]+",
              REG_EXTENDED | REG_NOSUB) != 0) {
    printf("Error\n");
    exit(1);
  }
  if (regexec(&expresion, pCadena, 0, NULL, 0) == 0) {
    regfree(&expresion);
    return true;
  } else {
    regfree(&expresion);
    return false;
  }
}


x86 assembly (clang, -O0):
<validarCadena>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
mov    0x2e74(%rip),%rax
or     (%rax),%edx
lea    -0x14(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1050 <regcomp@plt>
cmp    $0x0,%rax
je     119e <validarCadena+0x4e>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1060 <regexec@plt>
cmp    $0x0,%rax
jne    11d4 <validarCadena+0x84>
lea    -0x14(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <validarCadena+0x94>
lea    -0x14(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validarCadena>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e7a(%rip),%rax
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xe90(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1050 <regcomp@plt>
test   %rax,%rax
jne    11b0 <validarCadena+0x60>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %r14,%rdi
call   1040 <regfree@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"[ |\0A|\09]*[+|-]?[[:digit:]]+\00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@.str.1 = [7 x i8] c"Error\0A\00"
define i32 @validarCadena(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i32, i32* @REG_EXTENDED
%6 = load i32, i32* @REG_NOSUB
%7 = or i32 %5, %6
%8 = call i64 @regcomp(i32* %4, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i64 @regexec(i32* %4, i8* %14, i32 0, i32* null, i32 0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @regfree(i32* %4)
store i32 1, i32* %2
br label %21
19: ; preds = %13
%20 = call i32 @regfree(i32* %4)
store i32 0, i32* %2
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [27 x i8] c"[ |\0A|\09]*[+|-]?[[:digit:]]+\00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@str = [6 x i8] c"Error\00"
define i32 @validarCadena(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @REG_EXTENDED
%5 = load i32, i32* @REG_NOSUB
%6 = or i32 %5, %4
%7 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = call i64 @regexec(i32* %2, i8* %0, i32 0, i32* null, i32 0)
%14 = icmp eq i64 %13, 0
%15 = call i32 @regfree(i32* %2)
%16 = zext i1 %14 to i32
ret i32 %16
}