#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 */

/* Variables and functions */
int /*<<< orphan*/ ex4(char *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strtok(char *, char *);
int main() {
  char *in = malloc(128 * sizeof(char)), *out = malloc(128 * sizeof(char));
  printf("Digite o nome do arquivo de alunos antigo: ");
  fgets(in, 128, stdin);
  strtok(in, "\n");
  printf("Digite o nome do arquivo de alunos novo: ");
  fgets(out, 128, stdin);
  strtok(out, "\n");
  ex4(in, out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1070 <strtok@plt>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1070 <strtok@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <ex4@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e63(%rip),%r12
mov    (%r12),%edx
mov    %r14,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    0xe8f(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <ex4@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Digite o nome do arquivo de alunos antigo: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c"Digite o nome do arquivo de alunos novo: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @malloc(i32 128)
store i8* %4, i8** %2
%5 = call i8* @malloc(i32 128)
store i8* %5, i8** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 128, i32 %8)
%10 = load i8*, i8** %2
%11 = call i32 @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** %3
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 128, i32 %14)
%16 = load i8*, i8** %3
%17 = call i32 @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %2
%19 = load i8*, i8** %3
%20 = call i32 @ex4(i8* %18, i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Digite o nome do arquivo de alunos antigo: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c"Digite o nome do arquivo de alunos novo: \00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%2 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgets(i8* %1, i32 128, i32 %4)
%6 = tail call i32 @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = tail call i32 @fgets(i8* %2, i32 128, i32 %8)
%10 = tail call i32 @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @ex4(i8* %1, i8* %2)
ret i32 0
}