#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 *, double *, double *);
double sqrt(double);
int main() {
  double a, b, c, s, area, perimeter;
  printf("Enter 3 sides of the triangle: ");
  scanf("%lf %lf %lf", &a, &b, &c);
  if (a + b > c && a + c > b && b + c > a) {
    s = (a + b + c) / 2;
    area = sqrt(s * (s - a) * (s - b) * (s - c));
    perimeter = a + b + c;
    printf("area=%.2f; perimeter=%.2f\n", area, perimeter);
  } else
    printf("These sides do not correspond to a valid triangle\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    122e <main+0xfe>
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    122e <main+0xfe>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    122e <main+0xfe>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe12(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    123c <main+0x10c>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e2 <main+0xa2>
movapd %xmm3,%xmm4
addsd  %xmm1,%xmm4
ucomisd %xmm2,%xmm4
jbe    11e2 <main+0xa2>
movapd %xmm2,%xmm4
addsd  %xmm1,%xmm4
ucomisd %xmm3,%xmm4
jbe    11e2 <main+0xa2>
addsd  %xmm1,%xmm0
mulsd  0xe4e(%rip),%xmm0
movapd %xmm0,%xmm4
subsd  %xmm3,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm0,%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm4,%xmm3
subsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f0 <main+0xb0>
sqrtsd %xmm0,%xmm0
jmp    11f5 <main+0xb5>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
jmp    1214 <main+0xd4>
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
addsd  (%rsp),%xmm1
lea    0xe27(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter 3 sides of the triangle: \00"
@.str.1 = [12 x i8] c"%lf %lf %lf\00"
@.str.2 = [27 x i8] c"area=%.2f; perimeter=%.2f\0A\00"
@.str.3 = [51 x i8] c"These sides do not correspond to a valid triangle\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4)
%10 = load double, double* %2
%11 = load double, double* %3
%12 = fadd double %10, %11
%13 = load double, double* %4
%14 = fcmp ogt double %12, %13
br i1 %14, label %15, label %56
15: ; preds = %0
%16 = load double, double* %2
%17 = load double, double* %4
%18 = fadd double %16, %17
%19 = load double, double* %3
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %56
21: ; preds = %15
%22 = load double, double* %3
%23 = load double, double* %4
%24 = fadd double %22, %23
%25 = load double, double* %2
%26 = fcmp ogt double %24, %25
br i1 %26, label %27, label %56
27: ; preds = %21
%28 = load double, double* %2
%29 = load double, double* %3
%30 = fadd double %28, %29
%31 = load double, double* %4
%32 = fadd double %30, %31
%33 = fdiv double %32, 2.000000e+00
store double %33, double* %5
%34 = load double, double* %5
%35 = load double, double* %5
%36 = load double, double* %2
%37 = fsub double %35, %36
%38 = fmul double %34, %37
%39 = load double, double* %5
%40 = load double, double* %3
%41 = fsub double %39, %40
%42 = fmul double %38, %41
%43 = load double, double* %5
%44 = load double, double* %4
%45 = fsub double %43, %44
%46 = fmul double %42, %45
%47 = call double @sqrt(double %46)
store double %47, double* %6
%48 = load double, double* %2
%49 = load double, double* %3
%50 = fadd double %48, %49
%51 = load double, double* %4
%52 = fadd double %50, %51
store double %52, double* %7
%53 = load double, double* %6
%54 = load double, double* %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %53, double %54)
br label %58
56: ; preds = %21, %15, %0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter 3 sides of the triangle: \00"
@.str.1 = [12 x i8] c"%lf %lf %lf\00"
@.str.2 = [27 x i8] c"area=%.2f; perimeter=%.2f\0A\00"
@str = [50 x i8] c"These sides do not correspond to a valid triangle\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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3)
%9 = load double, double* %1
%10 = load double, double* %2
%11 = fadd double %9, %10
%12 = load double, double* %3
%13 = fcmp ogt double %11, %12
%14 = fadd double %9, %12
%15 = fcmp ogt double %14, %10
%16 = and i1 %13, %15
%17 = fadd double %10, %12
%18 = fcmp ogt double %17, %9
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %20, label %36
20: ; preds = %0
%21 = fadd double %11, %12
%22 = fmul double %21, 5.000000e-01
%23 = fsub double %22, %9
%24 = fmul double %22, %23
%25 = fsub double %22, %10
%26 = fmul double %25, %24
%27 = fsub double %22, %12
%28 = fmul double %27, %26
%29 = call double @sqrt(double %28)
%30 = load double, double* %1
%31 = load double, double* %2
%32 = fadd double %30, %31
%33 = load double, double* %3
%34 = fadd double %32, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %29, double %34)
br label %38
36: ; preds = %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %38
38: ; preds = %36, %20
ret i32 0
}