#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 sqrt(double);
int main() {
  double triangleA = 0, triangleB = 0, triangleC = 0;
  double area = 0, halfPerimeter = 0;
  printf("Please enter the sides of the triangle:\n Side A = ");
  scanf("%lf", &triangleA);
  printf("\n Side B = ");
  scanf("%lf", &triangleB);
  printf("\n Side C = ");
  scanf("%lf", &triangleC);
  halfPerimeter = (triangleA + triangleB + triangleC) / 2;
  area = sqrt(halfPerimeter * (halfPerimeter - triangleA) *
              (halfPerimeter - triangleB) * (halfPerimeter - triangleC));
  printf("Area = %lf", area);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe2d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm0
mulsd  0xe32(%rip),%xmm0
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11fe <main+0xce>
sqrtsd %xmm0,%xmm0
jmp    1203 <main+0xd3>
call   1050 <sqrt@plt>
lea    0xe49(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Please enter the sides of the triangle:\0A Side A = \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"\0A Side B = \00"
@.str.3 = [12 x i8] c"\0A Side C = \00"
@.str.4 = [11 x i8] c"Area = %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 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* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 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* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 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* %4)
%13 = load double, double* %2
%14 = load double, double* %3
%15 = fadd double %13, %14
%16 = load double, double* %4
%17 = fadd double %15, %16
%18 = fdiv double %17, 2.000000e+00
store double %18, double* %6
%19 = load double, double* %6
%20 = load double, double* %6
%21 = load double, double* %2
%22 = fsub double %20, %21
%23 = fmul double %19, %22
%24 = load double, double* %6
%25 = load double, double* %3
%26 = fsub double %24, %25
%27 = fmul double %23, %26
%28 = load double, double* %6
%29 = load double, double* %4
%30 = fsub double %28, %29
%31 = fmul double %27, %30
%32 = call double @sqrt(double %31)
store double %32, double* %5
%33 = load double, double* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"Please enter the sides of the triangle:\0A Side A = \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"\0A Side B = \00"
@.str.3 = [12 x i8] c"\0A Side C = \00"
@.str.4 = [11 x i8] c"Area = %lf\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 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 ([12 x i8], [12 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 ([12 x i8], [12 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 = load double, double* %2
%15 = fadd double %13, %14
%16 = load double, double* %3
%17 = fadd double %15, %16
%18 = fmul double %17, 5.000000e-01
%19 = fsub double %18, %13
%20 = fmul double %18, %19
%21 = fsub double %18, %14
%22 = fmul double %21, %20
%23 = fsub double %18, %16
%24 = fmul double %23, %22
%25 = call double @sqrt(double %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %25)
ret i32 0
}