#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 *Tratamento();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int strlen(char *);
main() {
  FILE *arq_orig, *arq_novo;
  char lido[80];
  char *auxiliar;
  arq_orig = fopen("orig.txt", "r");
  arq_novo = fopen("novo.txt", "w");
  while (fgets(lido, 80, arq_orig) != NULL) {
    auxiliar = lido;
    fputs(auxiliar, arq_novo);
    if (!(auxiliar[strlen(auxiliar) - 1] == '\n'))
      fputs("\n", arq_novo);
    fputs(Tratamento(), arq_novo);
  }
  fclose(arq_orig);
  fclose(arq_novo);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7b(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1223 <main+0xc3>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     120b <main+0xab>
mov    -0x18(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1080 <Tratamento@plt>
mov    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
jmp    11a0 <main+0x40>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xe80(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe75(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r15
jmp    11c2 <main+0x52>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <Tratamento@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1203 <main+0x93>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r15,1)
je     11b0 <main+0x40>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    11b0 <main+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"orig.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"novo.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [80 x i8]
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %3
br label %8
8: ; preds = %30, %0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32* @fgets(i8* %9, i32 80, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %34
13: ; preds = %8
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = load i32*, i32** %3
%17 = call i32 @fputs(i8* %15, i32* %16)
%18 = load i8*, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %18, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 10
br i1 %26, label %30, label %27
27: ; preds = %13
%28 = load i32*, i32** %3
%29 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %27, %13
%31 = call i8* (...) @Tratamento()
%32 = load i32*, i32** %3
%33 = call i32 @fputs(i8* %31, i32* %32)
br label %8
34: ; preds = %8
%35 = load i32*, i32** %2
%36 = call i32 @fclose(i32* %35)
%37 = load i32*, i32** %3
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [9 x i8] c"orig.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"novo.txt\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32* @fgets(i8* %2, i32 80, i32* %3)
%6 = icmp eq i32* %5, null
br i1 %6, label %22, label %7
7: ; preds = %0, %17
%8 = call i32 @fputs(i8* %2, i32* %4)
%9 = call i32 @strlen(i8* %2)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %17, label %15
15: ; preds = %7
%16 = call i32 @fputc(i32 10, i32* %4)
br label %17
17: ; preds = %15, %7
%18 = call i8* (...) @Tratamento()
%19 = call i32 @fputs(i8* %18, i32* %4)
%20 = call i32* @fgets(i8* %2, i32 80, i32* %3)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %7
22: ; preds = %17, %0
%23 = call i32 @fclose(i32* %3)
%24 = call i32 @fclose(i32* %4)
ret i32 0
}