#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fxmlDecodeEntity(char **, char **);
char *malloc(int);
int /*<<< orphan*/ skipWhitespace(char **);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
char *strdup(char *);
char *extractAttrValue(char *start) {
  char *s = start;
  char *e, *out, *o;
  char quote;
  skipWhitespace(&s);
  if (*s != '=') {
    fprintf(stderr, "FXML: malformed attribute lacks equals sign.\n");
    return strdup("");
  }
  s++;
  skipWhitespace(&s);
  if (*s != '"' && *s != '\'') {
    fprintf(stderr, "FXML: malformed attribute lacks quotes.\n");
    return strdup("");
  }
  quote = *s;
  s++;
  e = strchr(s, quote);
  out = o = malloc(e - s + 1);
  if (!out) {
    fprintf(stderr, "FXML: OOM in extractAttrValue.\n");
    exit(1);
  }
  while (s < e) {
    if (*s == '&') {
      fxmlDecodeEntity(&s, &o);
    } else {
      *o++ = *s++;
    }
  }
  *o = 0;
  return out;
}


x86 assembly (clang, -O0):
<extractAttrValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <skipWhitespace@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     11c7 <extractAttrValue+0x57>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xebd(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    12ff <extractAttrValue+0x18f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <skipWhitespace@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1226 <extractAttrValue+0xb6>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     1226 <extractAttrValue+0xb6>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe5e(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    12ff <extractAttrValue+0x18f>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x31(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
movsbl -0x31(%rbp),%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1294 <extractAttrValue+0x124>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1299 <extractAttrValue+0x129>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    12f0 <extractAttrValue+0x180>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    12c9 <extractAttrValue+0x159>
lea    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <fxmlDecodeEntity@plt>
jmp    12eb <extractAttrValue+0x17b>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    1299 <extractAttrValue+0x129>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractAttrValue>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,(%rsp)
mov    %rsp,%rdi
call   1060 <skipWhitespace@plt>
mov    (%rsp),%rax
cmpb   $0x3d,(%rax)
jne    1236 <extractAttrValue+0xc6>
add    $0x1,%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1060 <skipWhitespace@plt>
mov    (%rsp),%rbx
mov    (%rbx),%al
cmp    $0x22,%al
je     11b8 <extractAttrValue+0x48>
cmp    $0x27,%al
jne    1248 <extractAttrValue+0xd8>
add    $0x1,%rbx
mov    %rbx,(%rsp)
movsbl %al,%esi
mov    %rbx,%rdi
call   1040 <strchr@plt>
mov    %rax,%r15
mov    %r15d,%edi
sub    %ebx,%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1287 <extractAttrValue+0x117>
mov    %rax,%r14
cmp    %r15,%rbx
jae    1273 <extractAttrValue+0x103>
mov    %rsp,%r12
lea    0x8(%rsp),%r13
jmp    1224 <extractAttrValue+0xb4>
nop
lea    0x1(%rbx),%rax
mov    %rax,(%rsp)
movzbl (%rbx),%eax
mov    0x8(%rsp),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,0x8(%rsp)
mov    %al,(%rcx)
mov    (%rsp),%rbx
cmp    %r15,%rbx
jae    126e <extractAttrValue+0xfe>
cmpb   $0x26,(%rbx)
jne    1200 <extractAttrValue+0x90>
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <fxmlDecodeEntity@plt>
jmp    121b <extractAttrValue+0xab>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
jmp    1258 <extractAttrValue+0xe8>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe12(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,%r14
jmp    1276 <extractAttrValue+0x106>
mov    0x8(%rsp),%rax
movb   $0x0,(%rax)
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"FXML: malformed attribute lacks equals sign.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [41 x i8] c"FXML: malformed attribute lacks quotes.\0A\00"
@.str.3 = [32 x i8] c"FXML: OOM in extractAttrValue.\0A\00"
define i8* @extractAttrValue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
store i8* %0, i8** %3
%9 = load i8*, i8** %3
store i8* %9, i8** %4
%10 = call i32 @skipWhitespace(i8** %4)
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 61
br i1 %14, label %15, label %19
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%18 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %2
br label %80
19: ; preds = %1
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = call i32 @skipWhitespace(i8** %4)
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 34
br i1 %26, label %27, label %36
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 39
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%35 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %35, i8** %2
br label %80
36: ; preds = %27, %19
%37 = load i8*, i8** %4
%38 = load i8, i8* %37
store i8 %38, i8* %8
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
%41 = load i8*, i8** %4
%42 = load i8, i8* %8
%43 = call i8* @strchr(i8* %41, i8 signext %42)
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = load i8*, i8** %4
%46 = ptrtoint i8* %44 to i64
%47 = ptrtoint i8* %45 to i64
%48 = sub i64 %46, %47
%49 = add nsw i64 %48, 1
%50 = trunc i64 %49 to i32
%51 = call i8* @malloc(i32 %50)
store i8* %51, i8** %7
store i8* %51, i8** %6
%52 = load i8*, i8** %6
%53 = icmp ne i8* %52, null
br i1 %53, label %58, label %54
54: ; preds = %36
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %36
br label %59
59: ; preds = %76, %58
%60 = load i8*, i8** %4
%61 = load i8*, i8** %5
%62 = icmp ult i8* %60, %61
br i1 %62, label %63, label %77
63: ; preds = %59
%64 = load i8*, i8** %4
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 38
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 @fxmlDecodeEntity(i8** %4, i8** %7)
br label %76
70: ; preds = %63
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %4
%73 = load i8, i8* %71
%74 = load i8*, i8** %7
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %7
store i8 %73, i8* %74
br label %76
76: ; preds = %70, %68
br label %59
77: ; preds = %59
%78 = load i8*, i8** %7
store i8 0, i8* %78
%79 = load i8*, i8** %6
store i8* %79, i8** %2
br label %80
80: ; preds = %77, %32, %15
%81 = load i8*, i8** %2
ret i8* %81
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"FXML: malformed attribute lacks equals sign.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [41 x i8] c"FXML: malformed attribute lacks quotes.\0A\00"
@.str.3 = [32 x i8] c"FXML: OOM in extractAttrValue.\0A\00"
define i8* @extractAttrValue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
store i8* %0, i8** %2
%5 = bitcast i8** %3 to i8*
%6 = call i32 @skipWhitespace(i8** %2)
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 61
br i1 %9, label %14, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%13 = call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %57
14: ; preds = %1
%15 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %15, i8** %2
%16 = call i32 @skipWhitespace(i8** %2)
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 34, label %23
i8 39, label %23
]
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%22 = call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %57
23: ; preds = %14, %14
%24 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %24, i8** %2
%25 = call i8* @strchr(i8* %24, i8 signext %18)
%26 = ptrtoint i8* %25 to i64
%27 = ptrtoint i8* %24 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = add i32 %29, 1
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %3
%32 = icmp eq i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %23
%34 = icmp ult i8* %24, %25
br i1 %34, label %39, label %55
35: ; preds = %23
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %33, %50
%40 = phi i8* [ %51, %50 ], [ %24, %33 ]
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 38
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @fxmlDecodeEntity(i8** %2, i8** %3)
br label %50
45: ; preds = %39
%46 = getelementptr inbounds i8, i8* %40, i64 1
store i8* %46, i8** %2
%47 = load i8, i8* %40
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 1
store i8* %49, i8** %3
store i8 %47, i8* %48
br label %50
50: ; preds = %45, %43
%51 = load i8*, i8** %2
%52 = icmp ult i8* %51, %25
br i1 %52, label %39, label %53
53: ; preds = %50
%54 = load i8*, i8** %3
br label %55
55: ; preds = %53, %33
%56 = phi i8* [ %54, %53 ], [ %31, %33 ]
store i8 0, i8* %56
br label %57
57: ; preds = %55, %19, %10
%58 = phi i8* [ %13, %10 ], [ %22, %19 ], [ %31, %55 ]
ret i8* %58
}