#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 *, long);
long findSumOfSquare_efficient(int maxValue) {
  double bigValue = maxValue;
  long int totalSum = (bigValue * bigValue * bigValue / 3) +
                      (bigValue * bigValue / 2) + (bigValue / 6);
  printf("Sum of Squares (1^2 + 2^2 + 3^2) = %lu\n", totalSum);
  return totalSum;
}


x86 assembly (clang, -O0):
<findSumOfSquare_efficient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xed4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xeb6(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe99(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findSumOfSquare_efficient>:
push   %rbx
cvtsi2sd %edi,%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm0,%xmm2
mulsd  0xed3(%rip),%xmm1
unpcklpd %xmm2,%xmm0
divpd  0xed7(%rip),%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%rbx
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Sum of Squares (1^2 + 2^2 + 3^2) = %lu\0A\00"
define i64 @findSumOfSquare_efficient(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sitofp i32 %5 to double
store double %6, double* %3
%7 = load double, double* %3
%8 = load double, double* %3
%9 = fmul double %7, %8
%10 = load double, double* %3
%11 = fmul double %9, %10
%12 = fdiv double %11, 3.000000e+00
%13 = load double, double* %3
%14 = load double, double* %3
%15 = fmul double %13, %14
%16 = fdiv double %15, 2.000000e+00
%17 = fadd double %12, %16
%18 = load double, double* %3
%19 = fdiv double %18, 6.000000e+00
%20 = fadd double %17, %19
%21 = fptosi double %20 to i64
store i64 %21, i64* %4
%22 = load i64, i64* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %22)
%24 = load i64, i64* %4
ret i64 %24
}

LLVM IR (-O2):
@.str = [40 x i8] c"Sum of Squares (1^2 + 2^2 + 3^2) = %lu\0A\00"
define i64 @findSumOfSquare_efficient(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fmul double %2, %2
%4 = fmul double %3, %2
%5 = fmul double %3, 5.000000e-01
%6 = insertelement <2 x double> poison, double %2, i64 0
%7 = insertelement <2 x double> %6, double %4, i64 1
%8 = fdiv <2 x double> %7, <double 6.000000e+00, double 3.000000e+00>
%9 = extractelement <2 x double> %8, i64 1
%10 = fadd double %5, %9
%11 = extractelement <2 x double> %8, i64 0
%12 = fadd double %11, %10
%13 = fptosi double %12 to i64
%14 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %13)
ret i64 %13
}