#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ skip_lws(char const *);
char *strdupdelim(char const *, char const *);
int /*<<< orphan*/ strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int /*<<< orphan*/);
int extract_header_attr(const char *au, const char *attr_name, char **ret) {
  const char *cp, *ep;
  ep = cp = au;
  if (strncmp(cp, attr_name, strlen(attr_name)) == 0) {
    cp += strlen(attr_name);
    if (!*cp)
      return -1;
    cp += skip_lws(cp);
    if (*cp != '=')
      return -1;
    if (!*++cp)
      return -1;
    cp += skip_lws(cp);
    if (*cp != '\"')
      return -1;
    if (!*++cp)
      return -1;
    for (ep = cp; *ep && *ep != '\"'; ep++)
      ;
    if (!*ep)
      return -1;
    do {
      if (*ret)
        free(*ret);
    } while (0);
    *ret = strdupdelim(cp, ep);
    return ep - au + 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<extract_header_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1346 <extract_header_attr+0x1f6>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11d4 <extract_header_attr+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
mov    -0x28(%rbp),%rdi
call   1060 <skip_lws@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     1209 <extract_header_attr+0xb9>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmpb   $0x0,0x1(%rax)
jne    122e <extract_header_attr+0xde>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
mov    -0x28(%rbp),%rdi
call   1060 <skip_lws@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1263 <extract_header_attr+0x113>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
cmpb   $0x0,0x1(%rax)
jne    1288 <extract_header_attr+0x138>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x41(%rbp)
je     12b5 <extract_header_attr+0x165>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    12c5 <extract_header_attr+0x175>
jmp    12db <extract_header_attr+0x18b>
jmp    12ca <extract_header_attr+0x17a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1290 <extract_header_attr+0x140>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12f4 <extract_header_attr+0x1a4>
movl   $0xffffffff,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
jmp    12f9 <extract_header_attr+0x1a9>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1313 <extract_header_attr+0x1c3>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1318 <extract_header_attr+0x1c8>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <strdupdelim@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x4(%rbp)
jmp    134d <extract_header_attr+0x1fd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_header_attr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     1193 <extract_header_attr+0x43>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
cltq
mov    $0xffffffff,%r13d
cmpb   $0x0,(%rbx,%rax,1)
je     1181 <extract_header_attr+0x31>
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <skip_lws@plt>
mov    %eax,%r12d
cltq
cmpb   $0x3d,(%rbx,%rax,1)
jne    1181 <extract_header_attr+0x31>
add    %rax,%rbx
cmpb   $0x0,0x1(%rbx)
je     1181 <extract_header_attr+0x31>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1060 <skip_lws@plt>
movslq %eax,%rcx
cmpb   $0x22,(%rbx,%rcx,1)
jne    1181 <extract_header_attr+0x31>
add    %rcx,%rbx
mov    0x1(%rbx),%cl
test   %cl,%cl
je     1181 <extract_header_attr+0x31>
add    $0x1,%rbx
add    %eax,%r12d
lea    (%r15,%r12,1),%r13d
add    $0x3,%r13d
mov    %rbx,%r15
test   %cl,%cl
je     1216 <extract_header_attr+0xc6>
cmp    $0x22,%cl
je     1221 <extract_header_attr+0xd1>
movzbl 0x1(%r15),%ecx
add    $0x1,%r15
add    $0x1,%r13d
test   %cl,%cl
jne    1200 <extract_header_attr+0xb0>
mov    $0xffffffff,%r13d
jmp    1181 <extract_header_attr+0x31>
mov    (%r14),%rdi
test   %rdi,%rdi
je     122e <extract_header_attr+0xde>
call   1030 <free@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strdupdelim@plt>
mov    %rax,(%r14)
jmp    1181 <extract_header_attr+0x31>

LLVM IR (-O0):
define i32 @extract_header_attr(i8* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%10 = load i8*, i8** %5
store i8* %10, i8** %8
store i8* %10, i8** %9
%11 = load i8*, i8** %8
%12 = load i8*, i8** %6
%13 = load i8*, i8** %6
%14 = call i32 @strlen(i8* %13)
%15 = call i64 @strncmp(i8* %11, i8* %12, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %106
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = load i8*, i8** %8
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %17
store i32 -1, i32* %4
br label %107
27: ; preds = %17
%28 = load i8*, i8** %8
%29 = call i32 @skip_lws(i8* %28)
%30 = load i8*, i8** %8
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 61
br i1 %36, label %37, label %38
37: ; preds = %27
store i32 -1, i32* %4
br label %107
38: ; preds = %27
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %8
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38
store i32 -1, i32* %4
br label %107
44: ; preds = %38
%45 = load i8*, i8** %8
%46 = call i32 @skip_lws(i8* %45)
%47 = load i8*, i8** %8
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds i8, i8* %47, i64 %48
store i8* %49, i8** %8
%50 = load i8*, i8** %8
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 34
br i1 %53, label %54, label %55
54: ; preds = %44
store i32 -1, i32* %4
br label %107
55: ; preds = %44
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %8
%58 = load i8, i8* %57
%59 = icmp ne i8 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %55
store i32 -1, i32* %4
br label %107
61: ; preds = %55
%62 = load i8*, i8** %8
store i8* %62, i8** %9
br label %63
63: ; preds = %76, %61
%64 = load i8*, i8** %9
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = load i8*, i8** %9
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %71, 34
br label %73
73: ; preds = %68, %63
%74 = phi i1 [ false, %63 ], [ %72, %68 ]
br i1 %74, label %75, label %79
75: ; preds = %73
br label %76
76: ; preds = %75
%77 = load i8*, i8** %9
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %9
br label %63
79: ; preds = %73
%80 = load i8*, i8** %9
%81 = load i8, i8* %80
%82 = icmp ne i8 %81, 0
br i1 %82, label %84, label %83
83: ; preds = %79
store i32 -1, i32* %4
br label %107
84: ; preds = %79
br label %85
85: ; preds = %84
%86 = load i8**, i8*** %7
%87 = load i8*, i8** %86
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %93
89: ; preds = %85
%90 = load i8**, i8*** %7
%91 = load i8*, i8** %90
%92 = call i32 @free(i8* %91)
br label %93
93: ; preds = %89, %85
br label %94
94: ; preds = %93
%95 = load i8*, i8** %8
%96 = load i8*, i8** %9
%97 = call i8* @strdupdelim(i8* %95, i8* %96)
%98 = load i8**, i8*** %7
store i8* %97, i8** %98
%99 = load i8*, i8** %9
%100 = load i8*, i8** %5
%101 = ptrtoint i8* %99 to i64
%102 = ptrtoint i8* %100 to i64
%103 = sub i64 %101, %102
%104 = add nsw i64 %103, 1
%105 = trunc i64 %104 to i32
store i32 %105, i32* %4
br label %107
106: ; preds = %3
store i32 0, i32* %4
br label %107
107: ; preds = %106, %94, %83, %60, %54, %43, %37, %26
%108 = load i32, i32* %4
ret i32 %108
}

LLVM IR (-O2):
define i32 @extract_header_attr(i8* %0, i8* %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %51
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %1)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %51, label %13
13: ; preds = %7
%14 = tail call i32 @skip_lws(i8* %10)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %10, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 61
br i1 %18, label %19, label %51
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %51, label %23
23: ; preds = %19
%24 = tail call i32 @skip_lws(i8* %20)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %20, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 34
br i1 %28, label %29, label %51
29: ; preds = %23
%30 = getelementptr inbounds i8, i8* %26, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %51, label %33
33: ; preds = %29, %36
%34 = phi i8 [ %38, %36 ], [ %31, %29 ]
%35 = phi i8* [ %37, %36 ], [ %30, %29 ]
switch i8 %34, label %36 [
i8 0, label %51
i8 34, label %39
]
36: ; preds = %33
%37 = getelementptr inbounds i8, i8* %35, i64 1
%38 = load i8, i8* %37
br label %33
39: ; preds = %33
%40 = load i8*, i8** %2
%41 = icmp eq i8* %40, null
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = tail call i32 @free(i8* %40)
br label %44
44: ; preds = %42, %39
%45 = tail call i8* @strdupdelim(i8* %30, i8* %35)
store i8* %45, i8** %2
%46 = ptrtoint i8* %35 to i64
%47 = ptrtoint i8* %0 to i64
%48 = sub i64 %46, %47
%49 = trunc i64 %48 to i32
%50 = add i32 %49, 1
br label %51
51: ; preds = %33, %3, %29, %23, %19, %13, %7, %44
%52 = phi i32 [ %50, %44 ], [ -1, %7 ], [ -1, %13 ], [ -1, %19 ], [ -1, %23 ], [ -1, %29 ], [ 0, %3 ], [ -1, %33 ]
ret i32 %52
}