#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*/ array_interpolate(double *, int, int, int /*<<< orphan*/,
                                     double, int *, double *, int, char *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double, double);
double sin(double);
int main() {
  int nLines = 21;
  int nColns = 2;
  double a = -3.14;
  double b = 3.14;
  double xi, yi;
  double *array = (double *)malloc(sizeof(double) * nLines * nColns);
  double *array_result = (double *)malloc(sizeof(double) * 2);
  for (int i = 0; i < nLines; i++) {
    xi = a + i * (b - a) / (nLines - 1.);
    yi = sin(xi);
    *(array + i * nColns + 0) = xi;
    *(array + i * nColns + 1) = yi;
  }
  xi = a;
  int last_index;
  for (int i = 0; i < 100; i++) {
    xi = a + i * (b - a) / (100. - 1.0);
    array_interpolate(array, nColns, nLines, 0, xi, &last_index, array_result,
                      2, "");
    printf("%10.5f\t%10.5f\n", *(array_result + 0), *(array_result + 1));
  };
  free(array);
  free(array_result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x15,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1247 <main+0xf7>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x44(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xe30(%rip),%xmm3
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,0x8(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b7 <main+0x67>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x64,-0x4c(%rbp)
jge    12eb <main+0x19b>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x4c(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd8e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%r9
xor    %ecx,%ecx
lea    -0x48(%rbp),%r8
lea    0xd7f(%rip),%rax
movl   $0x2,(%rsp)
mov    %rax,0x8(%rsp)
call   1070 <array_interpolate@plt>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  0x8(%rax),%xmm1
lea    0xd48(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1258 <main+0x108>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x150,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %r14,%rbx
add    $0x18,%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0xe68(%rip),%xmm2
movsd  0xe70(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  %xmm2,%xmm0
divsd  0xe54(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,-0x18(%rbx)
movsd  %xmm0,-0x10(%rbx)
mov    %r15,%rax
or     $0x1,%rax
cmp    $0x15,%rax
je     1232 <main+0xe2>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe11(%rip),%xmm0
mulsd  %xmm0,%xmm1
divsd  0xe0d(%rip),%xmm1
movsd  0xe0d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,-0x8(%rbx)
movsd  %xmm0,(%rbx)
add    $0x2,%r15
add    $0x20,%rbx
jmp    1190 <main+0x40>
xorpd  %xmm0,%xmm0
mov    $0x64,%ebx
lea    0xdf4(%rip),%rbp
lea    0x14(%rsp),%r15
lea    0xdda(%rip),%r12
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd9c(%rip),%xmm0
divsd  0xdac(%rip),%xmm0
addsd  0xd9c(%rip),%xmm0
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x15,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%r9
push   %rbp
push   $0x2
call   1070 <array_interpolate@plt>
add    $0x10,%rsp
movsd  0x0(%r13),%xmm0
movsd  0x8(%r13),%xmm1
mov    %r12,%rdi
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xd69(%rip),%xmm0
add    $0xffffffff,%ebx
jne    1250 <main+0x100>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"%10.5f\09%10.5f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 21, i32* %2
store i32 2, i32* %3
store double -3.140000e+00, double* %4
store double 3.140000e+00, double* %5
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = mul i64 8, %14
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = mul i64 %15, %17
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %8
%22 = call i64 @malloc(i32 16)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %9
store i32 0, i32* %10
br label %24
24: ; preds = %59, %0
%25 = load i32, i32* %10
%26 = load i32, i32* %2
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %62
28: ; preds = %24
%29 = load double, double* %4
%30 = load i32, i32* %10
%31 = sitofp i32 %30 to double
%32 = load double, double* %5
%33 = load double, double* %4
%34 = fsub double %32, %33
%35 = fmul double %31, %34
%36 = load i32, i32* %2
%37 = sitofp i32 %36 to double
%38 = fsub double %37, 1.000000e+00
%39 = fdiv double %35, %38
%40 = fadd double %29, %39
store double %40, double* %6
%41 = load double, double* %6
%42 = call double @sin(double %41)
store double %42, double* %7
%43 = load double, double* %6
%44 = load double*, double** %8
%45 = load i32, i32* %10
%46 = load i32, i32* %3
%47 = mul nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %44, i64 %48
%50 = getelementptr inbounds double, double* %49, i64 0
store double %43, double* %50
%51 = load double, double* %7
%52 = load double*, double** %8
%53 = load i32, i32* %10
%54 = load i32, i32* %3
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %52, i64 %56
%58 = getelementptr inbounds double, double* %57, i64 1
store double %51, double* %58
br label %59
59: ; preds = %28
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %24
62: ; preds = %24
%63 = load double, double* %4
store double %63, double* %6
store i32 0, i32* %12
br label %64
64: ; preds = %90, %62
%65 = load i32, i32* %12
%66 = icmp slt i32 %65, 100
br i1 %66, label %67, label %93
67: ; preds = %64
%68 = load double, double* %4
%69 = load i32, i32* %12
%70 = sitofp i32 %69 to double
%71 = load double, double* %5
%72 = load double, double* %4
%73 = fsub double %71, %72
%74 = fmul double %70, %73
%75 = fdiv double %74, 9.900000e+01
%76 = fadd double %68, %75
store double %76, double* %6
%77 = load double*, double** %8
%78 = load i32, i32* %3
%79 = load i32, i32* %2
%80 = load double, double* %6
%81 = load double*, double** %9
%82 = call i32 @array_interpolate(double* %77, i32 %78, i32 %79, i32 0, double %80, i32* %11, double* %81, i32 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%83 = load double*, double** %9
%84 = getelementptr inbounds double, double* %83, i64 0
%85 = load double, double* %84
%86 = load double*, double** %9
%87 = getelementptr inbounds double, double* %86, i64 1
%88 = load double, double* %87
%89 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %85, double %88)
br label %90
90: ; preds = %67
%91 = load i32, i32* %12
%92 = add nsw i32 %91, 1
store i32 %92, i32* %12
br label %64
93: ; preds = %64
%94 = load double*, double** %8
%95 = call i32 @free(double* %94)
%96 = load double*, double** %9
%97 = call i32 @free(double* %96)
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"%10.5f\09%10.5f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i64 @malloc(i32 336)
%3 = inttoptr i64 %2 to double*
%4 = tail call i64 @malloc(i32 16)
br label %9
5: ; preds = %9
%6 = inttoptr i64 %4 to double*
%7 = bitcast i32* %1 to i8*
%8 = getelementptr inbounds double, double* %6, i64 1
br label %36
9: ; preds = %22, %0
%10 = phi i64 [ 0, %0 ], [ %32, %22 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 6.280000e+00
%14 = fdiv double %13, 2.000000e+01
%15 = fadd double %14, -3.140000e+00
%16 = tail call double @sin(double %15)
%17 = shl nuw nsw i64 %10, 1
%18 = getelementptr inbounds double, double* %3, i64 %17
store double %15, double* %18
%19 = getelementptr inbounds double, double* %18, i64 1
store double %16, double* %19
%20 = or i64 %10, 1
%21 = icmp eq i64 %20, 21
br i1 %21, label %5, label %22
22: ; preds = %9
%23 = trunc i64 %20 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 6.280000e+00
%26 = fdiv double %25, 2.000000e+01
%27 = fadd double %26, -3.140000e+00
%28 = tail call double @sin(double %27)
%29 = shl nuw nsw i64 %20, 1
%30 = getelementptr inbounds double, double* %3, i64 %29
store double %27, double* %30
%31 = getelementptr inbounds double, double* %30, i64 1
store double %28, double* %31
%32 = add nuw nsw i64 %10, 2
br label %9
33: ; preds = %36
%34 = call i32 @free(double* %3)
%35 = call i32 @free(double* %6)
ret i32 0
36: ; preds = %5, %36
%37 = phi i32 [ 0, %5 ], [ %46, %36 ]
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 6.280000e+00
%40 = fdiv double %39, 9.900000e+01
%41 = fadd double %40, -3.140000e+00
%42 = call i32 @array_interpolate(double* %3, i32 2, i32 21, i32 0, double %41, i32* %1, double* %6, i32 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%43 = load double, double* %6
%44 = load double, double* %8
%45 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %43, double %44)
%46 = add nuw nsw i32 %37, 1
%47 = icmp eq i32 %46, 100
br i1 %47, label %33, label %36
}