#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*/ printf(char *);
char *strcasestr(char *, char *);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strspn(char *, char *);
char *tagoption(char *tag, char *option) {
  char *tmp = strcasestr(tag, option);
  if (0)
    printf("tagoption\n");
  if (!tmp)
    return NULL;
  tmp += strlen(option) + strspn(tmp + strlen(option), " =");
  if (tmp[0] == '\"') {
    tmp++;
    if (strchr(tmp, '\"'))
      *strchr(tmp, '\"') = '\0';
    else
      tmp[strlen(tmp) - 1] == '\0';
  } else if (strchr(tmp, ' '))
    *strchr(tmp, ' ') = '\0';
  else
    *strchr(tmp, '>') = '\0';
  return tmp;
}


x86 assembly (clang, -O0):
<tagoption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcasestr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1179 <tagoption+0x39>
movq   $0x0,-0x8(%rbp)
jmp    1264 <tagoption+0x124>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xe57(%rip),%rsi
call   1050 <strspn@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1218 <tagoption+0xd8>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     120a <tagoption+0xca>
mov    -0x20(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
jmp    1213 <tagoption+0xd3>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
jmp    125c <tagoption+0x11c>
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1246 <tagoption+0x106>
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
jmp    1257 <tagoption+0x117>
mov    -0x20(%rbp),%rdi
mov    $0x3e,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
jmp    125c <tagoption+0x11c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tagoption>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1060 <strcasestr@plt>
test   %rax,%rax
je     11ad <tagoption+0x6d>
mov    %rax,%r14
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
lea    0xe85(%rip),%rsi
call   1050 <strspn@plt>
add    %r12,%rax
add    %rax,%r14
cmpb   $0x22,(%r15,%rax,1)
jne    11b2 <tagoption+0x72>
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x22,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11d1 <tagoption+0x91>
mov    %r14,%rdi
call   1030 <strlen@plt>
jmp    11d4 <tagoption+0x94>
xor    %r14d,%r14d
jmp    11d4 <tagoption+0x94>
mov    %r14,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11d1 <tagoption+0x91>
mov    %r14,%rdi
mov    $0x3e,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" =\00"
define i8* @tagoption(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i8* @strcasestr(i8* %7, i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %65
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = load i8*, i8** %6
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = call i64 @strspn(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = add nsw i64 %16, %22
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 %23
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 34
br i1 %30, label %31, label %52
31: ; preds = %13
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %6
%34 = load i8*, i8** %6
%35 = call i8* @strchr(i8* %34, i8 signext 34)
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i8*, i8** %6
%39 = call i8* @strchr(i8* %38, i8 signext 34)
store i8 0, i8* %39
br label %51
40: ; preds = %31
%41 = load i8*, i8** %6
%42 = load i8*, i8** %6
%43 = call i32 @strlen(i8* %42)
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 0
%50 = zext i1 %49 to i32
br label %51
51: ; preds = %40, %37
br label %63
52: ; preds = %13
%53 = load i8*, i8** %6
%54 = call i8* @strchr(i8* %53, i8 signext 32)
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = load i8*, i8** %6
%58 = call i8* @strchr(i8* %57, i8 signext 32)
store i8 0, i8* %58
br label %62
59: ; preds = %52
%60 = load i8*, i8** %6
%61 = call i8* @strchr(i8* %60, i8 signext 62)
store i8 0, i8* %61
br label %62
62: ; preds = %59, %56
br label %63
63: ; preds = %62, %51
%64 = load i8*, i8** %6
store i8* %64, i8** %3
br label %65
65: ; preds = %63, %12
%66 = load i8*, i8** %3
ret i8* %66
}

LLVM IR (-O2):
@.str = [3 x i8] c" =\00"
define i8* @tagoption(i8* %0, i8* %1) {
%3 = tail call i8* @strcasestr(i8* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %1)
%7 = sext i32 %6 to i64
%8 = tail call i32 @strlen(i8* %1)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %3, i64 %9
%11 = tail call i64 @strspn(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = add nsw i64 %11, %7
%13 = getelementptr inbounds i8, i8* %3, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 34
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = tail call i8* @strchr(i8* %17, i8 signext 34)
%19 = icmp eq i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %16
store i8 0, i8* %18
br label %29
21: ; preds = %16
%22 = tail call i32 @strlen(i8* %17)
br label %29
23: ; preds = %5
%24 = tail call i8* @strchr(i8* %13, i8 signext 32)
%25 = icmp eq i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %23
store i8 0, i8* %24
br label %29
27: ; preds = %23
%28 = tail call i8* @strchr(i8* %13, i8 signext 62)
store i8 0, i8* %28
br label %29
29: ; preds = %21, %20, %27, %26, %2
%30 = phi i8* [ null, %2 ], [ %17, %20 ], [ %17, %21 ], [ %13, %26 ], [ %13, %27 ]
ret i8* %30
}