#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 hypot2_sqr(double const, double const);
double roundness(const double v1[2], const double v2[2], const double v3[2],
                 int *short_edge) {
  double d12, d23, d31, dmin, dmax;
  d12 = hypot2_sqr(v1[0] - v2[0], v1[1] - v2[1]);
  d23 = hypot2_sqr(v2[0] - v3[0], v2[1] - v3[1]);
  d31 = hypot2_sqr(v3[0] - v1[0], v3[1] - v1[1]);
  *short_edge = 0;
  dmax = dmin = d12;
  if (d23 < dmin) {
    dmin = d23;
    *short_edge = 1;
  } else if (d23 > dmax)
    dmax = d23;
  if (d31 < dmin) {
    dmin = d31;
    *short_edge = 2;
  } else if (d31 > dmax)
    dmax = d31;
  if (dmax == 0.0)
    return 1.0;
  return dmin / dmax;
}


x86 assembly (clang, -O0):
<roundness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f2 <roundness+0xe2>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    1211 <roundness+0x101>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    120c <roundness+0xfc>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1211 <roundness+0x101>
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    123e <roundness+0x12e>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x2,(%rax)
jmp    125d <roundness+0x14d>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1258 <roundness+0x148>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    125d <roundness+0x14d>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1287 <roundness+0x177>
jp     1287 <roundness+0x177>
movsd  0xd83(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1296 <roundness+0x186>
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roundness>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
subsd  (%rsi),%xmm0
subsd  0x8(%rsi),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
subsd  (%r12),%xmm0
subsd  0x8(%r12),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%r12),%xmm0
movsd  0x8(%r12),%xmm1
subsd  (%r15),%xmm0
subsd  0x8(%r15),%xmm1
call   1030 <hypot2_sqr@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movapd %xmm0,%xmm1
movl   $0x0,(%r14)
ucomisd %xmm3,%xmm2
jbe    11b2 <roundness+0xa2>
movl   $0x1,(%r14)
movapd %xmm3,%xmm0
ucomisd %xmm1,%xmm0
jbe    11c6 <roundness+0xb6>
jmp    11dc <roundness+0xcc>
ucomisd %xmm2,%xmm3
jbe    11d2 <roundness+0xc2>
movapd %xmm2,%xmm0
movapd %xmm3,%xmm2
ucomisd %xmm1,%xmm0
ja     11dc <roundness+0xcc>
ucomisd %xmm2,%xmm1
jbe    11e7 <roundness+0xd7>
movapd %xmm1,%xmm2
jmp    11e7 <roundness+0xd7>
movapd %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11c6 <roundness+0xb6>
movl   $0x2,(%r14)
movapd %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    11fd <roundness+0xed>
jp     11fd <roundness+0xed>
movsd  0xe05(%rip),%xmm0
jmp    1201 <roundness+0xf1>
divsd  %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @roundness(double* %0, double* %1, double* %2, i32* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32* %3, i32** %9
%15 = load double*, double** %6
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %7
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = fsub double %17, %20
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = load double*, double** %7
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = call double @hypot2_sqr(double %21, double %28)
store double %29, double* %10
%30 = load double*, double** %7
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = load double*, double** %8
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = fsub double %32, %35
%37 = load double*, double** %7
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = fsub double %39, %42
%44 = call double @hypot2_sqr(double %36, double %43)
store double %44, double* %11
%45 = load double*, double** %8
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = load double*, double** %6
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = fsub double %47, %50
%52 = load double*, double** %8
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = load double*, double** %6
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fsub double %54, %57
%59 = call double @hypot2_sqr(double %51, double %58)
store double %59, double* %12
%60 = load i32*, i32** %9
store i32 0, i32* %60
%61 = load double, double* %10
store double %61, double* %13
store double %61, double* %14
%62 = load double, double* %11
%63 = load double, double* %13
%64 = fcmp olt double %62, %63
br i1 %64, label %65, label %68
65: ; preds = %4
%66 = load double, double* %11
store double %66, double* %13
%67 = load i32*, i32** %9
store i32 1, i32* %67
br label %75
68: ; preds = %4
%69 = load double, double* %11
%70 = load double, double* %14
%71 = fcmp ogt double %69, %70
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = load double, double* %11
store double %73, double* %14
br label %74
74: ; preds = %72, %68
br label %75
75: ; preds = %74, %65
%76 = load double, double* %12
%77 = load double, double* %13
%78 = fcmp olt double %76, %77
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load double, double* %12
store double %80, double* %13
%81 = load i32*, i32** %9
store i32 2, i32* %81
br label %89
82: ; preds = %75
%83 = load double, double* %12
%84 = load double, double* %14
%85 = fcmp ogt double %83, %84
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = load double, double* %12
store double %87, double* %14
br label %88
88: ; preds = %86, %82
br label %89
89: ; preds = %88, %79
%90 = load double, double* %14
%91 = fcmp oeq double %90, 0.000000e+00
br i1 %91, label %92, label %93
92: ; preds = %89
store double 1.000000e+00, double* %5
br label %97
93: ; preds = %89
%94 = load double, double* %13
%95 = load double, double* %14
%96 = fdiv double %94, %95
store double %96, double* %5
br label %97
97: ; preds = %93, %92
%98 = load double, double* %5
ret double %98
}

LLVM IR (-O2):
define double @roundness(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32* nocapture writeonly %3) {
%5 = load double, double* %0
%6 = load double, double* %1
%7 = fsub double %5, %6
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = tail call double @hypot2_sqr(double %7, double %12)
%14 = load double, double* %1
%15 = load double, double* %2
%16 = fsub double %14, %15
%17 = load double, double* %10
%18 = getelementptr inbounds double, double* %2, i64 1
%19 = load double, double* %18
%20 = fsub double %17, %19
%21 = tail call double @hypot2_sqr(double %16, double %20)
%22 = load double, double* %2
%23 = load double, double* %0
%24 = fsub double %22, %23
%25 = load double, double* %18
%26 = load double, double* %8
%27 = fsub double %25, %26
%28 = tail call double @hypot2_sqr(double %24, double %27)
store i32 0, i32* %3
%29 = fcmp olt double %21, %13
br i1 %29, label %30, label %31
30: ; preds = %4
store i32 1, i32* %3
br label %34
31: ; preds = %4
%32 = fcmp ogt double %21, %13
br i1 %32, label %33, label %34
33: ; preds = %31
br label %34
34: ; preds = %31, %33, %30
%35 = phi double [ %21, %30 ], [ %13, %33 ], [ %13, %31 ]
%36 = phi double [ %13, %30 ], [ %21, %33 ], [ %13, %31 ]
%37 = fcmp olt double %28, %35
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 2, i32* %3
br label %42
39: ; preds = %34
%40 = fcmp ogt double %28, %36
br i1 %40, label %41, label %42
41: ; preds = %39
br label %42
42: ; preds = %39, %41, %38
%43 = phi double [ %28, %38 ], [ %35, %41 ], [ %35, %39 ]
%44 = phi double [ %36, %38 ], [ %28, %41 ], [ %36, %39 ]
%45 = fcmp oeq double %44, 0.000000e+00
%46 = fdiv double %43, %44
%47 = select i1 %45, double 1.000000e+00, double %46
ret double %47
}