#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ least_square(int, int, double *, double *, double *);
int /*<<< orphan*/ printf(char *, int, double);
int main(int argc, char *argv[]) {
  double x[10] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
  double y[10] = {24.5, 20.7, 18.1, 16.4, 15.0, 14.2, 13.6, 13.0, 12.4, 12.1};
  double a[10];
  uint32_t i = 0;
  least_square(10, 3, x, y, a);
  for (i = 0; i <= 3; i++)
    printf("a[%d] = %10.5lf\n", i, a[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
lea    0xee4(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x104(%rbp)
lea    -0x60(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
lea    -0x100(%rbp),%r8
mov    $0xa,%edi
mov    $0x3,%esi
call   1050 <least_square@plt>
movl   $0x0,-0x104(%rbp)
cmpl   $0x3,-0x104(%rbp)
jg     11ee <main+0xbe>
mov    -0x104(%rbp),%esi
movslq -0x104(%rbp),%rax
movsd  -0x100(%rbp,%rax,8),%xmm0
ff ff
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11ab <main+0x7b>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xf0,%rsp
movaps 0xf11(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xef2(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf1f(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf03(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%rdx
mov    %rsp,%rcx
lea    0xa0(%rsp),%r8
mov    $0xa,%edi
mov    $0x3,%esi
call   1040 <least_square@plt>
movsd  0xa0(%rsp),%xmm0
lea    0xecc(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
movsd  0xa8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movsd  0xb0(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
movsd  0xb8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.x = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@__const.main.y = [10 x double] [double 2.450000e+01, double 2.070000e+01, double 1.810000e+01, double 1.640000e+01, double 1.500000e+01, double 1.420000e+01, double 1.360000e+01, double 1.300000e+01, double 1.240000e+01, double 1.210000e+01]
@.str = [17 x i8] c"a[%d] = %10.5lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x double]
%7 = alloca [10 x double]
%8 = alloca [10 x double]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [10 x double]* %6 to i8*
%11 = bitcast [10 x double]* %7 to i8*
store i32 0, i32* %9
%12 = getelementptr inbounds [10 x double], [10 x double]* %6, i64 0, i64 0
%13 = getelementptr inbounds [10 x double], [10 x double]* %7, i64 0, i64 0
%14 = getelementptr inbounds [10 x double], [10 x double]* %8, i64 0, i64 0
%15 = call i32 @least_square(i32 10, i32 3, double* %12, double* %13, double* %14)
store i32 0, i32* %9
br label %16
16: ; preds = %26, %2
%17 = load i32, i32* %9
%18 = icmp sle i32 %17, 3
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i32, i32* %9
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x double], [10 x double]* %8, i64 0, i64 %22
%24 = load double, double* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %20, double %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %16
29: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@__const.main.y = [10 x double] [double 2.450000e+01, double 2.070000e+01, double 1.810000e+01, double 1.640000e+01, double 1.500000e+01, double 1.420000e+01, double 1.360000e+01, double 1.300000e+01, double 1.240000e+01, double 1.210000e+01]
@.str = [17 x i8] c"a[%d] = %10.5lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x double]
%4 = alloca [10 x double]
%5 = alloca [10 x double]
%6 = bitcast [10 x double]* %3 to i8*
%7 = bitcast [10 x double]* %4 to i8*
%8 = bitcast [10 x double]* %5 to i8*
%9 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%10 = getelementptr inbounds [10 x double], [10 x double]* %4, i64 0, i64 0
%11 = getelementptr inbounds [10 x double], [10 x double]* %5, i64 0, i64 0
%12 = call i32 @least_square(i32 10, i32 3, double* %9, double* %10, double* %11)
%13 = load double, double* %11
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 0, double %13)
%15 = getelementptr inbounds [10 x double], [10 x double]* %5, i64 0, i64 1
%16 = load double, double* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 1, double %16)
%18 = getelementptr inbounds [10 x double], [10 x double]* %5, i64 0, i64 2
%19 = load double, double* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 2, double %19)
%21 = getelementptr inbounds [10 x double], [10 x double]* %5, i64 0, i64 3
%22 = load double, double* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 3, double %22)
ret i32 0
}