#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 *skipString(char *);
scalar_t__ strchr(char *, char);
char *strstr(char *, char *);
char *strstr_c(char *p, char *ptn) {
  char *q;
  if (q = strstr(p, ptn)) {
    while (*p && p != q)
      if (strchr("\"\'", *p))
        p = skipString(p);
      else
        ++p;
    if (!*p)
      q = 0;
  }
  return q;
}


x86 assembly (clang, -O0):
<strstr_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ed <strstr_c+0xbd>
jmp    1160 <strstr_c+0x30>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1183 <strstr_c+0x53>
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1193 <strstr_c+0x63>
jmp    11d3 <strstr_c+0xa3>
mov    -0x8(%rbp),%rax
lea    0xe62(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11c2 <strstr_c+0x92>
mov    -0x8(%rbp),%rdi
call   1040 <skipString@plt>
mov    %rax,-0x8(%rbp)
jmp    11ce <strstr_c+0x9e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1160 <strstr_c+0x30>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11e8 <strstr_c+0xb8>
movq   $0x0,-0x18(%rbp)
jmp    11ed <strstr_c+0xbd>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strstr_c>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <strstr@plt>
test   %rax,%rax
je     119a <strstr_c+0x6a>
mov    %rax,%r14
mov    (%rbx),%al
test   %al,%al
je     1190 <strstr_c+0x60>
cmp    %rbx,%r14
je     1190 <strstr_c+0x60>
lea    0xea9(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     1180 <strstr_c+0x50>
mov    %rbx,%rdi
call   1040 <skipString@plt>
mov    %rax,%rbx
jmp    1184 <strstr_c+0x54>
nopl   (%rax)
add    $0x1,%rbx
movzbl (%rbx),%eax
test   %al,%al
je     1190 <strstr_c+0x60>
cmp    %r14,%rbx
jne    1160 <strstr_c+0x30>
xor    %ecx,%ecx
test   %al,%al
cmove  %rcx,%r14
jmp    119d <strstr_c+0x6d>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\22'\00"
define i8* @strstr_c(i8* %0, i8* nocapture %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp ne i8 %6, 0
%8 = icmp ne i8* %3, %0
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %25
10: ; preds = %5, %19
%11 = phi i8 [ %21, %19 ], [ %6, %5 ]
%12 = phi i8* [ %20, %19 ], [ %0, %5 ]
%13 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i8* @skipString(i8* %12)
br label %19
17: ; preds = %10
%18 = getelementptr inbounds i8, i8* %12, i64 1
br label %19
19: ; preds = %17, %15
%20 = phi i8* [ %16, %15 ], [ %18, %17 ]
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
%23 = icmp ne i8* %20, %3
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %10, label %25
25: ; preds = %19, %5
%26 = phi i8 [ %6, %5 ], [ %21, %19 ]
%27 = icmp eq i8 %26, 0
%28 = select i1 %27, i8* null, i8* %3
br label %29
29: ; preds = %25, %2
%30 = phi i8* [ null, %2 ], [ %28, %25 ]
ret i8* %30
}