#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 */
char *strstr(char *, char *);
char *nextURL(char *s) {
  char *c;
  c = strstr(s, "href");
  if (c == NULL)
    return NULL;
  while (*c != '\0') {
    if (*c == '"' || *c == '\'')
      break;
    c++;
  }
  if (*c == '\0')
    return NULL;
  c++;
  return c;
}


x86 assembly (clang, -O0):
<nextURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1148 <nextURL+0x38>
movq   $0x0,-0x8(%rbp)
jmp    11c4 <nextURL+0xb4>
jmp    114d <nextURL+0x3d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1193 <nextURL+0x83>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     117d <nextURL+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1182 <nextURL+0x72>
jmp    1193 <nextURL+0x83>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <nextURL+0x3d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b0 <nextURL+0xa0>
movq   $0x0,-0x8(%rbp)
jmp    11c4 <nextURL+0xb4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextURL>:
push   %rax
lea    0xee8(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     115e <nextURL+0x4e>
add    $0x1,%rax
movabs $0x8400000001,%rcx
jmp    1144 <nextURL+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
movzbl -0x1(%rax),%edx
cmp    $0x27,%rdx
ja     1140 <nextURL+0x30>
bt     %rdx,%rcx
jae    1140 <nextURL+0x30>
xor    %ecx,%ecx
test   %dl,%dl
cmove  %rcx,%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"href\00"
define i8* @nextURL(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* null, i8** %2
br label %40
10: ; preds = %1
br label %11
11: ; preds = %27, %10
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 34
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 39
br i1 %25, label %26, label %27
26: ; preds = %21, %16
br label %30
27: ; preds = %21
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %11
30: ; preds = %26, %11
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i8* null, i8** %2
br label %40
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8*, i8** %4
store i8* %39, i8** %2
br label %40
40: ; preds = %36, %35, %9
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
@.str = [5 x i8] c"href\00"
define i8* @nextURL(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1, %7
%5 = phi i8* [ %8, %7 ], [ %2, %1 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %9
i8 34, label %9
i8 39, label %9
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
9: ; preds = %4, %4, %4
%10 = icmp eq i8 %6, 0
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = select i1 %10, i8* null, i8* %11
br label %13
13: ; preds = %9, %1
%14 = phi i8* [ null, %1 ], [ %12, %9 ]
ret i8* %14
}