#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 *);
char *strchr(char *, char);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
char *tagoption(char *, char *);
char *geturl(char *tag) {
  char *tmp;
  if (0)
    printf("geturl: %s\n", tag);
  if (!strncasecmp("a ", tag + 1, 2) || !strncasecmp("area ", tag + 1, 5) ||
      !strncasecmp("base ", tag + 1, 5) || !strncasecmp("link ", tag + 1, 5)) {
    tmp = tagoption(tag, "href");
    if (!tmp)
      return NULL;
    if (tmp[0] == '#')
      return NULL;
    if (!strncasecmp("mailto:", tmp, 7))
      return NULL;
    if (strchr(tmp, '#'))
      *strchr(tmp, '#') = '\0';
    return tmp;
  }
  if (!strncasecmp("img ", tag + 1, 4) ||
      !strncasecmp("bgsound ", tag + 1, 8) ||
      !strncasecmp("embed ", tag + 1, 6) ||
      !strncasecmp("frame ", tag + 1, 6) || !strncasecmp("iframe ", tag + 1, 7))
    return tagoption(tag, "src");
  if (!strncasecmp("body ", tag + 1, 5))
    return tagoption(tag, "background");
  return NULL;
}


x86 assembly (clang, -O0):
<geturl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xeb8(%rip),%rdi
mov    $0x2,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     11c4 <geturl+0x94>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe93(%rip),%rdi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     11c4 <geturl+0x94>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe77(%rip),%rdi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     11c4 <geturl+0x94>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe5b(%rip),%rdi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    126e <geturl+0x13e>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1050 <tagoption@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f0 <geturl+0xc0>
movq   $0x0,-0x8(%rbp)
jmp    1374 <geturl+0x244>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    120d <geturl+0xdd>
movq   $0x0,-0x8(%rbp)
jmp    1374 <geturl+0x244>
mov    -0x18(%rbp),%rsi
lea    0xdff(%rip),%rdi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1238 <geturl+0x108>
movq   $0x0,-0x8(%rbp)
jmp    1374 <geturl+0x244>
mov    -0x18(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1261 <geturl+0x131>
mov    -0x18(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1374 <geturl+0x244>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xda2(%rip),%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1318 <geturl+0x1e8>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xd85(%rip),%rdi
mov    $0x8,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1318 <geturl+0x1e8>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xd6c(%rip),%rdi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1318 <geturl+0x1e8>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xd52(%rip),%rdi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1318 <geturl+0x1e8>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xd2f(%rip),%rdi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1331 <geturl+0x201>
mov    -0x10(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   1050 <tagoption@plt>
mov    %rax,-0x8(%rbp)
jmp    1374 <geturl+0x244>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xd00(%rip),%rdi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    136c <geturl+0x23c>
mov    -0x10(%rbp),%rdi
lea    0xce8(%rip),%rsi
call   1050 <tagoption@plt>
mov    %rax,-0x8(%rbp)
jmp    1374 <geturl+0x244>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geturl>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x1(%rdi),%rbx
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     1254 <geturl+0x124>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     1254 <geturl+0x124>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     1254 <geturl+0x124>
lea    0xe76(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     1254 <geturl+0x124>
lea    0xe6d(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ac <geturl+0x17c>
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ac <geturl+0x17c>
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ac <geturl+0x17c>
lea    0xe2f(%rip),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ac <geturl+0x17c>
lea    0xe12(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     12ac <geturl+0x17c>
lea    0xe06(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
jne    129f <geturl+0x16f>
lea    0xdf4(%rip),%rsi
jmp    12b3 <geturl+0x183>
lea    0xdb7(%rip),%rsi
mov    %r14,%rdi
call   1050 <tagoption@plt>
test   %rax,%rax
je     129f <geturl+0x16f>
mov    %rax,%rbx
cmpb   $0x23,(%rax)
je     129f <geturl+0x16f>
lea    0xda0(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     129f <geturl+0x16f>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     12a1 <geturl+0x171>
movb   $0x0,(%rax)
jmp    12a1 <geturl+0x171>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd89(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <tagoption@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"a \00"
@.str.1 = [6 x i8] c"area \00"
@.str.2 = [6 x i8] c"base \00"
@.str.3 = [6 x i8] c"link \00"
@.str.4 = [5 x i8] c"href\00"
@.str.5 = [8 x i8] c"mailto:\00"
@.str.6 = [5 x i8] c"img \00"
@.str.7 = [9 x i8] c"bgsound \00"
@.str.8 = [7 x i8] c"embed \00"
@.str.9 = [7 x i8] c"frame \00"
@.str.10 = [8 x i8] c"iframe \00"
@.str.11 = [4 x i8] c"src\00"
@.str.12 = [6 x i8] c"body \00"
@.str.13 = [11 x i8] c"background\00"
define i8* @geturl(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = call i32 @strncasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6, i32 2)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 5)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 5)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %21, i32 5)
%23 = icmp ne i32 %22, 0
br i1 %23, label %51, label %24
24: ; preds = %19, %14, %9, %1
%25 = load i8*, i8** %3
%26 = call i8* @tagoption(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %30, label %29
29: ; preds = %24
store i8* null, i8** %2
br label %88
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 35
br i1 %35, label %36, label %37
36: ; preds = %30
store i8* null, i8** %2
br label %88
37: ; preds = %30
%38 = load i8*, i8** %4
%39 = call i32 @strncasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %38, i32 7)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i8* null, i8** %2
br label %88
42: ; preds = %37
%43 = load i8*, i8** %4
%44 = call i8* @strchr(i8* %43, i8 signext 35)
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i8*, i8** %4
%48 = call i8* @strchr(i8* %47, i8 signext 35)
store i8 0, i8* %48
br label %49
49: ; preds = %46, %42
%50 = load i8*, i8** %4
store i8* %50, i8** %2
br label %88
51: ; preds = %19
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = call i32 @strncasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %53, i32 4)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %76
56: ; preds = %51
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = call i32 @strncasecmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %58, i32 8)
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %56
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %63, i32 6)
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %76
66: ; preds = %61
%67 = load i8*, i8** %3
%68 = getelementptr inbounds i8, i8* %67, i64 1
%69 = call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %68, i32 6)
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %66
%72 = load i8*, i8** %3
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = call i32 @strncasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %73, i32 7)
%75 = icmp ne i32 %74, 0
br i1 %75, label %79, label %76
76: ; preds = %71, %66, %61, %56, %51
%77 = load i8*, i8** %3
%78 = call i8* @tagoption(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
store i8* %78, i8** %2
br label %88
79: ; preds = %71
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %81, i32 5)
%83 = icmp ne i32 %82, 0
br i1 %83, label %87, label %84
84: ; preds = %79
%85 = load i8*, i8** %3
%86 = call i8* @tagoption(i8* %85, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
store i8* %86, i8** %2
br label %88
87: ; preds = %79
store i8* null, i8** %2
br label %88
88: ; preds = %87, %84, %76, %49, %41, %36, %29
%89 = load i8*, i8** %2
ret i8* %89
}

LLVM IR (-O2):
@.str = [3 x i8] c"a \00"
@.str.1 = [6 x i8] c"area \00"
@.str.2 = [6 x i8] c"base \00"
@.str.3 = [6 x i8] c"link \00"
@.str.4 = [5 x i8] c"href\00"
@.str.5 = [8 x i8] c"mailto:\00"
@.str.6 = [5 x i8] c"img \00"
@.str.7 = [9 x i8] c"bgsound \00"
@.str.8 = [7 x i8] c"embed \00"
@.str.9 = [7 x i8] c"frame \00"
@.str.10 = [8 x i8] c"iframe \00"
@.str.11 = [4 x i8] c"src\00"
@.str.12 = [6 x i8] c"body \00"
@.str.13 = [11 x i8] c"background\00"
define i8* @geturl(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2, i32 2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %11, %8, %5, %1
%15 = tail call i8* @tagoption(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %49, label %17
17: ; preds = %14
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 35
br i1 %19, label %49, label %20
20: ; preds = %17
%21 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %15, i32 7)
%22 = icmp eq i32 %21, 0
br i1 %22, label %49, label %23
23: ; preds = %20
%24 = tail call i8* @strchr(i8* %15, i8 signext 35)
%25 = icmp eq i8* %24, null
br i1 %25, label %49, label %26
26: ; preds = %23
store i8 0, i8* %24
br label %49
27: ; preds = %11
%28 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %2, i32 4)
%29 = icmp eq i32 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %27
%31 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %2, i32 8)
%32 = icmp eq i32 %31, 0
br i1 %32, label %42, label %33
33: ; preds = %30
%34 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %2, i32 6)
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %2, i32 6)
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %2, i32 7)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39, %36, %33, %30, %27
%43 = tail call i8* @tagoption(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
br label %49
44: ; preds = %39
%45 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %2, i32 5)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i8* @tagoption(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
br label %49
49: ; preds = %44, %23, %26, %20, %17, %14, %47, %42
%50 = phi i8* [ %48, %47 ], [ %43, %42 ], [ null, %14 ], [ null, %17 ], [ null, %20 ], [ %15, %26 ], [ %15, %23 ], [ null, %44 ]
ret i8* %50
}