int morphological_feature_circularity_index(int *area, double *perim,
                                            int n_object, double *circ) {
  unsigned int i = 0;
  for (i = 0; i < n_object; i++) {
    circ[i] = 4.0 * 3.1415926535897932384626433832795 * area[i] /
              (perim[i] * perim[i]);
  }
  return 1;
}


x86 assembly (clang, -O0):
<morphological_feature_circularity_index>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    117b <morphological_feature_circularity_index+0x7b>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
cvtsi2sdl (%rax,%rcx,4),%xmm1
movsd  0xebf(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1121 <morphological_feature_circularity_index+0x21>
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<morphological_feature_circularity_index>:
test   %edx,%edx
je     1261 <morphological_feature_circularity_index+0x161>
mov    %edx,%r8d
cmp    $0x1,%edx
je     112a <morphological_feature_circularity_index+0x2a>
lea    (%rsi,%r8,8),%rax
cmp    %rcx,%rax
jbe    11bd <morphological_feature_circularity_index+0xbd>
lea    (%rcx,%r8,8),%rax
cmp    %rsi,%rax
jbe    11bd <morphological_feature_circularity_index+0xbd>
xor    %edx,%edx
mov    %rdx,%rax
not    %rax
test   $0x1,%r8b
je     115e <morphological_feature_circularity_index+0x5e>
xorps  %xmm0,%xmm0
cvtsi2sdl (%rdi,%rdx,4),%xmm0
mulsd  0xec8(%rip),%xmm0
movsd  (%rsi,%rdx,8),%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx,%rdx,8)
or     $0x1,%rdx
add    %r8,%rax
je     1261 <morphological_feature_circularity_index+0x161>
movsd  0xea1(%rip),%xmm0
nop
xorps  %xmm1,%xmm1
cvtsi2sdl (%rdi,%rdx,4),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsi,%rdx,8),%xmm2
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  %xmm1,(%rcx,%rdx,8)
xorps  %xmm1,%xmm1
cvtsi2sdl 0x4(%rdi,%rdx,4),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsi,%rdx,8),%xmm2
mulsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rcx,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%r8
jne    1170 <morphological_feature_circularity_index+0x70>
jmp    1261 <morphological_feature_circularity_index+0x161>
mov    %r8d,%edx
and    $0xfffffffe,%edx
lea    -0x2(%rdx),%rax
mov    %rax,%r9
shr    %r9
add    $0x1,%r9
test   %rax,%rax
je     1267 <morphological_feature_circularity_index+0x167>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
movapd 0xe15(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
cvtdq2pd (%rdi,%rax,4),%xmm1
mulpd  %xmm0,%xmm1
movupd (%rsi,%rax,8),%xmm2
mulpd  %xmm2,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,(%rcx,%rax,8)
cvtdq2pd 0x8(%rdi,%rax,4),%xmm1
mulpd  %xmm0,%xmm1
movupd 0x10(%rsi,%rax,8),%xmm2
mulpd  %xmm2,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,0x10(%rcx,%rax,8)
add    $0x4,%rax
add    $0xfffffffffffffffe,%r10
jne    11f0 <morphological_feature_circularity_index+0xf0>
test   $0x1,%r9b
je     1258 <morphological_feature_circularity_index+0x158>
cvtdq2pd (%rdi,%rax,4),%xmm0
mulpd  0xdba(%rip),%xmm0
movupd (%rsi,%rax,8),%xmm1
mulpd  %xmm1,%xmm1
divpd  %xmm1,%xmm0
movupd %xmm0,(%rcx,%rax,8)
cmp    %r8,%rdx
jne    112c <morphological_feature_circularity_index+0x2c>
mov    $0x1,%eax
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1239 <morphological_feature_circularity_index+0x139>
jmp    1258 <morphological_feature_circularity_index+0x158>

LLVM IR (-O0):
define i32 @morphological_feature_circularity_index(i32* %0, double* %1, i32 %2, double* %3) {
%5 = alloca i32*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
store i32* %0, i32** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double* %3, double** %8
store i32 0, i32* %9
store i32 0, i32* %9
br label %10
10: ; preds = %38, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = load i32*, i32** %5
%16 = load i32, i32* %9
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = sitofp i32 %19 to double
%21 = fmul double 0x402921FB54442D18, %20
%22 = load double*, double** %6
%23 = load i32, i32* %9
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %6
%28 = load i32, i32* %9
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = fmul double %26, %31
%33 = fdiv double %21, %32
%34 = load double*, double** %8
%35 = load i32, i32* %9
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %14
%39 = load i32, i32* %9
%40 = add i32 %39, 1
store i32 %40, i32* %9
br label %10
41: ; preds = %10
ret i32 1
}

LLVM IR (-O2):
define i32 @morphological_feature_circularity_index(i32* nocapture %0, double* nocapture %1, i32 %2, double* nocapture writeonly %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %116, label %6
6: ; preds = %4
%7 = zext i32 %2 to i64
%8 = icmp eq i32 %2, 1
br i1 %8, label %73, label %9
9: ; preds = %6
%10 = getelementptr double, double* %3, i64 %7
%11 = getelementptr double, double* %1, i64 %7
%12 = icmp ugt double* %11, %3
%13 = icmp ugt double* %10, %1
%14 = and i1 %12, %13
br i1 %14, label %73, label %15
15: ; preds = %9
%16 = and i64 %7, 4294967294
%17 = add nsw i64 %16, -2
%18 = lshr exact i64 %17, 1
%19 = add nuw i64 %18, 1
%20 = and i64 %19, 1
%21 = icmp eq i64 %17, 0
br i1 %21, label %55, label %22
22: ; preds = %15
%23 = and i64 %19, -2
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %52, %24 ]
%26 = phi i64 [ 0, %22 ], [ %53, %24 ]
%27 = getelementptr inbounds i32, i32* %0, i64 %25
%28 = bitcast i32* %27 to <2 x i32>*
%29 = load <2 x i32>, <2 x i32>* %28
%30 = sitofp <2 x i32> %29 to <2 x double>
%31 = fmul <2 x double> %30, <double 0x402921FB54442D18, double 0x402921FB54442D18>
%32 = getelementptr inbounds double, double* %1, i64 %25
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = fmul <2 x double> %34, %34
%36 = fdiv <2 x double> %31, %35
%37 = getelementptr inbounds double, double* %3, i64 %25
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %36, <2 x double>* %38
%39 = or i64 %25, 2
%40 = getelementptr inbounds i32, i32* %0, i64 %39
%41 = bitcast i32* %40 to <2 x i32>*
%42 = load <2 x i32>, <2 x i32>* %41
%43 = sitofp <2 x i32> %42 to <2 x double>
%44 = fmul <2 x double> %43, <double 0x402921FB54442D18, double 0x402921FB54442D18>
%45 = getelementptr inbounds double, double* %1, i64 %39
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = fmul <2 x double> %47, %47
%49 = fdiv <2 x double> %44, %48
%50 = getelementptr inbounds double, double* %3, i64 %39
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %49, <2 x double>* %51
%52 = add nuw i64 %25, 4
%53 = add nuw i64 %26, 2
%54 = icmp eq i64 %53, %23
br i1 %54, label %55, label %24
55: ; preds = %24, %15
%56 = phi i64 [ 0, %15 ], [ %52, %24 ]
%57 = icmp eq i64 %20, 0
br i1 %57, label %71, label %58
58: ; preds = %55
%59 = getelementptr inbounds i32, i32* %0, i64 %56
%60 = bitcast i32* %59 to <2 x i32>*
%61 = load <2 x i32>, <2 x i32>* %60
%62 = sitofp <2 x i32> %61 to <2 x double>
%63 = fmul <2 x double> %62, <double 0x402921FB54442D18, double 0x402921FB54442D18>
%64 = getelementptr inbounds double, double* %1, i64 %56
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fmul <2 x double> %66, %66
%68 = fdiv <2 x double> %63, %67
%69 = getelementptr inbounds double, double* %3, i64 %56
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %68, <2 x double>* %70
br label %71
71: ; preds = %55, %58
%72 = icmp eq i64 %16, %7
br i1 %72, label %116, label %73
73: ; preds = %9, %6, %71
%74 = phi i64 [ 0, %9 ], [ 0, %6 ], [ %16, %71 ]
%75 = xor i64 %74, -1
%76 = and i64 %7, 1
%77 = icmp eq i64 %76, 0
br i1 %77, label %89, label %78
78: ; preds = %73
%79 = getelementptr inbounds i32, i32* %0, i64 %74
%80 = load i32, i32* %79
%81 = sitofp i32 %80 to double
%82 = fmul double %81, 0x402921FB54442D18
%83 = getelementptr inbounds double, double* %1, i64 %74
%84 = load double, double* %83
%85 = fmul double %84, %84
%86 = fdiv double %82, %85
%87 = getelementptr inbounds double, double* %3, i64 %74
store double %86, double* %87
%88 = or i64 %74, 1
br label %89
89: ; preds = %78, %73
%90 = phi i64 [ %74, %73 ], [ %88, %78 ]
%91 = sub nsw i64 0, %7
%92 = icmp eq i64 %75, %91
br i1 %92, label %116, label %93
93: ; preds = %89, %93
%94 = phi i64 [ %114, %93 ], [ %90, %89 ]
%95 = getelementptr inbounds i32, i32* %0, i64 %94
%96 = load i32, i32* %95
%97 = sitofp i32 %96 to double
%98 = fmul double %97, 0x402921FB54442D18
%99 = getelementptr inbounds double, double* %1, i64 %94
%100 = load double, double* %99
%101 = fmul double %100, %100
%102 = fdiv double %98, %101
%103 = getelementptr inbounds double, double* %3, i64 %94
store double %102, double* %103
%104 = add nuw nsw i64 %94, 1
%105 = getelementptr inbounds i32, i32* %0, i64 %104
%106 = load i32, i32* %105
%107 = sitofp i32 %106 to double
%108 = fmul double %107, 0x402921FB54442D18
%109 = getelementptr inbounds double, double* %1, i64 %104
%110 = load double, double* %109
%111 = fmul double %110, %110
%112 = fdiv double %108, %111
%113 = getelementptr inbounds double, double* %3, i64 %104
store double %112, double* %113
%114 = add nuw nsw i64 %94, 2
%115 = icmp eq i64 %114, %7
br i1 %115, label %116, label %93
116: ; preds = %89, %93, %71, %4
ret i32 1
}