#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 *);
void main() {
  float base, altura;
  printf("\nDigite o valor da base: ");
  scanf("%f", &base);
  printf("Digite o valor da altura: ");
  scanf(" %f", &altura);
  if (base <= 0 || altura <= 0)
    printf("\nTriangulo invalido.\n");
  else
    printf("\nArea do triangulo: %.2f.\n", base * altura / 2.0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jae    117e <main+0x5e>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1191 <main+0x71>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <main+0x99>
movss  -0x4(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jae    11a5 <main+0x75>
movss  (%rsp),%xmm1
ucomiss %xmm1,%xmm2
jae    11a5 <main+0x75>
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe6b(%rip),%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
pop    %rax
ret
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0ADigite o valor da base: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [27 x i8] c"Digite o valor da altura: \00"
@.str.3 = [4 x i8] c" %f\00"
@.str.4 = [22 x i8] c"\0ATriangulo invalido.\0A\00"
@.str.5 = [27 x i8] c"\0AArea do triangulo: %.2f.\0A\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %2)
%7 = load float, float* %1
%8 = fcmp ole float %7, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load float, float* %2
%11 = fcmp ole float %10, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %9, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %21
14: ; preds = %9
%15 = load float, float* %1
%16 = load float, float* %2
%17 = fmul float %15, %16
%18 = fpext float %17 to double
%19 = fdiv double %18, 2.000000e+00
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %19)
br label %21
21: ; preds = %14, %12
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0ADigite o valor da base: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [27 x i8] c"Digite o valor da altura: \00"
@.str.3 = [4 x i8] c" %f\00"
@.str.5 = [27 x i8] c"\0AArea do triangulo: %.2f.\0A\00"
@str = [21 x i8] c"\0ATriangulo invalido.\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), float* %2)
%9 = load float, float* %1
%10 = fcmp ole float %9, 0.000000e+00
%11 = load float, float* %2
%12 = fcmp ole float %11, 0.000000e+00
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %21
16: ; preds = %0
%17 = fmul float %9, %11
%18 = fpext float %17 to double
%19 = fmul double %18, 5.000000e-01
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %19)
br label %21
21: ; preds = %16, %14
ret void
}