#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*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
void converte_entidade(FILE *arqin, FILE *arqout) {
  char c, entidade[10];
  int i = 0;
  c = fgetc(arqin);
  while (c != ';') {
    entidade[i++] = c;
    c = fgetc(arqin);
  }
  entidade[i] = '\0';
  if (!strcmp(entidade, "#39"))
    fprintf(arqout, "\'");
  else if (!strcmp(entidade, "quot"))
    fprintf(arqout, "\"");
}


x86 assembly (clang, -O0):
<converte_entidade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x3b,%eax
je     1185 <converte_entidade+0x55>
mov    -0x11(%rbp),%cl
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
cltq
mov    %cl,-0x1b(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1153 <converte_entidade+0x23>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x1b(%rbp,%rax,1)
lea    -0x1b(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11bc <converte_entidade+0x8c>
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ea <converte_entidade+0xba>
lea    -0x1b(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e5 <converte_entidade+0xb5>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ea <converte_entidade+0xba>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<converte_entidade>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <fgetc@plt>
cmp    $0x3b,%al
jne    113c <converte_entidade+0x1c>
xor    %eax,%eax
jmp    1156 <converte_entidade+0x36>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %al,0x6(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0x3b,%al
jne    1140 <converte_entidade+0x20>
mov    %ebx,%eax
movb   $0x0,0x6(%rsp,%rax,1)
cmpl   $0x393323,0x6(%rsp)
je     1181 <converte_entidade+0x61>
mov    $0x746f7571,%eax
xor    0x6(%rsp),%eax
movzbl 0xa(%rsp),%ecx
or     %eax,%ecx
je     1188 <converte_entidade+0x68>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x27,%edi
jmp    118d <converte_entidade+0x6d>
mov    $0x22,%edi
mov    %r14,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"\00"
@.str.2 = [5 x i8] c"quot\00"
define void @converte_entidade(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call signext i8 @fgetc(i32* %0)
%6 = icmp eq i8 %5, 59
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %10, %7 ], [ 0, %2 ]
%9 = phi i8 [ %12, %7 ], [ %5, %2 ]
%10 = add nuw i64 %8, 1
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %8
store i8 %9, i8* %11
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = icmp eq i8 %12, 59
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = and i64 %10, 4294967295
br label %16
16: ; preds = %14, %2
%17 = phi i64 [ 0, %2 ], [ %15, %14 ]
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 @bcmp(i8* dereferenceable(4) %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 4)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21, %16
%25 = phi i32 [ 39, %16 ], [ 34, %21 ]
%26 = tail call i32 @fputc(i32 %25, i32* %1)
br label %27
27: ; preds = %24, %21
ret void
}