#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 */
double areaTriangle(double);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ printf(char *, double);
scalar_t__ scanf(char *, double *);
int main() {
  double input;
  while (scanf("%lf", &input)) {
    if (input < 0)
      die("Not a positive number");
    printf("Area: %f\n", areaTriangle(input));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     119e <main+0x5e>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1183 <main+0x43>
lea    0xe86(%rip),%rdi
call   1060 <die@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <areaTriangle@plt>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb9(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11bb <main+0x7b>
lea    0xea9(%rip),%r14
lea    0xeb8(%rip),%r15
lea    0xe97(%rip),%r12
mov    %rsp,%rbx
jmp    119d <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
call   1040 <areaTriangle@plt>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11bb <main+0x7b>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1180 <main+0x40>
mov    %r14,%rdi
call   1060 <die@plt>
movsd  (%rsp),%xmm0
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [22 x i8] c"Not a positive number\00"
@.str.2 = [10 x i8] c"Area: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
br label %3
3: ; preds = %11, %0
%4 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load double, double* %2
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = load double, double* %2
%13 = call double @areaTriangle(double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %3
15: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [22 x i8] c"Not a positive number\00"
@.str.2 = [10 x i8] c"Area: %f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %0, %11
%6 = load double, double* %1
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = load double, double* %1
br label %11
11: ; preds = %8, %5
%12 = phi double [ %10, %8 ], [ %6, %5 ]
%13 = call double @areaTriangle(double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %13)
%15 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %11, %0
ret i32 0
}