#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int verificaTagInterna(FILE *arquivo) {
  char aux, tag_atual[3], tag_fim[] = "/p";
  int i = 0;
  printf("Verificando tag interna...");
  aux = fgetc(arquivo);
  while (aux != '>' && i < 3) {
    tag_atual[i++] = aux;
    aux = fgetc(arquivo);
  }
  tag_atual[i] = '\0';
  if (!strcmp(tag_atual, tag_fim)) {
    printf(" tag é do tipo final\n");
    return 2;
  }
  while (aux != '>')
    aux = fgetc(arquivo);
  printf(" tag deve ser ignorada\n");
  return 3;
}


x86 assembly (clang, -O0):
<verificaTagInterna>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xebd(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xeb5(%rip),%al
mov    %al,-0x15(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x3e,%ecx
mov    %al,-0x1d(%rbp)
je     118b <verificaTagInterna+0x5b>
cmpl   $0x3,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    119b <verificaTagInterna+0x6b>
jmp    11c0 <verificaTagInterna+0x90>
mov    -0x11(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    116f <verificaTagInterna+0x3f>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x14(%rbp,%rax,1)
lea    -0x14(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11f7 <verificaTagInterna+0xc7>
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    122d <verificaTagInterna+0xfd>
jmp    11fc <verificaTagInterna+0xcc>
movsbl -0x11(%rbp),%eax
cmp    $0x3e,%eax
je     121a <verificaTagInterna+0xea>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    11fc <verificaTagInterna+0xcc>
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verificaTagInterna>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    $0x3e,%al
jne    1158 <verificaTagInterna+0x28>
mov    $0x3e,%al
xor    %ebx,%ebx
jmp    117d <verificaTagInterna+0x4d>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbp),%rbx
mov    %al,0x5(%rsp,%rbp,1)
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    $0x3e,%al
je     117d <verificaTagInterna+0x4d>
cmp    $0x2,%rbp
mov    %rbx,%rbp
jb     1160 <verificaTagInterna+0x30>
movb   $0x0,0x5(%rsp,%rbx,1)
movzwl 0x5(%rsp),%ecx
xor    $0x702f,%ecx
movzbl 0x7(%rsp),%edx
or     %cx,%dx
je     11be <verificaTagInterna+0x8e>
mov    $0x3,%r14d
lea    0xe90(%rip),%rbp
cmp    $0x3e,%al
je     11cb <verificaTagInterna+0x9b>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    $0x3e,%al
jne    11b0 <verificaTagInterna+0x80>
jmp    11cb <verificaTagInterna+0x9b>
mov    $0x2,%r14d
lea    0xe53(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.verificaTagInterna.tag_fim = [3 x i8] c"/p\00"
@.str = [27 x i8] c"Verificando tag interna...\00"
@.str.1 = [23 x i8] c" tag \C3\A9 do tipo final\0A\00"
@.str.2 = [24 x i8] c" tag deve ser ignorada\0A\00"
define i32 @verificaTagInterna(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca i32
store i32* %0, i32** %3
%8 = bitcast [3 x i8]* %6 to i8*
store i32 0, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = load i32*, i32** %3
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %4
br label %12
12: ; preds = %21, %1
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 62
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 3
br label %19
19: ; preds = %16, %12
%20 = phi i1 [ false, %12 ], [ %18, %16 ]
br i1 %20, label %21, label %29
21: ; preds = %19
%22 = load i8, i8* %4
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %25
store i8 %22, i8* %26
%27 = load i32*, i32** %3
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %4
br label %12
29: ; preds = %19
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %31
store i8 0, i8* %32
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%35 = call i32 @strcmp(i8* %33, i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %29
%38 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %2
br label %49
39: ; preds = %29
br label %40
40: ; preds = %44, %39
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 62
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32*, i32** %3
%46 = call signext i8 @fgetc(i32* %45)
store i8 %46, i8* %4
br label %40
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 3, i32* %2
br label %49
49: ; preds = %47, %37
%50 = load i32, i32* %2
ret i32 %50
}

LLVM IR (-O2):
@__const.verificaTagInterna.tag_fim = [3 x i8] c"/p\00"
@.str = [27 x i8] c"Verificando tag interna...\00"
@str = [22 x i8] c" tag \C3\A9 do tipo final\00"
@str.3 = [23 x i8] c" tag deve ser ignorada\00"
define i32 @verificaTagInterna(i32* nocapture %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = tail call signext i8 @fgetc(i32* %0)
%6 = icmp eq i8 %5, 62
br i1 %6, label %16, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %10, %7 ], [ 0, %1 ]
%9 = phi i8 [ %12, %7 ], [ %5, %1 ]
%10 = add nuw nsw i64 %8, 1
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 %8
store i8 %9, i8* %11
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = icmp ne i8 %12, 62
%14 = icmp ult i64 %8, 2
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %7, label %16
16: ; preds = %7, %1
%17 = phi i8 [ 62, %1 ], [ %12, %7 ]
%18 = phi i64 [ 0, %1 ], [ %10, %7 ]
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @bcmp(i8* dereferenceable(3) %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @__const.verificaTagInterna.tag_fim, i64 0, i64 0), i64 3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %16
%23 = icmp eq i8 %17, 62
br i1 %23, label %27, label %24
24: ; preds = %22, %24
%25 = tail call signext i8 @fgetc(i32* %0)
%26 = icmp eq i8 %25, 62
br i1 %26, label %27, label %24
27: ; preds = %24, %22, %16
%28 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %16 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %22 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %24 ]
%29 = phi i32 [ 2, %16 ], [ 3, %22 ], [ 3, %24 ]
%30 = tail call i32 @puts(i8* dereferenceable(1) %28)
ret i32 %29
}