#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float B, b, altura, area;
  printf("-------- TRAPÉZIO --------\n");
  printf("Digite a base maior: ");
  scanf("%f", &B);
  printf("Digite a base menor: ");
  scanf("%f", &b);
  printf("Digite a altura: ");
  scanf("%f", &altura);
  if (B <= 0.0 || b <= 0.0 || altura <= 0.0) {
    printf("Valor menor ou igual a zero é invalido. Programa encerrado!");
  } else {
    area = ((B + b) * altura) / 2.0;
    printf("Area do Trapézio: %.2f", area);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11d9 <main+0xb9>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11d9 <main+0xb9>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     11ec <main+0xcc>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0x10b>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf9(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jae    11e4 <main+0xb4>
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm2
jae    11e4 <main+0xb4>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
ucomiss %xmm2,%xmm3
jae    11e4 <main+0xb4>
addss  %xmm1,%xmm0
mulss  %xmm2,%xmm0
mulss  0xe30(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11f2 <main+0xc2>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"-------- TRAP\C3\89ZIO --------\0A\00"
@.str.1 = [22 x i8] c"Digite a base maior: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [22 x i8] c"Digite a base menor: \00"
@.str.4 = [18 x i8] c"Digite a altura: \00"
@.str.5 = [61 x i8] c"Valor menor ou igual a zero \C3\A9 invalido. Programa encerrado!\00"
@.str.6 = [24 x i8] c"Area do Trap\C3\A9zio: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%13 = load float, float* %2
%14 = fpext float %13 to double
%15 = fcmp ole double %14, 0.000000e+00
br i1 %15, label %24, label %16
16: ; preds = %0
%17 = load float, float* %3
%18 = fpext float %17 to double
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = fcmp ole double %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %20, %16, %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
br label %38
26: ; preds = %20
%27 = load float, float* %2
%28 = load float, float* %3
%29 = fadd float %27, %28
%30 = load float, float* %4
%31 = fmul float %29, %30
%32 = fpext float %31 to double
%33 = fdiv double %32, 2.000000e+00
%34 = fptrunc double %33 to float
store float %34, float* %5
%35 = load float, float* %5
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %36)
br label %38
38: ; preds = %26, %24
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Digite a base maior: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [22 x i8] c"Digite a base menor: \00"
@.str.4 = [18 x i8] c"Digite a altura: \00"
@.str.5 = [61 x i8] c"Valor menor ou igual a zero \C3\A9 invalido. Programa encerrado!\00"
@.str.6 = [24 x i8] c"Area do Trap\C3\A9zio: %.2f\00"
@str = [28 x i8] c"-------- TRAP\C3\89ZIO --------\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = load float, float* %1
%15 = fcmp ugt float %14, 0.000000e+00
br i1 %15, label %16, label %22
16: ; preds = %0
%17 = load float, float* %2
%18 = fcmp ugt float %17, 0.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load float, float* %3
%21 = fcmp ugt float %20, 0.000000e+00
br i1 %21, label %24, label %22
22: ; preds = %19, %16, %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
br label %30
24: ; preds = %19
%25 = fadd float %14, %17
%26 = fmul float %25, %20
%27 = fmul float %26, 5.000000e-01
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %28)
br label %30
30: ; preds = %24, %22
ret i32 0
}