#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int rm_eo;
  int rm_so;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int /*<<< orphan*/ print_error(char *);
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
scalar_t__ regexec(int /*<<< orphan*/ *, char const *, size_t, TYPE_1__ *,
                   int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
void parse_line(char const *line, char **directive, char **value) {
  regex_t pregex;
  char *pattern =
      "^[[:blank:]]*([[:punct:][:alnum:]]+)[[:blank:]]*=[[:blank:]]*([^#]+)";
  size_t nmatch = 3;
  regmatch_t pmatch[3];
  regcomp(&pregex, pattern, REG_EXTENDED);
  if (0 == regexec(&pregex, line, nmatch, pmatch, 0)) {
    size_t size = pmatch[1].rm_eo - pmatch[1].rm_so + 1;
    if ((*directive = malloc(sizeof(char) * size)) == NULL)
      print_error("Out of memory");
    ;
    memcpy(*directive, line + pmatch[1].rm_so, size - 1);
    (*directive)[size - 1] = '\0';
    size = pmatch[2].rm_eo - pmatch[2].rm_so + 1;
    size_t i;
    for (i = size - 2; i > 0; i--) {
      if (*(line + pmatch[2].rm_so + i) == ' ' ||
          *(line + pmatch[2].rm_so + i) == '\t')
        size--;
      else
        break;
    }
    if ((*value = malloc(sizeof(char) * size)) == NULL)
      print_error("Out of memory");
    memcpy(*value, line + pmatch[2].rm_so, size - 1);
    (*value)[size - 1] = '\0';
  } else
    *value = *directive = NULL;
  regfree(&pregex);
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x3,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rdi
call   1050 <regcomp@plt>
mov    -0x8(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
xor    %r8d,%r8d
call   1080 <regexec@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    131d <parse_line+0x1bd>
mov    -0x48(%rbp),%eax
sub    -0x44(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11fe <parse_line+0x9e>
lea    0xe4c(%rip),%rdi
call   1030 <print_error@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x44(%rbp),%rax
add    %rax,%rsi
mov    -0x58(%rbp),%rdx
sub    $0x1,%rdx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x58(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%eax
sub    -0x3c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jbe    12ba <parse_line+0x15a>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
mov    -0x60(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     128e <parse_line+0x12e>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
mov    -0x60(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    129f <parse_line+0x13f>
mov    -0x58(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x58(%rbp)
jmp    12a4 <parse_line+0x144>
jmp    12ba <parse_line+0x15a>
jmp    12a9 <parse_line+0x149>
mov    -0x60(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x60(%rbp)
jmp    124b <parse_line+0xeb>
mov    -0x58(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    12e6 <parse_line+0x186>
lea    0xd64(%rip),%rdi
call   1030 <print_error@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x3c(%rbp),%rax
add    %rax,%rsi
mov    -0x58(%rbp),%rdx
sub    $0x1,%rdx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x58(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1333 <parse_line+0x1d3>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
lea    -0x1c(%rbp),%rdi
call   1040 <regfree@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
lea    0xe7b(%rip),%rsi
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <regcomp@plt>
lea    0x10(%rsp),%rcx
mov    $0x3,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %r8d,%r8d
call   1080 <regexec@plt>
test   %rax,%rax
je     11c3 <parse_line+0x63>
movq   $0x0,(%r12)
movq   $0x0,(%r14)
jmp    128e <parse_line+0x12e>
movslq 0x18(%rsp),%rbx
movslq 0x1c(%rsp),%rbp
sub    %rbp,%rbx
lea    0x1(%rbx),%edi
call   1070 <malloc@plt>
mov    %rax,(%r12)
test   %rax,%rax
jne    11f5 <parse_line+0x95>
lea    0xe5d(%rip),%rdi
call   1030 <print_error@plt>
mov    (%r12),%rax
mov    0x1c(%rsp),%ebp
movslq %ebp,%rsi
add    %r15,%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    (%r12),%rax
movb   $0x0,(%rax,%rbx,1)
mov    0x20(%rsp),%eax
mov    0x24(%rsp),%ebp
sub    %ebp,%eax
add    $0x1,%eax
movslq %eax,%rbx
cmp    $0x2,%rbx
je     124a <parse_line+0xea>
movslq %ebp,%rax
add    %r15,%rax
add    $0xfffffffffffffffe,%rax
jmp    123a <parse_line+0xda>
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
je     124a <parse_line+0xea>
movzbl (%rax,%rbx,1),%ecx
cmp    $0x20,%cl
je     1230 <parse_line+0xd0>
cmp    $0x9,%cl
je     1230 <parse_line+0xd0>
jmp    124f <parse_line+0xef>
mov    $0x2,%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
jne    1271 <parse_line+0x111>
lea    0xde0(%rip),%rdi
call   1030 <print_error@plt>
mov    (%r14),%rax
mov    0x24(%rsp),%ebp
movslq %ebp,%rcx
add    %rcx,%r15
lea    -0x1(%rbx),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
mov    (%r14),%rax
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xc(%rsp),%rdi
call   1040 <regfree@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [69 x i8] c"^[[:blank:]]*([[:punct:][:alnum:]]+)[[:blank:]]*=[[:blank:]]*([^#]+)\00"
@REG_EXTENDED = global i32 0
@.str.1 = [14 x i8] c"Out of memory\00"
define void @parse_line(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca [3 x %struct.TYPE_3__]
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i8** %8
store i64 3, i64* %9
%13 = load i8*, i8** %8
%14 = load i32, i32* @REG_EXTENDED
%15 = call i32 @regcomp(i32* %7, i8* %13, i32 %14)
%16 = load i8*, i8** %4
%17 = load i64, i64* %9
%18 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 0
%19 = call i64 @regexec(i32* %7, i8* %16, i64 %17, %struct.TYPE_3__* %18, i32 0)
%20 = icmp eq i64 0, %19
br i1 %20, label %21, label %128
21: ; preds = %3
%22 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 1
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 1
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = sub nsw i32 %24, %27
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
store i64 %30, i64* %11
%31 = load i64, i64* %11
%32 = mul i64 1, %31
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
%35 = load i8**, i8*** %5
store i8* %34, i8** %35
%36 = icmp eq i8* %34, null
br i1 %36, label %37, label %39
37: ; preds = %21
%38 = call i32 @print_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %21
%40 = load i8**, i8*** %5
%41 = load i8*, i8** %40
%42 = load i8*, i8** %4
%43 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 1
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %42, i64 %46
%48 = load i64, i64* %11
%49 = sub i64 %48, 1
%50 = call i32 @memcpy(i8* %41, i8* %47, i64 %49)
%51 = load i8**, i8*** %5
%52 = load i8*, i8** %51
%53 = load i64, i64* %11
%54 = sub i64 %53, 1
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
%56 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 2
%57 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 2
%60 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %59, i32 0, i32 1
%61 = load i32, i32* %60
%62 = sub nsw i32 %58, %61
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
store i64 %64, i64* %11
%65 = load i64, i64* %11
%66 = sub i64 %65, 2
store i64 %66, i64* %12
br label %67
67: ; preds = %99, %39
%68 = load i64, i64* %12
%69 = icmp ugt i64 %68, 0
br i1 %69, label %70, label %102
70: ; preds = %67
%71 = load i8*, i8** %4
%72 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 2
%73 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %71, i64 %75
%77 = load i64, i64* %12
%78 = getelementptr inbounds i8, i8* %76, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 32
br i1 %81, label %94, label %82
82: ; preds = %70
%83 = load i8*, i8** %4
%84 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 2
%85 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %84, i32 0, i32 1
%86 = load i32, i32* %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %83, i64 %87
%89 = load i64, i64* %12
%90 = getelementptr inbounds i8, i8* %88, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 9
br i1 %93, label %94, label %97
94: ; preds = %82, %70
%95 = load i64, i64* %11
%96 = add i64 %95, -1
store i64 %96, i64* %11
br label %98
97: ; preds = %82
br label %102
98: ; preds = %94
br label %99
99: ; preds = %98
%100 = load i64, i64* %12
%101 = add i64 %100, -1
store i64 %101, i64* %12
br label %67
102: ; preds = %97, %67
%103 = load i64, i64* %11
%104 = mul i64 1, %103
%105 = trunc i64 %104 to i32
%106 = call i8* @malloc(i32 %105)
%107 = load i8**, i8*** %6
store i8* %106, i8** %107
%108 = icmp eq i8* %106, null
br i1 %108, label %109, label %111
109: ; preds = %102
%110 = call i32 @print_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %111
111: ; preds = %109, %102
%112 = load i8**, i8*** %6
%113 = load i8*, i8** %112
%114 = load i8*, i8** %4
%115 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %10, i64 0, i64 2
%116 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %115, i32 0, i32 1
%117 = load i32, i32* %116
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %114, i64 %118
%120 = load i64, i64* %11
%121 = sub i64 %120, 1
%122 = call i32 @memcpy(i8* %113, i8* %119, i64 %121)
%123 = load i8**, i8*** %6
%124 = load i8*, i8** %123
%125 = load i64, i64* %11
%126 = sub i64 %125, 1
%127 = getelementptr inbounds i8, i8* %124, i64 %126
store i8 0, i8* %127
br label %131
128: ; preds = %3
%129 = load i8**, i8*** %5
store i8* null, i8** %129
%130 = load i8**, i8*** %6
store i8* null, i8** %130
br label %131
131: ; preds = %128, %111
%132 = call i32 @regfree(i32* %7)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [69 x i8] c"^[[:blank:]]*([[:punct:][:alnum:]]+)[[:blank:]]*=[[:blank:]]*([^#]+)\00"
@REG_EXTENDED = global i32 0
@.str.1 = [14 x i8] c"Out of memory\00"
define void @parse_line(i8* %0, i8** nocapture %1, i8** nocapture %2) {
%4 = alloca i32
%5 = alloca [3 x %struct.TYPE_3__]
%6 = bitcast i32* %4 to i8*
%7 = bitcast [3 x %struct.TYPE_3__]* %5 to i8*
%8 = load i32, i32* @REG_EXTENDED
%9 = call i32 @regcomp(i32* %4, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %5, i64 0, i64 0
%11 = call i64 @regexec(i32* %4, i8* %0, i64 3, %struct.TYPE_3__* %10, i32 0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %74
13: ; preds = %3
%14 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %5, i64 0, i64 1, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %5, i64 0, i64 1, i32 1
%17 = load i32, i32* %16
%18 = sub nsw i32 %15, %17
%19 = add nsw i32 %18, 1
%20 = call i8* @malloc(i32 %19)
store i8* %20, i8** %1
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = call i32 @print_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8*, i8** %1
%25 = load i32, i32* %16
br label %26
26: ; preds = %22, %13
%27 = phi i32 [ %25, %22 ], [ %17, %13 ]
%28 = phi i8* [ %24, %22 ], [ %20, %13 ]
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = sext i32 %18 to i64
%32 = call i32 @memcpy(i8* %28, i8* %30, i64 %31)
%33 = load i8*, i8** %1
%34 = getelementptr inbounds i8, i8* %33, i64 %31
store i8 0, i8* %34
%35 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %5, i64 0, i64 2, i32 0
%36 = load i32, i32* %35
%37 = getelementptr inbounds [3 x %struct.TYPE_3__], [3 x %struct.TYPE_3__]* %5, i64 0, i64 2, i32 1
%38 = load i32, i32* %37
%39 = add i32 %36, 1
%40 = sub i32 %39, %38
%41 = sext i32 %40 to i64
%42 = add nsw i64 %41, -2
%43 = icmp eq i64 %42, 0
br i1 %43, label %56, label %44
44: ; preds = %26
%45 = sext i32 %38 to i64
%46 = getelementptr inbounds i8, i8* %0, i64 %45
br label %47
47: ; preds = %44, %52
%48 = phi i64 [ %42, %44 ], [ %54, %52 ]
%49 = phi i64 [ %41, %44 ], [ %53, %52 ]
%50 = getelementptr inbounds i8, i8* %46, i64 %48
%51 = load i8, i8* %50
switch i8 %51, label %56 [
i8 32, label %52
i8 9, label %52
]
52: ; preds = %47, %47
%53 = add i64 %49, -1
%54 = add i64 %48, -1
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %47
56: ; preds = %52, %47, %26
%57 = phi i64 [ 2, %26 ], [ %49, %47 ], [ 2, %52 ]
%58 = trunc i64 %57 to i32
%59 = call i8* @malloc(i32 %58)
store i8* %59, i8** %2
%60 = icmp eq i8* %59, null
br i1 %60, label %61, label %65
61: ; preds = %56
%62 = call i32 @print_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%63 = load i8*, i8** %2
%64 = load i32, i32* %37
br label %65
65: ; preds = %61, %56
%66 = phi i32 [ %64, %61 ], [ %38, %56 ]
%67 = phi i8* [ %63, %61 ], [ %59, %56 ]
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds i8, i8* %0, i64 %68
%70 = add i64 %57, -1
%71 = call i32 @memcpy(i8* %67, i8* %69, i64 %70)
%72 = load i8*, i8** %2
%73 = getelementptr inbounds i8, i8* %72, i64 %70
store i8 0, i8* %73
br label %75
74: ; preds = %3
store i8* null, i8** %1
store i8* null, i8** %2
br label %75
75: ; preds = %74, %65
%76 = call i32 @regfree(i32* %4)
ret void
}