#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 CSPL_Regression_TheilSen(double *, double *, int, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  double x[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  double y[10] = {0.86074211, 2.243673,  2.32922599, 3.5269751, 5.19649183,
                  4.55875795, 8.6822283, 7.86981641, 9.0570581, 7.766994};
  long i;
  double slope, intercept;
  double rsq;
  rsq = CSPL_Regression_TheilSen(x, y, 10, &slope, &intercept);
  printf("%10s\t%10s\n", "x", "y");
  for (i = 0; i < 10; i++) {
    printf("%10.2lf\t%10.2lf\n", x[i], y[i]);
  }
  printf("\n");
  printf("Slope: %lf, Intercept=%lf, R**2=%lf\n", slope, intercept, rsq);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
lea    0xeeb(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0xa,%edx
lea    -0xc0(%rbp),%rcx
lea    -0xc8(%rbp),%r8
call   1040 <CSPL_Regression_TheilSen@plt>
movsd  %xmm0,-0xd0(%rbp)
ff
lea    0xeff(%rip),%rdi
lea    0xf03(%rip),%rsi
lea    0xefe(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0xb8(%rbp)
cmpq   $0xa,-0xb8(%rbp)
0a
jge    1211 <main+0xe1>
mov    -0xb8(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
mov    -0xb8(%rbp),%rax
movsd  -0xb0(%rbp,%rax,8),%xmm1
ff ff
lea    0xebc(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0xb8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xb8(%rbp)
jmp    11c1 <main+0x91>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0xc0(%rbp),%xmm0
ff
movsd  -0xc8(%rbp),%xmm1
ff
movsd  -0xd0(%rbp),%xmm2
ff
lea    0xe82(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xc0,%rsp
movaps 0xf01(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xf09(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeed(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x70(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    $0xa,%edx
call   1050 <CSPL_Regression_TheilSen@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xeb9(%rip),%rdi
lea    0xebd(%rip),%rsi
lea    0xeb8(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x70(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x78(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x80(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x88(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x90(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x98(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xa0(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xa8(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xb0(%rsp),%xmm0
movsd  0x60(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xb8(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
lea    0xdac(%rip),%rdi
movsd  0x8(%rsp),%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%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 0x3FEB8B330997AE5D, double 0x4001F30AD46F587D, double 0x4002A2413C605885, double 0x400C373EB8A2735D, double 0x4014C935277F1FF1, double 0x40123C2B0B468520, double 0x40215D4D0719CFB5, double 0x401F7AB12729E582, double 0x40221D36B822F19D, double 0x401F1166E008E9B4]
@.str = [11 x i8] c"%10s\09%10s\0A\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [17 x i8] c"%10.2lf\09%10.2lf\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [37 x i8] c"Slope: %lf, Intercept=%lf, R**2=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x double]
%3 = alloca [10 x double]
%4 = alloca i64
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = bitcast [10 x double]* %2 to i8*
%9 = bitcast [10 x double]* %3 to i8*
%10 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%11 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%12 = call double @CSPL_Regression_TheilSen(double* %10, double* %11, i32 10, double* %5, double* %6)
store double %12, double* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %4
br label %14
14: ; preds = %25, %0
%15 = load i64, i64* %4
%16 = icmp slt i64 %15, 10
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i64, i64* %4
%19 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 %18
%20 = load double, double* %19
%21 = load i64, i64* %4
%22 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 %21
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %20, double %23)
br label %25
25: ; preds = %17
%26 = load i64, i64* %4
%27 = add nsw i64 %26, 1
store i64 %27, i64* %4
br label %14
28: ; preds = %14
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = load double, double* %5
%31 = load double, double* %6
%32 = load double, double* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %30, double %31, double %32)
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 0x3FEB8B330997AE5D, double 0x4001F30AD46F587D, double 0x4002A2413C605885, double 0x400C373EB8A2735D, double 0x4014C935277F1FF1, double 0x40123C2B0B468520, double 0x40215D4D0719CFB5, double 0x401F7AB12729E582, double 0x40221D36B822F19D, double 0x401F1166E008E9B4]
@.str = [11 x i8] c"%10s\09%10s\0A\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [17 x i8] c"%10.2lf\09%10.2lf\0A\00"
@.str.5 = [37 x i8] c"Slope: %lf, Intercept=%lf, R**2=%lf\0A\00"
define i32 @main() {
%1 = alloca [10 x double]
%2 = alloca [10 x double]
%3 = alloca double
%4 = alloca double
%5 = bitcast [10 x double]* %1 to i8*
%6 = bitcast [10 x double]* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
%10 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%11 = call double @CSPL_Regression_TheilSen(double* %9, double* %10, i32 10, double* %3, double* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = load double, double* %9
%14 = load double, double* %10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %13, double %14)
%16 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 1
%17 = load double, double* %16
%18 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 1
%19 = load double, double* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %17, double %19)
%21 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 2
%22 = load double, double* %21
%23 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 2
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %22, double %24)
%26 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 3
%27 = load double, double* %26
%28 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 3
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %27, double %29)
%31 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 4
%32 = load double, double* %31
%33 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 4
%34 = load double, double* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %32, double %34)
%36 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 5
%37 = load double, double* %36
%38 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 5
%39 = load double, double* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %37, double %39)
%41 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 6
%42 = load double, double* %41
%43 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 6
%44 = load double, double* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %42, double %44)
%46 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 7
%47 = load double, double* %46
%48 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 7
%49 = load double, double* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %47, double %49)
%51 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 8
%52 = load double, double* %51
%53 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 8
%54 = load double, double* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %52, double %54)
%56 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 9
%57 = load double, double* %56
%58 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 9
%59 = load double, double* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %57, double %59)
%61 = call i32 @putchar(i32 10)
%62 = load double, double* %3
%63 = load double, double* %4
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %62, double %63, double %11)
ret i32 0
}