#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 */
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ *abri_arquivo();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
double pow(float, int);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ vazio_arquivo(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *farq;
  char tipo = {'r', 't', 'c'};
  char c;
  float cont[3], v[2] = {0, 0};
  float b = 0, h = 0, r = 0;
  farq = abri_arquivo();
  vazio_arquivo(farq);
  fseek(farq, 0, SEEK_SET);
  while (!feof(farq)) {
    c = fgetc(farq);
    fscanf(farq, "%f", &b);
    if (c == 'r') {
      fscanf(farq, "%f", &h);
      v[0] += (b * h);
      cont[0]++;
    } else if (c == 't') {
      fscanf(farq, "%f", &h);
      v[1] += (b * h);
      cont[1]++;
    } else if (c == 'c') {
      h = 0;
      b = pow(b, 2) * 3.14159;
      ;
      r += b;
      cont[2]++;
    }
  }
  fclose(farq);
  printf("Media areas de retangulo: %.2f \n", v[0] / cont[0]);
  printf("Media areas de triangulo: %.2f \n", v[1] / cont[1]);
  printf("Media areas de circulo: %.2f \n", r / cont[2]);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x72,-0x19(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    $0x0,%al
call   10a0 <abri_arquivo@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <vazio_arquivo@plt>
mov    -0x18(%rbp),%rdi
mov    0x2ddf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1228 <main+0x88>
jmp    1359 <main+0x1b9>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x1a(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdd1(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1070 <fscanf@plt>
movsbl -0x1a(%rbp),%eax
cmp    $0x72,%eax
jne    129c <main+0xfc>
mov    -0x18(%rbp),%rdi
lea    0xdb0(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <fscanf@plt>
movss  -0x34(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xd73(%rip),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    1354 <main+0x1b4>
movsbl -0x1a(%rbp),%eax
cmp    $0x74,%eax
jne    12f0 <main+0x150>
mov    -0x18(%rbp),%rdi
lea    0xd5c(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <fscanf@plt>
movss  -0x34(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xd1f(%rip),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    134f <main+0x1af>
movsbl -0x1a(%rbp),%eax
cmp    $0x63,%eax
jne    134a <main+0x1aa>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x34(%rbp),%xmm0
mov    $0x2,%edi
call   10c0 <pow@plt>
movsd  0xcec(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
addss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xcc0(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    134f <main+0x1af>
jmp    1354 <main+0x1b4>
jmp    120a <main+0x6a>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movss  -0x30(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
lea    0xca0(%rip),%rdi
call   1050 <printf@plt>
movss  -0x2c(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
lea    0xcab(%rip),%rdi
call   1050 <printf@plt>
movss  -0x3c(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
lea    0xcb6(%rip),%rdi
call   1050 <printf@plt>
mov    0x2c2d(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
xor    %eax,%eax
call   1090 <abri_arquivo@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1030 <vazio_arquivo@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %r13,%rdi
call   1080 <feof@plt>
xorps  %xmm0,%xmm0
test   %eax,%eax
je     1284 <main+0xf4>
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%rsp),%xmm0
divss  0x14(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
divss  0x1c(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  (%rsp),%xmm0
divss  0x18(%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    %r13,%rdi
call   1040 <fclose@plt>
lea    0xdd0(%rip),%rdi
movss  (%rsp),%xmm0
call   1050 <printf@plt>
lea    0xde0(%rip),%rdi
movss  0x8(%rsp),%xmm0
call   1050 <printf@plt>
lea    0xdef(%rip),%rdi
movss  0x4(%rsp),%xmm0
call   1050 <printf@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
movss  %xmm0,0x4(%rsp)
lea    0xd7b(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
jmp    12fe <main+0x16e>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
movss  0xc(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x1c(%rsp),%xmm0
addss  0xd20(%rip),%xmm0
movss  %xmm0,0x1c(%rsp)
mov    %r13,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11fc <main+0x6c>
mov    %r13,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
cmp    $0x63,%bl
je     1370 <main+0x1e0>
cmp    $0x74,%bl
je     12b0 <main+0x120>
cmp    $0x72,%bl
jne    12ee <main+0x15e>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
movss  0xc(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
movss  0x18(%rsp),%xmm0
addss  0xcad(%rip),%xmm0
movss  %xmm0,0x18(%rsp)
jmp    12ee <main+0x15e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
mov    $0x2,%edi
call   10b0 <pow@plt>
mulsd  0xc70(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x14(%rsp),%xmm0
addss  0xc50(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
jmp    12ee <main+0x15e>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%f\00"
@.str.1 = [33 x i8] c"Media areas de retangulo: %.2f \0A\00"
@.str.2 = [33 x i8] c"Media areas de triangulo: %.2f \0A\00"
@.str.3 = [31 x i8] c"Media areas de circulo: %.2f \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i8
%9 = alloca [3 x float]
%10 = alloca [2 x float]
%11 = alloca float
%12 = alloca float
%13 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 114, i8* %7
%14 = bitcast [2 x float]* %10 to i8*
store float 0.000000e+00, float* %11
store float 0.000000e+00, float* %12
store float 0.000000e+00, float* %13
%15 = call i32* (...) @abri_arquivo()
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = call i32 @vazio_arquivo(i32* %16)
%18 = load i32*, i32** %6
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @fseek(i32* %18, i32 0, i32 %19)
br label %21
21: ; preds = %77, %2
%22 = load i32*, i32** %6
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %78
26: ; preds = %21
%27 = load i32*, i32** %6
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %8
%29 = load i32*, i32** %6
%30 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %11)
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 114
br i1 %33, label %34, label %45
34: ; preds = %26
%35 = load i32*, i32** %6
%36 = call i32 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %12)
%37 = load float, float* %11
%38 = load float, float* %12
%39 = getelementptr inbounds [2 x float], [2 x float]* %10, i64 0, i64 0
%40 = load float, float* %39
%41 = call float @llvm.fmuladd.f32(float %37, float %38, float %40)
store float %41, float* %39
%42 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%43 = load float, float* %42
%44 = fadd float %43, 1.000000e+00
store float %44, float* %42
br label %77
45: ; preds = %26
%46 = load i8, i8* %8
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 116
br i1 %48, label %49, label %60
49: ; preds = %45
%50 = load i32*, i32** %6
%51 = call i32 @fscanf(i32* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %12)
%52 = load float, float* %11
%53 = load float, float* %12
%54 = getelementptr inbounds [2 x float], [2 x float]* %10, i64 0, i64 1
%55 = load float, float* %54
%56 = call float @llvm.fmuladd.f32(float %52, float %53, float %55)
store float %56, float* %54
%57 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%58 = load float, float* %57
%59 = fadd float %58, 1.000000e+00
store float %59, float* %57
br label %76
60: ; preds = %45
%61 = load i8, i8* %8
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 99
br i1 %63, label %64, label %75
64: ; preds = %60
store float 0.000000e+00, float* %12
%65 = load float, float* %11
%66 = call double @pow(float %65, i32 2)
%67 = fmul double %66, 3.141590e+00
%68 = fptrunc double %67 to float
store float %68, float* %11
%69 = load float, float* %11
%70 = load float, float* %13
%71 = fadd float %70, %69
store float %71, float* %13
%72 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%73 = load float, float* %72
%74 = fadd float %73, 1.000000e+00
store float %74, float* %72
br label %75
75: ; preds = %64, %60
br label %76
76: ; preds = %75, %49
br label %77
77: ; preds = %76, %34
br label %21
78: ; preds = %21
%79 = load i32*, i32** %6
%80 = call i32 @fclose(i32* %79)
%81 = getelementptr inbounds [2 x float], [2 x float]* %10, i64 0, i64 0
%82 = load float, float* %81
%83 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%84 = load float, float* %83
%85 = fdiv float %82, %84
%86 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), float %85)
%87 = getelementptr inbounds [2 x float], [2 x float]* %10, i64 0, i64 1
%88 = load float, float* %87
%89 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
%90 = load float, float* %89
%91 = fdiv float %88, %90
%92 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), float %91)
%93 = load float, float* %13
%94 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
%95 = load float, float* %94
%96 = fdiv float %93, %95
%97 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), float %96)
%98 = load i32, i32* @EXIT_SUCCESS
ret i32 %98
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%f\00"
@.str.1 = [33 x i8] c"Media areas de retangulo: %.2f \0A\00"
@.str.2 = [33 x i8] c"Media areas de triangulo: %.2f \0A\00"
@.str.3 = [31 x i8] c"Media areas de circulo: %.2f \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%6 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%7 = tail call i32* (...) @abri_arquivo()
%8 = tail call i32 @vazio_arquivo(i32* %7)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %7, i32 0, i32 %9)
%11 = call i32 @feof(i32* %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %50
13: ; preds = %2, %41
%14 = phi float [ %47, %41 ], [ 0.000000e+00, %2 ]
%15 = phi float [ %46, %41 ], [ 0.000000e+00, %2 ]
%16 = phi float [ %45, %41 ], [ 0.000000e+00, %2 ]
%17 = phi float [ %44, %41 ], [ undef, %2 ]
%18 = phi float [ %43, %41 ], [ undef, %2 ]
%19 = phi float [ %42, %41 ], [ undef, %2 ]
%20 = call signext i8 @fgetc(i32* %7)
%21 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
switch i8 %20, label %41 [
i8 114, label %22
i8 116, label %28
i8 99, label %34
]
22: ; preds = %13
%23 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %4)
%24 = load float, float* %3
%25 = load float, float* %4
%26 = call float @llvm.fmuladd.f32(float %24, float %25, float %16)
%27 = fadd float %17, 1.000000e+00
br label %41
28: ; preds = %13
%29 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %4)
%30 = load float, float* %3
%31 = load float, float* %4
%32 = call float @llvm.fmuladd.f32(float %30, float %31, float %15)
%33 = fadd float %18, 1.000000e+00
br label %41
34: ; preds = %13
store float 0.000000e+00, float* %4
%35 = load float, float* %3
%36 = call double @pow(float %35, i32 2)
%37 = fmul double %36, 3.141590e+00
%38 = fptrunc double %37 to float
store float %38, float* %3
%39 = fadd float %14, %38
%40 = fadd float %19, 1.000000e+00
br label %41
41: ; preds = %13, %28, %34, %22
%42 = phi float [ %19, %22 ], [ %19, %28 ], [ %40, %34 ], [ %19, %13 ]
%43 = phi float [ %18, %22 ], [ %33, %28 ], [ %18, %34 ], [ %18, %13 ]
%44 = phi float [ %27, %22 ], [ %17, %28 ], [ %17, %34 ], [ %17, %13 ]
%45 = phi float [ %26, %22 ], [ %16, %28 ], [ %16, %34 ], [ %16, %13 ]
%46 = phi float [ %15, %22 ], [ %32, %28 ], [ %15, %34 ], [ %15, %13 ]
%47 = phi float [ %14, %22 ], [ %14, %28 ], [ %39, %34 ], [ %14, %13 ]
%48 = call i32 @feof(i32* %7)
%49 = icmp eq i32 %48, 0
br i1 %49, label %13, label %50
50: ; preds = %41, %2
%51 = phi float [ undef, %2 ], [ %42, %41 ]
%52 = phi float [ undef, %2 ], [ %43, %41 ]
%53 = phi float [ undef, %2 ], [ %44, %41 ]
%54 = phi float [ 0.000000e+00, %2 ], [ %45, %41 ]
%55 = phi float [ 0.000000e+00, %2 ], [ %46, %41 ]
%56 = phi float [ 0.000000e+00, %2 ], [ %47, %41 ]
%57 = call i32 @fclose(i32* %7)
%58 = fdiv float %54, %53
%59 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), float %58)
%60 = fdiv float %55, %52
%61 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), float %60)
%62 = fdiv float %56, %51
%63 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), float %62)
%64 = load i32, i32* @EXIT_SUCCESS
ret i32 %64
}