#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 */
typedef int /*<<< orphan*/ start_tag;
typedef int /*<<< orphan*/ end_tag;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
scalar_t__ strlen(char const *);
char *strstr(char *, char *);
void _get_next_tag_chunk(char **start, char **end, const char *tag) {
  char start_tag[64], end_tag[64];
  *start = *end;
  snprintf(start_tag, sizeof(start_tag), "<%s>", tag);
  snprintf(end_tag, sizeof(end_tag), "</%s>", tag);
  *start = strstr(*start, start_tag);
  if (!*start)
    return;
  *end = strstr(*start, end_tag);
  if (!*end)
    return;
  *start += strlen(tag) + 2;
  **end = '\0';
  (*end)++;
}


x86 assembly (clang, -O0):
<_get_next_tag_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x40,%esi
lea    0xe97(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x40,%esi
lea    0xe80(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b7 <_get_next_tag_chunk+0x87>
jmp    1219 <_get_next_tag_chunk+0xe9>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11e7 <_get_next_tag_chunk+0xb7>
jmp    1219 <_get_next_tag_chunk+0xe9>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
add    $0x2,%rcx
mov    -0x8(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_next_tag_chunk>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%rax
mov    %rax,(%rdi)
lea    0xeac(%rip),%rdx
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    $0x40,%esi
mov    %r15,%rcx
call   1040 <snprintf@plt>
lea    0xe95(%rip),%rdx
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %r15,%rcx
call   1040 <snprintf@plt>
mov    (%rbx),%rdi
mov    %r12,%rsi
call   1050 <strstr@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11c5 <_get_next_tag_chunk+0x95>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <strstr@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11c5 <_get_next_tag_chunk+0x95>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    (%rbx),%rcx
add    %rcx,%rax
add    $0x2,%rax
mov    %rax,(%rbx)
mov    (%r14),%rax
movb   $0x0,(%rax)
addq   $0x1,(%r14)
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"<%s>\00"
@.str.1 = [6 x i8] c"</%s>\00"
define void @_get_next_tag_chunk(i8** nocapture %0, i8** nocapture %1, i8* %2) {
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %1
store i8* %8, i8** %0
%9 = call i32 @snprintf(i8* %6, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = call i32 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = load i8*, i8** %0
%12 = call i8* @strstr(i8* dereferenceable(1) %11, i8* %6)
store i8* %12, i8** %0
%13 = icmp eq i8* %12, null
br i1 %13, label %25, label %14
14: ; preds = %3
%15 = call i8* @strstr(i8* %12, i8* %7)
store i8* %15, i8** %1
%16 = icmp eq i8* %15, null
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = call i64 @strlen(i8* dereferenceable(1) %2)
%19 = add nsw i64 %18, 2
%20 = load i8*, i8** %0
%21 = getelementptr inbounds i8, i8* %20, i64 %19
store i8* %21, i8** %0
%22 = load i8*, i8** %1
store i8 0, i8* %22
%23 = load i8*, i8** %1
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %1
br label %25
25: ; preds = %14, %3, %17
ret void
}