#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 /*<<< orphan*/ FILE;

/* Variables and functions */
double *calloc(int, int);
int /*<<< orphan*/ count_coefficient(double *, double *, double *, double *,
                                     double *, double *, double *, int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double,
                           int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *, double *,
                          double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ spline(double, double, double, double, double);
int main() {
  int M = 0;
  double *fmdottan;
  double *coords;
  double *V;
  double *dist;
  double *a, *b, *c, *d;
  double x;
  double A, B;
  double length = 0.0;
  int i, j;
  FILE *data;
  printf("Enter M = number of images - 1 \n");
  scanf("%d", &M);
  a = calloc(M, sizeof(double));
  b = calloc(M, sizeof(double));
  c = calloc(M, sizeof(double));
  d = calloc(M, sizeof(double));
  V = calloc((M + 1), sizeof(double));
  coords = calloc((M + 1), sizeof(double));
  fmdottan = calloc((M + 1), sizeof(double));
  dist = calloc(M + 1, sizeof(double));
  if ((data = fopen("neb_init.dat", "r")) == NULL) {
    printf("Incorrect input file name.");
    return 0;
  }
  for (j = 0; j < M + 1; j++) {
    fscanf(data, "%lf\t%lf\t%lf\t%lf\n", &coords[j], &V[j], &fmdottan[j],
           &dist[j]);
    length += dist[j];
    printf("%lf %lf %lf %lf\n", coords[j], V[j], fmdottan[j], dist[j]);
  }
  if ((fclose(data)) == 0) {
    printf("Data stored, input file closed.\n ");
  }
  count_coefficient(V, fmdottan, dist, a, b, c, d, M);
  if ((data = fopen("interpolation_result.dat", "w")) == NULL) {
    printf("Interpolation file could not be open.");
    return 0;
  }
  A = B = 0.0;
  for (i = 0; i < M; i++) {
    B += dist[i];
    printf("%13le\n", B);
    for (j = 0; j <= 1000; j++) {
      x = dist[i] * 1.0e-3 * j;
      fprintf(data, "%13lf\t%13le\n", (x + A) / length,
              spline(a[i], b[i], c[i], d[i], x));
    }
    A += dist[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xdc2(%rip),%rdi
lea    0xdc8(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    129e <main+0x10e>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1526 <main+0x396>
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1369 <main+0x1d9>
mov    -0x78(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x10(%rbp),%r8
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r8
mov    -0x28(%rbp),%r9
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r9
lea    0xd59(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
lea    0xd13(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12a5 <main+0x115>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
jne    138a <main+0x1fa>
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
mov    -0x48(%rbp),%r10
mov    -0x8(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   10b0 <count_coefficient@plt>
lea    0xcdd(%rip),%rdi
lea    0xcef(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    13f1 <main+0x261>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1526 <main+0x396>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    151f <main+0x38f>
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
lea    0xcaa(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x70(%rbp)
cmpl   $0x3e8,-0x70(%rbp)
jg     14fa <main+0x36a>
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  0xb9e(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x70(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x88(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x48(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
movsd  -0x50(%rbp),%xmm4
call   10a0 <spline@plt>
mov    -0x88(%rbp),%rdi
movsd  -0x80(%rbp),%xmm0
mov    %eax,%edx
lea    0xbf4(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1445 <main+0x2b5>
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1408 <main+0x278>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movl   $0x0,0xc(%rsp)
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
lea    0xe47(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x40(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%rbp
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x38(%rsp)
add    $0x1,%ebx
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x28(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x20(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,0x10(%rsp)
lea    0xdb0(%rip),%rdi
lea    0xdb6(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     131f <main+0x17f>
mov    %rax,%r14
mov    %r12,0x48(%rsp)
mov    %rbp,0x30(%rsp)
cmpl   $0x0,0xc(%rsp)
js     132b <main+0x18b>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %ebp,%ebp
mov    0x10(%rsp),%r12
mov    0x28(%rsp),%rbx
mov    0x20(%rsp),%r13
nopl   0x0(%rax,%rax,1)
lea    (%r15,%rbp,8),%rdx
lea    (%rbx,%rbp,8),%rcx
lea    0x0(,%rbp,8),%r8
add    %r13,%r8
lea    (%r12,%rbp,8),%r9
mov    %r14,%rdi
lea    0xd6c(%rip),%rsi
call   1060 <fscanf@plt>
movsd  (%r12,%rbp,8),%xmm3
movsd  0x18(%rsp),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%r15,%rbp,8),%xmm0
movsd  (%rbx,%rbp,8),%xmm1
movsd  0x0(%r13,%rbp,8),%xmm2
lea    0xd49(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
lea    0x1(%rbp),%rax
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rbp
mov    %rax,%rbp
jl     12b0 <main+0x110>
jmp    1335 <main+0x195>
lea    0xcfc(%rip),%rdi
jmp    14b7 <main+0x317>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    1350 <main+0x1b0>
lea    0xd16(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
mov    0x28(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
mov    0x48(%rsp),%rcx
mov    0x40(%rsp),%r8
mov    0x30(%rsp),%r9
push   %rax
push   0x40(%rsp)
call   10c0 <count_coefficient@plt>
add    $0x10,%rsp
lea    0xcf7(%rip),%rdi
lea    0xd09(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14b0 <main+0x310>
mov    %rax,0x58(%rsp)
cmpl   $0x0,0xc(%rsp)
jle    14be <main+0x31e>
xorpd  %xmm0,%xmm0
xor    %r15d,%r15d
xorpd  %xmm1,%xmm1
mov    0x30(%rsp),%r14
mov    0x38(%rsp),%rbp
mov    0x58(%rsp),%r13
nopl   0x0(%rax)
movsd  %xmm1,0x50(%rsp)
addsd  (%rbx,%r15,8),%xmm0
lea    0xce5(%rip),%rdi
movsd  %xmm0,0x60(%rsp)
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x3e9,%r12d
xorpd  %xmm1,%xmm1
mov    0x40(%rsp),%rbx
nop
movsd  %xmm1,0x28(%rsp)
mov    0x10(%rsp),%rax
movsd  (%rax,%r15,8),%xmm4
mulsd  0xbe7(%rip),%xmm4
mulsd  %xmm1,%xmm4
movsd  0x50(%rsp),%xmm0
addsd  %xmm4,%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x48(%rsp),%rax
movsd  (%rax,%r15,8),%xmm0
movsd  (%rbx,%r15,8),%xmm1
movsd  (%r14,%r15,8),%xmm2
movsd  0x0(%rbp,%r15,8),%xmm3
call   10b0 <spline@plt>
mov    %r13,%rdi
lea    0xc62(%rip),%rsi
movsd  0x20(%rsp),%xmm0
mov    %eax,%edx
call   1080 <fprintf@plt>
movsd  0x28(%rsp),%xmm1
addsd  0xb8d(%rip),%xmm1
add    $0xffffffff,%r12d
jne    1400 <main+0x260>
movsd  0x50(%rsp),%xmm1
mov    0x10(%rsp),%rbx
addsd  (%rbx,%r15,8),%xmm1
add    $0x1,%r15
movslq 0xc(%rsp),%rax
cmp    %rax,%r15
movsd  0x60(%rsp),%xmm0
jl     13d0 <main+0x230>
jmp    14be <main+0x31e>
lea    0xbe5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter M = number of images - 1 \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"neb_init.dat\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [27 x i8] c"Incorrect input file name.\00"
@.str.5 = [17 x i8] c"%lf\09%lf\09%lf\09%lf\0A\00"
@.str.6 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@.str.7 = [34 x i8] c"Data stored, input file closed.\0A \00"
@.str.8 = [25 x i8] c"interpolation_result.dat\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [38 x i8] c"Interpolation file could not be open.\00"
@.str.11 = [7 x i8] c"%13le\0A\00"
@.str.12 = [13 x i8] c"%13lf\09%13le\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double*
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store double 0.000000e+00, double* %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = call double* @calloc(i32 %20, i32 8)
store double* %21, double** %7
%22 = load i32, i32* %2
%23 = call double* @calloc(i32 %22, i32 8)
store double* %23, double** %8
%24 = load i32, i32* %2
%25 = call double* @calloc(i32 %24, i32 8)
store double* %25, double** %9
%26 = load i32, i32* %2
%27 = call double* @calloc(i32 %26, i32 8)
store double* %27, double** %10
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
%30 = call double* @calloc(i32 %29, i32 8)
store double* %30, double** %5
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
%33 = call double* @calloc(i32 %32, i32 8)
store double* %33, double** %4
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
%36 = call double* @calloc(i32 %35, i32 8)
store double* %36, double** %3
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
%39 = call double* @calloc(i32 %38, i32 8)
store double* %39, double** %6
%40 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %40, i32** %17
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %44
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %192
44: ; preds = %0
store i32 0, i32* %16
br label %45
45: ; preds = %97, %44
%46 = load i32, i32* %16
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
%49 = icmp slt i32 %46, %48
br i1 %49, label %50, label %100
50: ; preds = %45
%51 = load i32*, i32** %17
%52 = load double*, double** %4
%53 = load i32, i32* %16
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double*, double** %5
%57 = load i32, i32* %16
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double*, double** %3
%61 = load i32, i32* %16
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double*, double** %6
%65 = load i32, i32* %16
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = call i32 @fscanf(i32* %51, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double* %55, double* %59, double* %63, double* %67)
%69 = load double*, double** %6
%70 = load i32, i32* %16
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = load double, double* %14
%75 = fadd double %74, %73
store double %75, double* %14
%76 = load double*, double** %4
%77 = load i32, i32* %16
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = load double*, double** %5
%82 = load i32, i32* %16
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
%85 = load double, double* %84
%86 = load double*, double** %3
%87 = load i32, i32* %16
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
%90 = load double, double* %89
%91 = load double*, double** %6
%92 = load i32, i32* %16
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %80, double %85, double %90, double %95)
br label %97
97: ; preds = %50
%98 = load i32, i32* %16
%99 = add nsw i32 %98, 1
store i32 %99, i32* %16
br label %45
100: ; preds = %45
%101 = load i32*, i32** %17
%102 = call i64 @fclose(i32* %101)
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %100
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %106
106: ; preds = %104, %100
%107 = load double*, double** %5
%108 = load double*, double** %3
%109 = load double*, double** %6
%110 = load double*, double** %7
%111 = load double*, double** %8
%112 = load double*, double** %9
%113 = load double*, double** %10
%114 = load i32, i32* %2
%115 = call i32 @count_coefficient(double* %107, double* %108, double* %109, double* %110, double* %111, double* %112, double* %113, i32 %114)
%116 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %116, i32** %17
%117 = icmp eq i32* %116, null
br i1 %117, label %118, label %120
118: ; preds = %106
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %192
120: ; preds = %106
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %12
store i32 0, i32* %15
br label %121
121: ; preds = %188, %120
%122 = load i32, i32* %15
%123 = load i32, i32* %2
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %191
125: ; preds = %121
%126 = load double*, double** %6
%127 = load i32, i32* %15
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %126, i64 %128
%130 = load double, double* %129
%131 = load double, double* %13
%132 = fadd double %131, %130
store double %132, double* %13
%133 = load double, double* %13
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double %133)
store i32 0, i32* %16
br label %135
135: ; preds = %177, %125
%136 = load i32, i32* %16
%137 = icmp sle i32 %136, 1000
br i1 %137, label %138, label %180
138: ; preds = %135
%139 = load double*, double** %6
%140 = load i32, i32* %15
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds double, double* %139, i64 %141
%143 = load double, double* %142
%144 = fmul double %143, 1.000000e-03
%145 = load i32, i32* %16
%146 = sitofp i32 %145 to double
%147 = fmul double %144, %146
store double %147, double* %11
%148 = load i32*, i32** %17
%149 = load double, double* %11
%150 = load double, double* %12
%151 = fadd double %149, %150
%152 = load double, double* %14
%153 = fdiv double %151, %152
%154 = load double*, double** %7
%155 = load i32, i32* %15
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds double, double* %154, i64 %156
%158 = load double, double* %157
%159 = load double*, double** %8
%160 = load i32, i32* %15
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %159, i64 %161
%163 = load double, double* %162
%164 = load double*, double** %9
%165 = load i32, i32* %15
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double, double* %164, i64 %166
%168 = load double, double* %167
%169 = load double*, double** %10
%170 = load i32, i32* %15
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds double, double* %169, i64 %171
%173 = load double, double* %172
%174 = load double, double* %11
%175 = call i32 @spline(double %158, double %163, double %168, double %173, double %174)
%176 = call i32 @fprintf(i32* %148, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), double %153, i32 %175)
br label %177
177: ; preds = %138
%178 = load i32, i32* %16
%179 = add nsw i32 %178, 1
store i32 %179, i32* %16
br label %135
180: ; preds = %135
%181 = load double*, double** %6
%182 = load i32, i32* %15
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
%186 = load double, double* %12
%187 = fadd double %186, %185
store double %187, double* %12
br label %188
188: ; preds = %180
%189 = load i32, i32* %15
%190 = add nsw i32 %189, 1
store i32 %190, i32* %15
br label %121
191: ; preds = %121
store i32 0, i32* %1
br label %192
192: ; preds = %191, %118, %42
%193 = load i32, i32* %1
ret i32 %193
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"neb_init.dat\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [27 x i8] c"Incorrect input file name.\00"
@.str.5 = [17 x i8] c"%lf\09%lf\09%lf\09%lf\0A\00"
@.str.6 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@.str.7 = [34 x i8] c"Data stored, input file closed.\0A \00"
@.str.8 = [25 x i8] c"interpolation_result.dat\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [38 x i8] c"Interpolation file could not be open.\00"
@.str.11 = [7 x i8] c"%13le\0A\00"
@.str.12 = [13 x i8] c"%13lf\09%13le\0A\00"
@str = [32 x i8] c"Enter M = number of images - 1 \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call double* @calloc(i32 %5, i32 8)
%7 = call double* @calloc(i32 %5, i32 8)
%8 = call double* @calloc(i32 %5, i32 8)
%9 = call double* @calloc(i32 %5, i32 8)
%10 = add nsw i32 %5, 1
%11 = call double* @calloc(i32 %10, i32 8)
%12 = call double* @calloc(i32 %10, i32 8)
%13 = call double* @calloc(i32 %10, i32 8)
%14 = call double* @calloc(i32 %10, i32 8)
%15 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %87, label %17
17: ; preds = %0
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 0
br i1 %19, label %38, label %20
20: ; preds = %17, %20
%21 = phi i64 [ %34, %20 ], [ 0, %17 ]
%22 = phi double [ %29, %20 ], [ 0.000000e+00, %17 ]
%23 = getelementptr inbounds double, double* %12, i64 %21
%24 = getelementptr inbounds double, double* %11, i64 %21
%25 = getelementptr inbounds double, double* %13, i64 %21
%26 = getelementptr inbounds double, double* %14, i64 %21
%27 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double* %23, double* %24, double* %25, double* %26)
%28 = load double, double* %26
%29 = fadd double %22, %28
%30 = load double, double* %23
%31 = load double, double* %24
%32 = load double, double* %25
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %30, double %31, double %32, double %28)
%34 = add nuw nsw i64 %21, 1
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %21, %36
br i1 %37, label %20, label %38
38: ; preds = %20, %17
%39 = phi double [ 0.000000e+00, %17 ], [ %29, %20 ]
%40 = call i64 @fclose(i32* %15)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
%45 = load i32, i32* %1
%46 = call i32 @count_coefficient(double* %11, double* %13, double* %14, double* %6, double* %7, double* %8, double* %9, i32 %45)
%47 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %87, label %49
49: ; preds = %44
%50 = load i32, i32* %1
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %90
52: ; preds = %49, %80
%53 = phi i64 [ %83, %80 ], [ 0, %49 ]
%54 = phi double [ %58, %80 ], [ 0.000000e+00, %49 ]
%55 = phi double [ %82, %80 ], [ 0.000000e+00, %49 ]
%56 = getelementptr inbounds double, double* %14, i64 %53
%57 = load double, double* %56
%58 = fadd double %54, %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double %58)
%60 = getelementptr inbounds double, double* %6, i64 %53
%61 = getelementptr inbounds double, double* %7, i64 %53
%62 = getelementptr inbounds double, double* %8, i64 %53
%63 = getelementptr inbounds double, double* %9, i64 %53
br label %64
64: ; preds = %52, %64
%65 = phi i32 [ 0, %52 ], [ %78, %64 ]
%66 = load double, double* %56
%67 = fmul double %66, 1.000000e-03
%68 = sitofp i32 %65 to double
%69 = fmul double %67, %68
%70 = fadd double %55, %69
%71 = fdiv double %70, %39
%72 = load double, double* %60
%73 = load double, double* %61
%74 = load double, double* %62
%75 = load double, double* %63
%76 = call i32 @spline(double %72, double %73, double %74, double %75, double %69)
%77 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), double %71, i32 %76)
%78 = add nuw nsw i32 %65, 1
%79 = icmp eq i32 %78, 1001
br i1 %79, label %80, label %64
80: ; preds = %64
%81 = load double, double* %56
%82 = fadd double %55, %81
%83 = add nuw nsw i64 %53, 1
%84 = load i32, i32* %1
%85 = sext i32 %84 to i64
%86 = icmp slt i64 %83, %85
br i1 %86, label %52, label %90
87: ; preds = %44, %0
%88 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), %0 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), %44 ]
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %88)
br label %90
90: ; preds = %80, %87, %49
ret i32 0
}