#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 *, double *);
int main() {
  double a, b, h, area;
  printf("a: ");
  scanf("%lf", &a);
  printf("b: ");
  scanf("%lf", &b);
  printf("h: ");
  scanf("%lf", &h);
  if (a <= 0 || b <= 0 || h <= 0) {
    printf("Invalid input!\n");
    return 1;
  } else {
    area = ((a + b) / 2.0) * h;
    printf("Area: %.2lf\n", area);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    11b3 <main+0x93>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    11b3 <main+0x93>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11cd <main+0xad>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1207 <main+0xe7>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11db <main+0xab>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm2,%xmm0
jae    11db <main+0xab>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
jae    11db <main+0xab>
addsd  %xmm2,%xmm1
mulsd  0xe3b(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
jmp    11ec <main+0xbc>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"a: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"b: \00"
@.str.3 = [4 x i8] c"h: \00"
@.str.4 = [16 x i8] c"Invalid input!\0A\00"
@.str.5 = [13 x i8] c"Area: %.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%12 = load double, double* %2
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %20, label %14
14: ; preds = %0
%15 = load double, double* %3
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load double, double* %4
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %17, %14, %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %32
22: ; preds = %17
%23 = load double, double* %2
%24 = load double, double* %3
%25 = fadd double %23, %24
%26 = fdiv double %25, 2.000000e+00
%27 = load double, double* %4
%28 = fmul double %26, %27
store double %28, double* %5
%29 = load double, double* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %29)
br label %31
31: ; preds = %22
store i32 0, i32* %1
br label %32
32: ; preds = %31, %20
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"a: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [4 x i8] c"b: \00"
@.str.3 = [4 x i8] c"h: \00"
@.str.5 = [13 x i8] c"Area: %.2lf\0A\00"
@str = [15 x i8] c"Invalid input!\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = load double, double* %1
%14 = fcmp ole double %13, 0.000000e+00
%15 = load double, double* %2
%16 = fcmp ole double %15, 0.000000e+00
%17 = select i1 %14, i1 true, i1 %16
%18 = load double, double* %3
%19 = fcmp ole double %18, 0.000000e+00
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %28
23: ; preds = %0
%24 = fadd double %13, %15
%25 = fmul double %24, 5.000000e-01
%26 = fmul double %18, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %26)
br label %28
28: ; preds = %23, %21
%29 = phi i32 [ 1, %21 ], [ 0, %23 ]
ret i32 %29
}