#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 */
float calcula(float **, float *, char, int /*<<< orphan*/ **);
int /*<<< orphan*/ derivada(float **, float *, char, int /*<<< orphan*/ **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ integral(float **, float *, char, int /*<<< orphan*/ **);
int /*<<< orphan*/ ler_arquivo_polinomio(float **, float **, float *,
                                         int /*<<< orphan*/ **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ soma(float **, float **, float *, int /*<<< orphan*/ **);
int /*<<< orphan*/ subtrai(float **, float **, float *, int /*<<< orphan*/ **);
int main() {
  FILE *saida = NULL;
  float x;
  float *polinomio1 = NULL;
  float *polinomio2 = NULL;
  float valor;
  saida = fopen("p-output.txt", "w");
  if (!saida) {
    printf("Erro ao abrir arquivo!\n");
    return 1;
  }
  ler_arquivo_polinomio(&polinomio1, &polinomio2, &x, &saida);
  valor = calcula(&polinomio1, &x, 'P', &saida);
  valor = calcula(&polinomio2, &x, 'Q', &saida);
  soma(&polinomio1, &polinomio2, &x, &saida);
  subtrai(&polinomio1, &polinomio2, &x, &saida);
  derivada(&polinomio2, &x, 'Q', &saida);
  integral(&polinomio1, &x, 'P', &saida);
  printf("Fim\n");
  fprintf(saida, "Fim\n");
  fclose(saida);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe32(%rip),%rdi
lea    0xe38(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1201 <main+0x61>
lea    0xe1f(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ce <main+0x12e>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1090 <ler_arquivo_polinomio@plt>
lea    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x50,%edx
lea    -0x10(%rbp),%rcx
call   1030 <calcula@plt>
movss  %xmm0,-0x2c(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x51,%edx
lea    -0x10(%rbp),%rcx
call   1030 <calcula@plt>
movss  %xmm0,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1080 <soma@plt>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   10b0 <subtrai@plt>
lea    -0x28(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x51,%edx
lea    -0x10(%rbp),%rcx
call   10c0 <derivada@plt>
lea    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x50,%edx
lea    -0x10(%rbp),%rcx
call   1040 <integral@plt>
lea    0xd7e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe3c(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     12a6 <main+0x106>
lea    0x18(%rsp),%r14
lea    0x10(%rsp),%r12
lea    0x24(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1080 <ler_arquivo_polinomio@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x50,%edx
mov    %r15,%rcx
call   1030 <calcula@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x51,%edx
mov    %r15,%rcx
call   1030 <calcula@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1070 <soma@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   10a0 <subtrai@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x51,%edx
mov    %r15,%rcx
call   10b0 <derivada@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x50,%edx
mov    %r15,%rcx
call   1050 <integral@plt>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rcx
lea    0xd86(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    12b7 <main+0x117>
lea    0xd67(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"p-output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [24 x i8] c"Erro ao abrir arquivo!\0A\00"
@.str.3 = [5 x i8] c"Fim\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca float
%4 = alloca float*
%5 = alloca float*
%6 = alloca float
store i32 0, i32* %1
store i32* null, i32** %2
store float* null, float** %4
store float* null, float** %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %25
12: ; preds = %0
%13 = call i32 @ler_arquivo_polinomio(float** %4, float** %5, float* %3, i32** %2)
%14 = call float @calcula(float** %4, float* %3, i8 signext 80, i32** %2)
store float %14, float* %6
%15 = call float @calcula(float** %5, float* %3, i8 signext 81, i32** %2)
store float %15, float* %6
%16 = call i32 @soma(float** %4, float** %5, float* %3, i32** %2)
%17 = call i32 @subtrai(float** %4, float** %5, float* %3, i32** %2)
%18 = call i32 @derivada(float** %5, float* %3, i8 signext 81, i32** %2)
%19 = call i32 @integral(float** %4, float* %3, i8 signext 80, i32** %2)
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32*, i32** %2
%22 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
store i32 0, i32* %1
br label %25
25: ; preds = %12, %10
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [13 x i8] c"p-output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [5 x i8] c"Fim\0A\00"
@str = [23 x i8] c"Erro ao abrir arquivo!\00"
@str.4 = [4 x i8] c"Fim\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca float
%3 = alloca float*
%4 = alloca float*
%5 = bitcast i32** %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float** %3 to i8*
store float* null, float** %3
%8 = bitcast float** %4 to i8*
store float* null, float** %4
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %1
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %26
13: ; preds = %0
%14 = call i32 @ler_arquivo_polinomio(float** %3, float** %4, float* %2, i32** %1)
%15 = call float @calcula(float** %3, float* %2, i8 signext 80, i32** %1)
%16 = call float @calcula(float** %4, float* %2, i8 signext 81, i32** %1)
%17 = call i32 @soma(float** %3, float** %4, float* %2, i32** %1)
%18 = call i32 @subtrai(float** %3, float** %4, float* %2, i32** %1)
%19 = call i32 @derivada(float** %4, float* %2, i8 signext 81, i32** %1)
%20 = call i32 @integral(float** %3, float* %2, i8 signext 80, i32** %1)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0))
%22 = load i32*, i32** %1
%23 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4, i64 1, i32* %22)
%24 = load i32*, i32** %1
%25 = call i32 @fclose(i32* %24)
br label %26
26: ; preds = %13, %11
%27 = phi i32 [ 0, %13 ], [ 1, %11 ]
ret i32 %27
}