#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;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *, char *);
int /*<<< orphan*/ verificaTag(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main() {
  char aux, filename[30], fileoutname[30];
  FILE *file, *fileout;
  scanf("%s %s", filename, fileoutname);
  file = fopen(filename, "r");
  fileout = fopen(fileoutname, "w");
  aux = fgetc(file);
  while (aux != EOF) {
    if (aux == '<') {
      printf("tag encontrada\n");
      verificaTag(file, fileout);
      printf("continuando leitura\n");
    }
    aux = fgetc(file);
  }
  printf("arquivo chegou ao fim\n");
  fclose(file);
  fclose(fileout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe82(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    0x2e26(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1210 <main+0xb0>
movsbl -0x5(%rbp),%eax
cmp    $0x3c,%eax
jne    11ff <main+0x9f>
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1030 <verificaTag@plt>
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x5(%rbp)
jmp    11b7 <main+0x57>
lea    0xe18(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x60(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xe8c(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <scanf@plt>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe68(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2e2e(%rip),%r13
cmp    0x0(%r13),%al
jne    11ec <main+0x8c>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe2d(%rip),%r15
lea    0xe35(%rip),%r12
jmp    120e <main+0xae>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%r13),%al
je     11c0 <main+0x60>
cmp    $0x3c,%al
jne    1200 <main+0xa0>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <verificaTag@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    1200 <main+0xa0>

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i8 0
@.str.3 = [16 x i8] c"tag encontrada\0A\00"
@.str.4 = [21 x i8] c"continuando leitura\0A\00"
@.str.5 = [23 x i8] c"arquivo chegou ao fim\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [30 x i8]
%4 = alloca [30 x i8]
%5 = alloca i32*
%6 = alloca i32*
store i32 0, i32* %1
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %5
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %5
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %2
br label %16
16: ; preds = %32, %0
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %35
22: ; preds = %16
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 60
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32*, i32** %5
%29 = load i32*, i32** %6
%30 = call i32 @verificaTag(i32* %28, i32* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %26, %22
%33 = load i32*, i32** %5
%34 = call signext i8 @fgetc(i32* %33)
store i8 %34, i8* %2
br label %16
35: ; preds = %16
%36 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32*, i32** %5
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i8 0
@str = [22 x i8] c"arquivo chegou ao fim\00"
@str.6 = [15 x i8] c"tag encontrada\00"
@str.7 = [20 x i8] c"continuando leitura\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = call signext i8 @fgetc(i32* %6)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %22, label %11
11: ; preds = %0, %18
%12 = phi i8 [ %19, %18 ], [ %8, %0 ]
%13 = icmp eq i8 %12, 60
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0))
%16 = call i32 @verificaTag(i32* %6, i32* %7)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
br label %18
18: ; preds = %14, %11
%19 = call signext i8 @fgetc(i32* %6)
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %19, %20
br i1 %21, label %22, label %11
22: ; preds = %18, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%24 = call i32 @fclose(i32* %6)
%25 = call i32 @fclose(i32* %7)
ret i32 0
}