#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
char *strstr(char *, char const *);
char *extract_xml(char *dest, char *haystack, const char *needle) {
  char *p, *pp;
  p = strstr(haystack, needle);
  if (!p) {
    fprintf(stderr, "parser cannot find \"%s\" in:\n%s\n", needle, haystack);
    return NULL;
  }
  pp = p;
  do
    pp += 1;
  while (*pp != '>');
  pp++;
  p = pp;
  do
    p += 1;
  while (*p != '<');
  *p = 0;
  snprintf(dest, 256 - 1, "%s", pp);
  return (p + 1);
}


x86 assembly (clang, -O0):
<extract_xml>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118a <extract_xml+0x5a>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    120a <extract_xml+0xda>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    1192 <extract_xml+0x62>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    11c2 <extract_xml+0x92>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0xff,%esi
lea    0xe27(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_xml>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1196 <extract_xml+0x66>
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x3e,(%rax)
lea    0x1(%rax),%rax
jne    1160 <extract_xml+0x30>
lea    0x1(%rax),%rbx
nopl   (%rax)
cmpb   $0x3c,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <extract_xml+0x40>
movb   $0x0,-0x1(%rbx)
lea    0xe9c(%rip),%rdx
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rax,%rcx
call   1030 <snprintf@plt>
jmp    11b3 <extract_xml+0x83>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"parser cannot find \22%s\22 in:\0A%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @extract_xml(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %6
%11 = load i8*, i8** %7
%12 = call i8* @strstr(i8* %10, i8* %11)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %7
%18 = load i8*, i8** %6
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
store i8* null, i8** %4
br label %49
20: ; preds = %3
%21 = load i8*, i8** %8
store i8* %21, i8** %9
br label %22
22: ; preds = %25, %20
%23 = load i8*, i8** %9
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %9
br label %25
25: ; preds = %22
%26 = load i8*, i8** %9
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 62
br i1 %29, label %22, label %30
30: ; preds = %25
%31 = load i8*, i8** %9
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %9
%33 = load i8*, i8** %9
store i8* %33, i8** %8
br label %34
34: ; preds = %37, %30
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %8
br label %37
37: ; preds = %34
%38 = load i8*, i8** %8
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 60
br i1 %41, label %34, label %42
42: ; preds = %37
%43 = load i8*, i8** %8
store i8 0, i8* %43
%44 = load i8*, i8** %5
%45 = load i8*, i8** %9
%46 = call i32 @snprintf(i8* %44, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %8
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** %4
br label %49
49: ; preds = %42, %15
%50 = load i8*, i8** %4
ret i8* %50
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"parser cannot find \22%s\22 in:\0A%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @extract_xml(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %1)
br label %24
9: ; preds = %3, %9
%10 = phi i8* [ %11, %9 ], [ %4, %3 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 62
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %10, i64 2
br label %16
16: ; preds = %16, %14
%17 = phi i8* [ %15, %14 ], [ %18, %16 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 60
br i1 %20, label %21, label %16
21: ; preds = %16
store i8 0, i8* %18
%22 = tail call i32 @snprintf(i8* %0, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%23 = getelementptr inbounds i8, i8* %17, i64 2
br label %24
24: ; preds = %21, %6
%25 = phi i8* [ %23, %21 ], [ null, %6 ]
ret i8* %25
}