int triangleType(double arr[]) {
  int type = 0;
  if (arr[0] == arr[1])
    type++;
  if (arr[1] == arr[2])
    type++;
  if (arr[2] == arr[0])
    type++;
  return type;
}


x86 assembly (clang, -O0):
<triangleType>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jne    1135 <triangleType+0x35>
jp     1135 <triangleType+0x35>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
ucomisd 0x10(%rax),%xmm0
jne    115c <triangleType+0x5c>
jp     115c <triangleType+0x5c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
ucomisd (%rax),%xmm0
jne    1182 <triangleType+0x82>
jp     1182 <triangleType+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangleType>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movapd %xmm0,%xmm2
cmpeqsd %xmm1,%xmm2
movq   %xmm2,%rcx
movsd  0x10(%rdi),%xmm2
mov    $0x1,%eax
sub    %ecx,%eax
and    $0x1,%ecx
ucomisd %xmm2,%xmm1
cmovne %ecx,%eax
cmovp  %ecx,%eax
cmpeqsd %xmm0,%xmm2
movq   %xmm2,%rcx
sub    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @triangleType(double* nocapture %0) {
%2 = load double, double* %0
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = fcmp oeq double %2, %4
%6 = zext i1 %5 to i32
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = fcmp oeq double %4, %8
%10 = select i1 %5, i32 2, i32 1
%11 = select i1 %9, i32 %10, i32 %6
%12 = fcmp oeq double %8, %2
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %11, %13
ret i32 %14
}