#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*/ Xml_Next_Word(char *, char *, int, char *);
int strlen(char *);
void xml_grab_tag_name(char *tag, char *name, int maxlen) {
  int j;
  Xml_Next_Word(tag, name, maxlen, " \t\n\r");
  j = strlen(name);
  if ((j > 1) && (name[j - 1] == '/')) {
    name[j - 1] = '\0';
    j = 0;
    do {
      tag[j + 1] = tag[j];
      j++;
    } while (tag[j - 1] != '\0');
    tag[0] = '/';
  }
}


x86 assembly (clang, -O0):
<xml_grab_tag_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xebb(%rip),%rcx
call   1040 <Xml_Next_Word@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jle    11d7 <xml_grab_tag_name+0xb7>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11d7 <xml_grab_tag_name+0xb7>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1192 <xml_grab_tag_name+0x72>
mov    -0x8(%rbp),%rax
movb   $0x2f,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml_grab_tag_name>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecf(%rip),%rcx
call   1040 <Xml_Next_Word@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     116e <xml_grab_tag_name+0x4e>
add    $0xffffffff,%eax
cmpb   $0x2f,(%rbx,%rax,1)
jne    116e <xml_grab_tag_name+0x4e>
movb   $0x0,(%rbx,%rax,1)
mov    (%r14),%al
lea    0x1(%r14),%rcx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rcx)
add    $0x1,%rcx
test   %al,%al
jne    1160 <xml_grab_tag_name+0x40>
movb   $0x2f,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0A\0D\00"
define void @xml_grab_tag_name(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @Xml_Next_Word(i8* %8, i8* %9, i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %56
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 47
br i1 %24, label %25, label %56
25: ; preds = %16
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8 0, i8* %30
store i32 0, i32* %7
br label %31
31: ; preds = %44, %25
%32 = load i8*, i8** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %4
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 %36, i8* %41
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %44
44: ; preds = %31
%45 = load i8*, i8** %4
%46 = load i32, i32* %7
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %31, label %53
53: ; preds = %44
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 0
store i8 47, i8* %55
br label %56
56: ; preds = %53, %16, %3
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0A\0D\00"
define void @xml_grab_tag_name(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @Xml_Next_Word(i8* %0, i8* %1, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %21
7: ; preds = %3
%8 = add nsw i32 %5, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 47
br i1 %12, label %13, label %21
13: ; preds = %7
store i8 0, i8* %10
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 0
br label %16
16: ; preds = %16, %13
%17 = phi i64 [ %18, %16 ], [ 0, %13 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 %14, i8* %19
br i1 %15, label %20, label %16
20: ; preds = %16
store i8 47, i8* %0
br label %21
21: ; preds = %20, %7, %3
ret void
}