#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 *find_arrow_ptr(char *annot, char *arrow_ptr, char *compl_arrow_ptr) {
  char *ptr;
  char *semi_colon_ptr;
  char *compl_ptr;
  ptr = strstr(annot, arrow_ptr);
  if (!ptr)
    return (NULL);
  semi_colon_ptr = strstr(annot + 1, ";");
  if (semi_colon_ptr && (semi_colon_ptr < ptr))
    return (NULL);
  else {
    compl_ptr = strstr(annot, compl_arrow_ptr);
    if (compl_ptr && (compl_ptr < ptr))
      return (NULL);
    else
      return (ptr);
  }
}


x86 assembly (clang, -O0):
<find_arrow_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    114d <find_arrow_ptr+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    11ca <find_arrow_ptr+0xba>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xea4(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     118b <find_arrow_ptr+0x7b>
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    118b <find_arrow_ptr+0x7b>
movq   $0x0,-0x8(%rbp)
jmp    11ca <find_arrow_ptr+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11c2 <find_arrow_ptr+0xb2>
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11c2 <find_arrow_ptr+0xb2>
movq   $0x0,-0x8(%rbp)
jmp    11ca <find_arrow_ptr+0xba>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_arrow_ptr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r15
call   1040 <strstr@plt>
test   %rax,%rax
je     1150 <find_arrow_ptr+0x30>
mov    %rax,%rbx
lea    0x1(%r15),%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1154 <find_arrow_ptr+0x34>
cmp    %rbx,%rax
jae    1154 <find_arrow_ptr+0x34>
xor    %eax,%eax
jmp    1172 <find_arrow_ptr+0x52>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
cmovae %rbx,%rax
test   %rcx,%rcx
cmove  %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @find_arrow_ptr(i8* %0, i8* nocapture %1, i8* nocapture %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = tail call i8* @strchr(i8* %7, i32 59)
%9 = icmp ne i8* %8, null
%10 = icmp ult i8* %8, %4
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %18, label %12
12: ; preds = %6
%13 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %2)
%14 = icmp ne i8* %13, null
%15 = icmp ult i8* %13, %4
%16 = select i1 %14, i1 %15, i1 false
%17 = select i1 %16, i8* null, i8* %4
br label %18
18: ; preds = %12, %6, %3
%19 = phi i8* [ null, %3 ], [ null, %6 ], [ %17, %12 ]
ret i8* %19
}