#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*/ FILE;

/* Variables and functions */
char EOF;
char fgetc(int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int nextEntity(char *s, FILE *in) {
  char c, p[256] = {0};
  int index, istag;
  index = 0;
  do {
    c = fgetc(in);
  } while (isspace(c) && c != EOF);
  if (c == EOF)
    return -1;
  if (c == '<') {
    istag = 1;
    c = fgetc(in);
    if (c != '/')
      ungetc(c, in);
  } else {
    istag = 0;
    p[index++] = c;
  }
  while (index < 256) {
    c = fgetc(in);
    if (c != '>' && c != '<')
      p[index++] = c;
    else {
      if (c == '<')
        ungetc(c, in);
      break;
    }
  }
  p[256 - 1] = 0;
  strcpy(s, p);
  return istag;
}


x86 assembly (clang, -O0):
<nextEntity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1060 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x129(%rbp)
je     11c3 <nextEntity+0x73>
movsbl -0x19(%rbp),%eax
mov    0x2e33(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    1180 <nextEntity+0x30>
movsbl -0x19(%rbp),%eax
mov    0x2e0c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11f3 <nextEntity+0xa3>
movl   $0xffffffff,-0x4(%rbp)
jmp    12fe <nextEntity+0x1ae>
movsbl -0x19(%rbp),%eax
cmp    $0x3c,%eax
jne    1237 <nextEntity+0xe7>
movl   $0x1,-0x128(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
je     1232 <nextEntity+0xe2>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1070 <ungetc@plt>
jmp    125e <nextEntity+0x10e>
movl   $0x0,-0x128(%rbp)
mov    -0x19(%rbp),%cl
mov    -0x124(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x124(%rbp)
cltq
mov    %cl,-0x120(%rbp,%rax,1)
jmp    1263 <nextEntity+0x113>
cmpl   $0x100,-0x124(%rbp)
jge    12e1 <nextEntity+0x191>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x3e,%eax
je     12bb <nextEntity+0x16b>
movsbl -0x19(%rbp),%eax
cmp    $0x3c,%eax
je     12bb <nextEntity+0x16b>
mov    -0x19(%rbp),%cl
mov    -0x124(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x124(%rbp)
cltq
mov    %cl,-0x120(%rbp,%rax,1)
jmp    12dc <nextEntity+0x18c>
movsbl -0x19(%rbp),%eax
cmp    $0x3c,%eax
jne    12d7 <nextEntity+0x187>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1070 <ungetc@plt>
jmp    12e1 <nextEntity+0x191>
jmp    1263 <nextEntity+0x113>
movb   $0x0,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x128(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextEntity>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e22(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1050 <isspace@plt>
movzbl 0x0(%rbp),%ecx
test   %rax,%rax
je     11ef <nextEntity+0xaf>
cmp    %cl,%bl
jne    11d0 <nextEntity+0x90>
mov    $0xffffffff,%r15d
cmp    %cl,%bl
je     1278 <nextEntity+0x138>
cmp    $0x3c,%bl
jne    1214 <nextEntity+0xd4>
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    $0x1,%r15d
cmp    $0x2f,%al
jne    1221 <nextEntity+0xe1>
xor    %ebx,%ebx
jmp    1230 <nextEntity+0xf0>
mov    %bl,(%rsp)
xor    %r15d,%r15d
mov    $0x1,%ebx
jmp    1230 <nextEntity+0xf0>
movsbl %al,%edi
mov    %r12,%rsi
call   1060 <ungetc@plt>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
and    $0xfd,%cl
cmp    $0x3c,%cl
je     1254 <nextEntity+0x114>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1230 <nextEntity+0xf0>
jmp    1265 <nextEntity+0x125>
cmp    $0x3c,%al
jne    1265 <nextEntity+0x125>
mov    $0x3c,%edi
mov    %r12,%rsi
call   1060 <ungetc@plt>
movb   $0x0,0xff(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r15d,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @nextEntity(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%10 = bitcast [256 x i8]* %7 to i8*
store i32 0, i32* %8
br label %11
11: ; preds = %24, %2
%12 = load i32*, i32** %5
%13 = call signext i8 @fgetc(i32* %12)
store i8 %13, i8* %6
br label %14
14: ; preds = %11
%15 = load i8, i8* %6
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br label %24
24: ; preds = %18, %14
%25 = phi i1 [ false, %14 ], [ %23, %18 ]
br i1 %25, label %11, label %26
26: ; preds = %24
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %28, %30
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 -1, i32* %3
br label %90
33: ; preds = %26
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 60
br i1 %36, label %37, label %48
37: ; preds = %33
store i32 1, i32* %9
%38 = load i32*, i32** %5
%39 = call signext i8 @fgetc(i32* %38)
store i8 %39, i8* %6
%40 = load i8, i8* %6
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 47
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = load i8, i8* %6
%45 = load i32*, i32** %5
%46 = call i32 @ungetc(i8 signext %44, i32* %45)
br label %47
47: ; preds = %43, %37
br label %54
48: ; preds = %33
store i32 0, i32* %9
%49 = load i8, i8* %6
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %52
store i8 %49, i8* %53
br label %54
54: ; preds = %48, %47
br label %55
55: ; preds = %83, %54
%56 = load i32, i32* %8
%57 = icmp slt i32 %56, 256
br i1 %57, label %58, label %84
58: ; preds = %55
%59 = load i32*, i32** %5
%60 = call signext i8 @fgetc(i32* %59)
store i8 %60, i8* %6
%61 = load i8, i8* %6
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 62
br i1 %63, label %64, label %74
64: ; preds = %58
%65 = load i8, i8* %6
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 60
br i1 %67, label %68, label %74
68: ; preds = %64
%69 = load i8, i8* %6
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
%72 = sext i32 %70 to i64
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %72
store i8 %69, i8* %73
br label %83
74: ; preds = %64, %58
%75 = load i8, i8* %6
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 60
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = load i8, i8* %6
%80 = load i32*, i32** %5
%81 = call i32 @ungetc(i8 signext %79, i32* %80)
br label %82
82: ; preds = %78, %74
br label %84
83: ; preds = %68
br label %55
84: ; preds = %82, %55
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 255
store i8 0, i8* %85
%86 = load i8*, i8** %4
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%88 = call i32 @strcpy(i8* %86, i8* %87)
%89 = load i32, i32* %9
store i32 %89, i32* %3
br label %90
90: ; preds = %84, %32
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @nextEntity(i8* %0, i32* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %5, %2
%6 = tail call signext i8 @fgetc(i32* %1)
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp ne i64 %7, 0
%9 = load i8, i8* @EOF
%10 = icmp ne i8 %6, %9
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %5, label %12
12: ; preds = %5
%13 = icmp eq i8 %6, %9
br i1 %13, label %41, label %14
14: ; preds = %12
%15 = icmp eq i8 %6, 60
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = tail call signext i8 @fgetc(i32* %1)
%18 = icmp eq i8 %17, 47
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @ungetc(i8 signext %17, i32* %1)
br label %22
21: ; preds = %14
store i8 %6, i8* %4
br label %22
22: ; preds = %16, %19, %21
%23 = phi i64 [ 0, %19 ], [ 0, %16 ], [ 1, %21 ]
%24 = phi i32 [ 1, %19 ], [ 1, %16 ], [ 0, %21 ]
br label %25
25: ; preds = %22, %30
%26 = phi i64 [ %23, %22 ], [ %31, %30 ]
%27 = tail call signext i8 @fgetc(i32* %1)
%28 = and i8 %27, -3
%29 = icmp eq i8 %28, 60
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = add nuw nsw i64 %26, 1
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %26
store i8 %27, i8* %32
%33 = icmp eq i64 %31, 256
br i1 %33, label %38, label %25
34: ; preds = %25
%35 = icmp eq i8 %27, 60
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = tail call i32 @ungetc(i8 signext 60, i32* %1)
br label %38
38: ; preds = %30, %34, %36
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 255
store i8 0, i8* %39
%40 = call i32 @strcpy(i8* %0, i8* %4)
br label %41
41: ; preds = %12, %38
%42 = phi i32 [ %24, %38 ], [ -1, %12 ]
ret i32 %42
}