#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 */
int /*<<< orphan*/ converte_entidade(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
int verificaTagInterna(int /*<<< orphan*/ *);
void escrever(FILE *arqin, FILE *arqout) {
  char c;
  int tag;
  c = fgetc(arqin);
  printf("iniciando escrita\n");
  while (c != '<') {
    if (c == '&') {
      printf("entidade encontrada\n");
      converte_entidade(arqin, arqout);
    } else
      fprintf(arqout, "%c", c);
    c = fgetc(arqin);
  }
  tag = verificaTagInterna(arqin);
  if (tag == 2) {
    fprintf(arqout, "\n");
    return;
  } else
    escrever(arqin, arqout);
  printf("escrita finalizada\n");
}


x86 assembly (clang, -O0):
<escrever>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x3c,%eax
je     11e7 <escrever+0x87>
movsbl -0x11(%rbp),%eax
cmp    $0x26,%eax
jne    11c0 <escrever+0x60>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <converte_entidade@plt>
jmp    11d6 <escrever+0x76>
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%edx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1188 <escrever+0x28>
mov    -0x8(%rbp),%rdi
call   1030 <verificaTagInterna@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    1214 <escrever+0xb4>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    122d <escrever+0xcd>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <escrever@plt>
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escrever>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <fgetc@plt>
mov    %eax,%ebx
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9d(%rip),%r15
jmp    11ad <escrever+0x4d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <converte_entidade@plt>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    $0x26,%bl
je     1190 <escrever+0x30>
cmp    $0x3c,%bl
je     11c4 <escrever+0x64>
movsbl %bl,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
jmp    11a3 <escrever+0x43>
mov    %r12,%rdi
call   1030 <verificaTagInterna@plt>
cmp    $0x2,%eax
jne    11e9 <escrever+0x89>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <fputc@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <escrever@plt>
lea    0xe17(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"iniciando escrita\0A\00"
@.str.1 = [21 x i8] c"entidade encontrada\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [20 x i8] c"escrita finalizada\0A\00"
define void @escrever(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %3
%8 = call signext i8 @fgetc(i32* %7)
store i8 %8, i8* %5
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %28, %2
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 60
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 38
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = load i32*, i32** %4
%22 = call i32 @converte_entidade(i32* %20, i32* %21)
br label %28
23: ; preds = %14
%24 = load i32*, i32** %4
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %23, %18
%29 = load i32*, i32** %3
%30 = call signext i8 @fgetc(i32* %29)
store i8 %30, i8* %5
br label %10
31: ; preds = %10
%32 = load i32*, i32** %3
%33 = call i32 @verificaTagInterna(i32* %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %44
39: ; preds = %31
%40 = load i32*, i32** %3
%41 = load i32*, i32** %4
br label %42
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
ret void
}

LLVM IR (-O2):
@str = [18 x i8] c"iniciando escrita\00"
@str.5 = [19 x i8] c"escrita finalizada\00"
@str.6 = [20 x i8] c"entidade encontrada\00"
define void @escrever(i32* %0, i32* %1) {
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %13, %2
%6 = phi i8 [ %3, %2 ], [ %14, %13 ]
switch i8 %6, label %10 [
i8 60, label %15
i8 38, label %7
]
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @converte_entidade(i32* %0, i32* %1)
br label %13
10: ; preds = %5
%11 = sext i8 %6 to i32
%12 = tail call i32 @fputc(i32 %11, i32* %1)
br label %13
13: ; preds = %10, %7
%14 = tail call signext i8 @fgetc(i32* %0)
br label %5
15: ; preds = %5
%16 = tail call i32 @verificaTagInterna(i32* %0)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = tail call i32 @fputc(i32 10, i32* %1)
br label %20
20: ; preds = %18, %21
ret void
21: ; preds = %15
tail call void @escrever(i32* %0, i32* %1)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
br label %20
}