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

/* Variables and functions */
int REG_NOMATCH;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int is_valid_line(char *line) {
  int regres;
  regex_t regex;
  char *regerr;
  regres = regcomp(&regex,
                   "^[ 	]*\\(\\(\\([*]\\|[+]\\|[-]\\|[/]\\|[%]\\)\\([ 	"
                   "]\\+\\)\\(\\([0-9]\\+\\)\\|\\([a-z]\\)\\)\\)\\|\\([=][ "
                   "	]\\+[a-z]\\)\\|\\([=]\\)\\)[ 	]*$",
                   0);
  regres = regexec(&regex, line, 0, NULL, 0);
  if (!regres) {
    regfree(&regex);
    return 1;
  } else if (regres == REG_NOMATCH) {
    regfree(&regex);
    return 0;
  } else {
    regfree(&regex);
    regerror(regres, &regex, regerr, sizeof(regerr));
    fputs(regerr, stderr);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<is_valid_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe89(%rip),%rsi
xor    %edx,%edx
call   1050 <regcomp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1070 <regexec@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ba <is_valid_line+0x5a>
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x1,-0x4(%rbp)
jmp    121b <is_valid_line+0xbb>
mov    -0x14(%rbp),%eax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%eax
jne    11e1 <is_valid_line+0x81>
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
movl   $0x0,-0x4(%rbp)
jmp    121b <is_valid_line+0xbb>
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rdx
lea    -0x18(%rbp),%rsi
mov    $0x8,%ecx
call   1060 <regerror@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_line>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbp
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <regcomp@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <regexec@plt>
test   %eax,%eax
je     11dc <is_valid_line+0x7c>
mov    %eax,%ebp
mov    0x2e45(%rip),%rax
mov    (%rax),%ebx
lea    0xc(%rsp),%rdi
call   1030 <regfree@plt>
cmp    %ebx,%ebp
je     11ec <is_valid_line+0x8c>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%ecx
call   1060 <regerror@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xc(%rsp),%rdi
call   1030 <regfree@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [113 x i8] c"^[ \09]*\\(\\(\\([*]\\|[+]\\|[-]\\|[/]\\|[%]\\)\\([ \09]\\+\\)\\(\\([0-9]\\+\\)\\|\\([a-z]\\)\\)\\)\\|\\([=][ \09]\\+[a-z]\\)\\|\\([=]\\)\\)[ \09]*$\00"
@REG_NOMATCH = global i32 0
@stderr = global i32 0
define i32 @is_valid_line(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
%7 = call i32 @regcomp(i32* %5, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %7, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @regexec(i32* %5, i8* %8, i32 0, i32* null, i32 0)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %1
%13 = call i32 @regfree(i32* %5)
store i32 1, i32* %2
br label %29
14: ; preds = %1
%15 = load i32, i32* %4
%16 = load i32, i32* @REG_NOMATCH
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @regfree(i32* %5)
store i32 0, i32* %2
br label %29
20: ; preds = %14
%21 = call i32 @regfree(i32* %5)
%22 = load i32, i32* %4
%23 = load i8*, i8** %6
%24 = call i32 @regerror(i32 %22, i32* %5, i8* %23, i32 8)
%25 = load i8*, i8** %6
%26 = load i32, i32* @stderr
%27 = call i32 @fputs(i8* %25, i32 %26)
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %18, %12
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [113 x i8] c"^[ \09]*\\(\\(\\([*]\\|[+]\\|[-]\\|[/]\\|[%]\\)\\([ \09]\\+\\)\\(\\([0-9]\\+\\)\\|\\([a-z]\\)\\)\\)\\|\\([=][ \09]\\+[a-z]\\)\\|\\([=]\\)\\)[ \09]*$\00"
@REG_NOMATCH = global i32 0
@stderr = global i32 0
define i32 @is_valid_line(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @regcomp(i32* %2, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = call i32 @regexec(i32* %2, i8* %0, i32 0, i32* null, i32 0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @regfree(i32* %2)
br label %18
9: ; preds = %1
%10 = load i32, i32* @REG_NOMATCH
%11 = icmp eq i32 %5, %10
%12 = call i32 @regfree(i32* %2)
br i1 %11, label %18, label %13
13: ; preds = %9
%14 = call i32 @regerror(i32 %5, i32* %2, i8* undef, i32 8)
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* undef, i32 %15)
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %9, %7
%19 = phi i32 [ 1, %7 ], [ 0, %9 ]
ret i32 %19
}