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

/* Variables and functions */
double calculate_cost(double **, double *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reset_coeff(double *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, double *);
char *strtok(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ train(double **, double *, int, double);
int main() {
  double data[506][14] = {0.0};
  double coeff[14] = {0.0};
  double alpha = 0.000001;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  char *token = NULL;
  char **tokens;
  int count = 0;
  int i, j, k;
  int num_samples;
  int upper = 506;
  int lower = 0;
  srand(time(NULL));
  FILE *f = fopen("../data/data.csv", "r");
  if (f == NULL) {
    printf("Failed to read file!\nExiting...\n");
    return -1;
  }
  while ((read = getline(&line, &len, f)) != -1) {
    count++;
    if (0 == 1) {
      printf("Retrieved line of length %zu Count : %d:\n", read, count);
      printf("%s", line);
    }
    token = strtok(line, ",");
    sscanf(token, "%lf", &data[count - 1][0]);
    for (i = 1; i < 14; i++) {
      token = strtok(NULL, ",");
      sscanf(token, "%lf", &data[count - 1][i]);
    }
  }
  fclose(f);
  if (0 == 1) {
    printf("Data Matrix: \n");
    for (i = 0; i < 506; i++) {
      for (j = 0; j < 14; j++)
        printf("%lf  ", data[i][j]);
      printf("\n");
    }
  }
  printf("Calculating the error tolerance by sampling and averaging 10 "
         "different samples...\n\n");
  double threshold_sum = 0.0;
  double err_threshold;
  for (i = 1; i <= 10; i++) {
    train(data, coeff, i * (506 / 10), alpha);
    threshold_sum = threshold_sum + calculate_cost(data, coeff);
    reset_coeff(coeff);
  }
  err_threshold = threshold_sum / 10.0;
  printf("Error tolerance : %f \n\n", err_threshold);
  printf("Finding a point near local minimum by using binary search...\n\n");
  double temp_cost;
  int secure_loop = 0;
  while (lower + 2 < upper) {
    if (secure_loop > 20) {
      break;
      printf("It did nit converge! Secure loop parameter caused to break the "
             "loop...\n");
    }
    secure_loop++;
    temp_cost = 0.0;
    num_samples = (lower + upper) / 2;
    for (j = 0; j < 5; j++) {
      train(data, coeff, num_samples, alpha);
      temp_cost = temp_cost + calculate_cost(data, coeff);
      reset_coeff(coeff);
    }
    temp_cost = temp_cost / 5.0;
    printf("Log: For %d number of random samples, the cost is : %f\n",
           num_samples, temp_cost);
    if (temp_cost > err_threshold) {
      lower = num_samples;
    } else {
      upper = num_samples;
    }
  }
  printf("\nFinding the minimum point near %d number of samples...\n\n",
         num_samples);
  double min = err_threshold * 10.0;
  int min_index = num_samples;
  for (i = (num_samples - (506 / 50)); i <= (num_samples + (506 / 50)); i++) {
    temp_cost = 0.0;
    for (j = 0; j < 5; j++) {
      train(data, coeff, i, alpha);
      temp_cost = temp_cost + calculate_cost(data, coeff);
      reset_coeff(coeff);
    }
    temp_cost = temp_cost / 5.0;
    printf("Log: For %d number of random samples, the cost is %f\n", i,
           temp_cost);
    if (temp_cost < min) {
      min = temp_cost;
      min_index = i;
    }
  }
  printf("\nMinimum cost is reached by using %d number of samples!\n\n",
         min_index);
  printf("Exiting...\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xde80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xdd70(%rbp),%rdi
xor    %esi,%esi
mov    $0xdd60,%edx
call   1050 <memset@plt>
lea    -0xdde0(%rbp),%rdi
xor    %esi,%esi
mov    $0x70,%edx
call   1050 <memset@plt>
movsd  0xe00(%rip),%xmm0
movsd  %xmm0,-0xdde8(%rbp)
ff
movq   $0x0,-0xddf0(%rbp)
movq   $0x0,-0xddf8(%rbp)
movq   $0x0,-0xde08(%rbp)
movl   $0x0,-0xde14(%rbp)
movl   $0x1fa,-0xde28(%rbp)
movl   $0x0,-0xde2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xdba(%rip),%rdi
lea    0xdc4(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0xde38(%rbp)
cmpq   $0x0,-0xde38(%rbp)
jne    1299 <main+0xd9>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    17a0 <main+0x5e0>
jmp    129e <main+0xde>
mov    -0xde38(%rbp),%rdx
lea    -0xddf0(%rbp),%rdi
lea    -0xddf8(%rbp),%rsi
call   10e0 <getline@plt>
mov    %eax,-0xddfc(%rbp)
cmp    $0xffffffff,%eax
je     139d <main+0x1dd>
mov    -0xde14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde14(%rbp)
mov    -0xddf0(%rbp),%rdi
lea    0xd68(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xde08(%rbp)
mov    -0xde08(%rbp),%rdi
mov    -0xde14(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0xdd70(%rbp),%rdx
imul   $0x70,%rax,%rax
add    %rax,%rdx
lea    0xd37(%rip),%rsi
call   10a0 <sscanf@plt>
movl   $0x1,-0xde18(%rbp)
cmpl   $0xe,-0xde18(%rbp)
jge    1398 <main+0x1d8>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd0e(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xde08(%rbp)
mov    -0xde08(%rbp),%rdi
mov    -0xde14(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0xdd70(%rbp),%rdx
imul   $0x70,%rax,%rax
add    %rax,%rdx
movslq -0xde18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xccf(%rip),%rsi
call   10a0 <sscanf@plt>
mov    -0xde18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde18(%rbp)
jmp    1326 <main+0x166>
jmp    129e <main+0xde>
mov    -0xde38(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xde40(%rbp)
ff
movl   $0x1,-0xde18(%rbp)
cmpl   $0xa,-0xde18(%rbp)
jg     1455 <main+0x295>
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
imul   $0x32,-0xde18(%rbp),%edx
movsd  -0xdde8(%rbp),%xmm0
ff
call   1080 <train@plt>
movsd  -0xde40(%rbp),%xmm0
ff
movsd  %xmm0,-0xde70(%rbp)
ff
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
call   1090 <calculate_cost@plt>
movaps %xmm0,%xmm1
movsd  -0xde70(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xde40(%rbp)
ff
lea    -0xdde0(%rbp),%rdi
call   10b0 <reset_coeff@plt>
mov    -0xde18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde18(%rbp)
jmp    13cc <main+0x20c>
movsd  -0xde40(%rbp),%xmm0
ff
movsd  0xba3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xde48(%rbp)
ff
movsd  -0xde48(%rbp),%xmm0
ff
lea    0xc26(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xde54(%rbp)
mov    -0xde2c(%rbp),%eax
add    $0x2,%eax
cmp    -0xde28(%rbp),%eax
jge    15fc <main+0x43c>
cmpl   $0x14,-0xde54(%rbp)
jle    14c6 <main+0x306>
jmp    15fc <main+0x43c>
mov    -0xde54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde54(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
mov    -0xde2c(%rbp),%eax
add    -0xde28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xde24(%rbp)
movl   $0x0,-0xde1c(%rbp)
cmpl   $0x5,-0xde1c(%rbp)
jge    158c <main+0x3cc>
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
mov    -0xde24(%rbp),%edx
movsd  -0xdde8(%rbp),%xmm0
ff
call   1080 <train@plt>
movsd  -0xde50(%rbp),%xmm0
ff
movsd  %xmm0,-0xde78(%rbp)
ff
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
call   1090 <calculate_cost@plt>
movaps %xmm0,%xmm1
movsd  -0xde78(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
lea    -0xdde0(%rbp),%rdi
call   10b0 <reset_coeff@plt>
mov    -0xde1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde1c(%rbp)
jmp    1504 <main+0x344>
movsd  -0xde50(%rbp),%xmm0
ff
movsd  0xa74(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
mov    -0xde24(%rbp),%esi
movsd  -0xde50(%rbp),%xmm0
ff
lea    0xb40(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0xde50(%rbp),%xmm0
ff
ucomisd -0xde48(%rbp),%xmm0
ff
jbe    15eb <main+0x42b>
mov    -0xde24(%rbp),%eax
mov    %eax,-0xde2c(%rbp)
jmp    15f7 <main+0x437>
mov    -0xde24(%rbp),%eax
mov    %eax,-0xde28(%rbp)
jmp    149f <main+0x2df>
mov    -0xde24(%rbp),%esi
lea    0xb2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0x9f0(%rip),%xmm0
mulsd  -0xde48(%rbp),%xmm0
ff
movsd  %xmm0,-0xde60(%rbp)
ff
mov    -0xde24(%rbp),%eax
mov    %eax,-0xde64(%rbp)
mov    -0xde24(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0xde18(%rbp)
mov    -0xde18(%rbp),%eax
mov    -0xde24(%rbp),%ecx
add    $0xa,%ecx
cmp    %ecx,%eax
jg     177e <main+0x5be>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
movl   $0x0,-0xde1c(%rbp)
cmpl   $0x5,-0xde1c(%rbp)
jge    16f7 <main+0x537>
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
mov    -0xde18(%rbp),%edx
movsd  -0xdde8(%rbp),%xmm0
ff
call   1080 <train@plt>
movsd  -0xde50(%rbp),%xmm0
ff
movsd  %xmm0,-0xde80(%rbp)
ff
lea    -0xdd70(%rbp),%rdi
lea    -0xdde0(%rbp),%rsi
call   1090 <calculate_cost@plt>
movaps %xmm0,%xmm1
movsd  -0xde80(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
lea    -0xdde0(%rbp),%rdi
call   10b0 <reset_coeff@plt>
mov    -0xde1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde1c(%rbp)
jmp    166f <main+0x4af>
movsd  -0xde50(%rbp),%xmm0
ff
movsd  0x909(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xde50(%rbp)
ff
mov    -0xde18(%rbp),%esi
movsd  -0xde50(%rbp),%xmm0
ff
lea    0xa47(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0xde50(%rbp),%xmm1
ff
movsd  -0xde60(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    1765 <main+0x5a5>
movsd  -0xde50(%rbp),%xmm0
ff
movsd  %xmm0,-0xde60(%rbp)
ff
mov    -0xde18(%rbp),%eax
mov    %eax,-0xde64(%rbp)
jmp    176a <main+0x5aa>
mov    -0xde18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xde18(%rbp)
jmp    1643 <main+0x483>
mov    -0xde64(%rbp),%esi
lea    0xa1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x8a7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xde80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xddf8,%rsp
lea    0x90(%rsp),%rbx
mov    $0xdd60,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x80(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0xdd0(%rip),%rdi
lea    0xdda(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1993 <main+0x7c3>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    %rax,%rdx
call   10f0 <getline@plt>
cmp    $0xffffffff,%eax
je     141b <main+0x24b>
lea    0xda9(%rip),%r15
lea    0xda4(%rip),%r12
lea    0x10(%rsp),%r13
lea    0x18(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x8(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x10(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x18(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x20(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x28(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x30(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x38(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x40(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x48(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x50(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x58(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x60(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10e0 <strtok@plt>
lea    0x68(%rbx),%rdx
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <sscanf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10f0 <getline@plt>
add    $0x70,%rbx
cmp    $0xffffffff,%eax
jne    12a0 <main+0xd0>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xd09(%rip),%rdi
call   1030 <puts@plt>
lea    0x90(%rsp),%r14
lea    0x20(%rsp),%r15
movsd  0xbbc(%rip),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x32,%edx
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x64,%edx
movsd  0xb79(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x96,%edx
movsd  0xb44(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xc8,%edx
movsd  0xb0f(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xfa,%edx
movsd  0xada(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x12c,%edx
movsd  0xaa5(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x15e,%edx
movsd  0xa70(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x190,%edx
movsd  0xa3b(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1c2,%edx
movsd  0xa06(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1f4,%edx
movsd  0x9d1(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
movsd  0x8(%rsp),%xmm0
divsd  0x9a8(%rip),%xmm0
lea    0x9d2(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xb0b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1fa,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
lea    (%r12,%r13,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
movsd  0x953(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  0x953(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
movsd  0x91e(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
movsd  0x8ec(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
movsd  0x8ba(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
movsd  0x888(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   10c0 <reset_coeff@plt>
movsd  (%rsp),%xmm0
divsd  0x869(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0x89e(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
mov    %ebx,%eax
ja     17d1 <main+0x601>
mov    %ebx,%r13d
mov    %r12d,%eax
lea    0x2(%rax),%ecx
cmp    %r13d,%ecx
jge    17ea <main+0x61a>
lea    0x1(%rbp),%ecx
mov    %eax,%r12d
cmp    $0x14,%ebp
mov    %ecx,%ebp
jb     1690 <main+0x4c0>
lea    0x898(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0x800(%rip),%xmm0
mov    $0xfffffff6,%r12d
lea    0x90(%rsp),%r14
lea    0x20(%rsp),%r13
mov    %ebx,%r15d
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
lea    (%rbx,%r12,1),%ebp
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x7c6(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <calculate_cost@plt>
addsd  0x7c6(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x791(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x75f(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x72d(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13,%rdi
call   10c0 <reset_coeff@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x6fb(%rip),%xmm0
call   1090 <train@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10a0 <calculate_cost@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r13,%rdi
call   10c0 <reset_coeff@plt>
movsd  (%rsp),%xmm0
divsd  0x6dc(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0x783(%rip),%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
cmova  %ebp,%r15d
minsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x1,%r12d
cmp    $0xb,%r12d
jne    1820 <main+0x650>
lea    0x780(%rip),%rdi
xor    %ebx,%ebx
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x84d(%rip),%rdi
call   1030 <puts@plt>
jmp    19a4 <main+0x7d4>
lea    0x82a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0xddf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"../data/data.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"Failed to read file!\0AExiting...\0A\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [84 x i8] c"Calculating the error tolerance by sampling and averaging 10 different samples...\0A\0A\00"
@.str.6 = [24 x i8] c"Error tolerance : %f \0A\0A\00"
@.str.7 = [63 x i8] c"Finding a point near local minimum by using binary search...\0A\0A\00"
@.str.8 = [56 x i8] c"Log: For %d number of random samples, the cost is : %f\0A\00"
@.str.9 = [58 x i8] c"\0AFinding the minimum point near %d number of samples...\0A\0A\00"
@.str.10 = [54 x i8] c"Log: For %d number of random samples, the cost is %f\0A\00"
@.str.11 = [58 x i8] c"\0AMinimum cost is reached by using %d number of samples!\0A\0A\00"
@.str.12 = [12 x i8] c"Exiting...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [506 x [14 x double]]
%3 = alloca [14 x double]
%4 = alloca double
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca double
%23 = alloca i32
store i32 0, i32* %1
%24 = bitcast [506 x [14 x double]]* %2 to i8*
%25 = bitcast [14 x double]* %3 to i8*
store double 0x3EB0C6F7A0B5ED8D, double* %4
store i8* null, i8** %5
store i64 0, i64* %6
store i8* null, i8** %8
store i32 0, i32* %10
store i32 506, i32* %15
store i32 0, i32* %16
%26 = call i32 @time(i32* null)
%27 = call i32 @srand(i32 %26)
%28 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %17
%29 = load i32*, i32** %17
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %206
33: ; preds = %0
br label %34
34: ; preds = %67, %33
%35 = load i32*, i32** %17
%36 = call i32 @getline(i8** %5, i64* %6, i32* %35)
store i32 %36, i32* %7
%37 = icmp ne i32 %36, -1
br i1 %37, label %38, label %68
38: ; preds = %34
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
%41 = load i8*, i8** %5
%42 = call i8* @strtok(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %42, i8** %8
%43 = load i8*, i8** %8
%44 = load i32, i32* %10
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 %46
%48 = getelementptr inbounds [14 x double], [14 x double]* %47, i64 0, i64 0
%49 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %48)
store i32 1, i32* %11
br label %50
50: ; preds = %64, %38
%51 = load i32, i32* %11
%52 = icmp slt i32 %51, 14
br i1 %52, label %53, label %67
53: ; preds = %50
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %54, i8** %8
%55 = load i8*, i8** %8
%56 = load i32, i32* %10
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 %58
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [14 x double], [14 x double]* %59, i64 0, i64 %61
%63 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %62)
br label %64
64: ; preds = %53
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
br label %50
67: ; preds = %50
br label %34
68: ; preds = %34
%69 = load i32*, i32** %17
%70 = call i32 @fclose(i32* %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.5, i64 0, i64 0))
store double 0.000000e+00, double* %18
store i32 1, i32* %11
br label %72
72: ; preds = %91, %68
%73 = load i32, i32* %11
%74 = icmp sle i32 %73, 10
br i1 %74, label %75, label %94
75: ; preds = %72
%76 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%77 = bitcast [14 x double]* %76 to double**
%78 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%79 = load i32, i32* %11
%80 = mul nsw i32 %79, 50
%81 = load double, double* %4
%82 = call i32 @train(double** %77, double* %78, i32 %80, double %81)
%83 = load double, double* %18
%84 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%85 = bitcast [14 x double]* %84 to double**
%86 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%87 = call double @calculate_cost(double** %85, double* %86)
%88 = fadd double %83, %87
store double %88, double* %18
%89 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%90 = call i32 @reset_coeff(double* %89)
br label %91
91: ; preds = %75
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
store i32 %93, i32* %11
br label %72
94: ; preds = %72
%95 = load double, double* %18
%96 = fdiv double %95, 1.000000e+01
store double %96, double* %19
%97 = load double, double* %19
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %21
br label %100
100: ; preds = %150, %94
%101 = load i32, i32* %16
%102 = add nsw i32 %101, 2
%103 = load i32, i32* %15
%104 = icmp slt i32 %102, %103
br i1 %104, label %105, label %151
105: ; preds = %100
%106 = load i32, i32* %21
%107 = icmp sgt i32 %106, 20
br i1 %107, label %108, label %109
108: ; preds = %105
br label %151
109: ; preds = %105
%110 = load i32, i32* %21
%111 = add nsw i32 %110, 1
store i32 %111, i32* %21
store double 0.000000e+00, double* %20
%112 = load i32, i32* %16
%113 = load i32, i32* %15
%114 = add nsw i32 %112, %113
%115 = sdiv i32 %114, 2
store i32 %115, i32* %14
store i32 0, i32* %12
br label %116
116: ; preds = %134, %109
%117 = load i32, i32* %12
%118 = icmp slt i32 %117, 5
br i1 %118, label %119, label %137
119: ; preds = %116
%120 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%121 = bitcast [14 x double]* %120 to double**
%122 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%123 = load i32, i32* %14
%124 = load double, double* %4
%125 = call i32 @train(double** %121, double* %122, i32 %123, double %124)
%126 = load double, double* %20
%127 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%128 = bitcast [14 x double]* %127 to double**
%129 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%130 = call double @calculate_cost(double** %128, double* %129)
%131 = fadd double %126, %130
store double %131, double* %20
%132 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%133 = call i32 @reset_coeff(double* %132)
br label %134
134: ; preds = %119
%135 = load i32, i32* %12
%136 = add nsw i32 %135, 1
store i32 %136, i32* %12
br label %116
137: ; preds = %116
%138 = load double, double* %20
%139 = fdiv double %138, 5.000000e+00
store double %139, double* %20
%140 = load i32, i32* %14
%141 = load double, double* %20
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %140, double %141)
%143 = load double, double* %20
%144 = load double, double* %19
%145 = fcmp ogt double %143, %144
br i1 %145, label %146, label %148
146: ; preds = %137
%147 = load i32, i32* %14
store i32 %147, i32* %16
br label %150
148: ; preds = %137
%149 = load i32, i32* %14
store i32 %149, i32* %15
br label %150
150: ; preds = %148, %146
br label %100
151: ; preds = %108, %100
%152 = load i32, i32* %14
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i32 %152)
%154 = load double, double* %19
%155 = fmul double %154, 1.000000e+01
store double %155, double* %22
%156 = load i32, i32* %14
store i32 %156, i32* %23
%157 = load i32, i32* %14
%158 = sub nsw i32 %157, 10
store i32 %158, i32* %11
br label %159
159: ; preds = %199, %151
%160 = load i32, i32* %11
%161 = load i32, i32* %14
%162 = add nsw i32 %161, 10
%163 = icmp sle i32 %160, %162
br i1 %163, label %164, label %202
164: ; preds = %159
store double 0.000000e+00, double* %20
store i32 0, i32* %12
br label %165
165: ; preds = %183, %164
%166 = load i32, i32* %12
%167 = icmp slt i32 %166, 5
br i1 %167, label %168, label %186
168: ; preds = %165
%169 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%170 = bitcast [14 x double]* %169 to double**
%171 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%172 = load i32, i32* %11
%173 = load double, double* %4
%174 = call i32 @train(double** %170, double* %171, i32 %172, double %173)
%175 = load double, double* %20
%176 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %2, i64 0, i64 0
%177 = bitcast [14 x double]* %176 to double**
%178 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%179 = call double @calculate_cost(double** %177, double* %178)
%180 = fadd double %175, %179
store double %180, double* %20
%181 = getelementptr inbounds [14 x double], [14 x double]* %3, i64 0, i64 0
%182 = call i32 @reset_coeff(double* %181)
br label %183
183: ; preds = %168
%184 = load i32, i32* %12
%185 = add nsw i32 %184, 1
store i32 %185, i32* %12
br label %165
186: ; preds = %165
%187 = load double, double* %20
%188 = fdiv double %187, 5.000000e+00
store double %188, double* %20
%189 = load i32, i32* %11
%190 = load double, double* %20
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %189, double %190)
%192 = load double, double* %20
%193 = load double, double* %22
%194 = fcmp olt double %192, %193
br i1 %194, label %195, label %198
195: ; preds = %186
%196 = load double, double* %20
store double %196, double* %22
%197 = load i32, i32* %11
store i32 %197, i32* %23
br label %198
198: ; preds = %195, %186
br label %199
199: ; preds = %198
%200 = load i32, i32* %11
%201 = add nsw i32 %200, 1
store i32 %201, i32* %11
br label %159
202: ; preds = %159
%203 = load i32, i32* %23
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0), i32 %203)
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %206
206: ; preds = %202, %31
%207 = load i32, i32* %1
ret i32 %207
}

LLVM IR (-O2):
@.str = [17 x i8] c"../data/data.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.6 = [24 x i8] c"Error tolerance : %f \0A\0A\00"
@.str.8 = [56 x i8] c"Log: For %d number of random samples, the cost is : %f\0A\00"
@.str.9 = [58 x i8] c"\0AFinding the minimum point near %d number of samples...\0A\0A\00"
@.str.10 = [54 x i8] c"Log: For %d number of random samples, the cost is %f\0A\00"
@.str.11 = [58 x i8] c"\0AMinimum cost is reached by using %d number of samples!\0A\0A\00"
@str = [83 x i8] c"Calculating the error tolerance by sampling and averaging 10 different samples...\0A\00"
@str.13 = [62 x i8] c"Finding a point near local minimum by using binary search...\0A\00"
@str.14 = [11 x i8] c"Exiting...\00"
@str.15 = [32 x i8] c"Failed to read file!\0AExiting...\00"
define i32 @main() {
%1 = alloca [506 x [14 x double]]
%2 = alloca [14 x double]
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast [506 x [14 x double]]* %1 to i8*
%6 = bitcast [14 x double]* %2 to i8*
%7 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%8 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%9 = tail call i32 @time(i32* null)
%10 = tail call i32 @srand(i32 %9)
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = call i32 @getline(i8** %3, i64* %4, i32* %11)
%15 = icmp eq i32 %14, -1
br i1 %15, label %66, label %18
16: ; preds = %0
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.15, i64 0, i64 0))
br label %189
18: ; preds = %13, %18
%19 = phi i64 [ %63, %18 ], [ 0, %13 ]
%20 = load i8*, i8** %3
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 0
%23 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %22)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 1
%26 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %25)
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 2
%29 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %28)
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 3
%32 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %31)
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 4
%35 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %34)
%36 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 5
%38 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %37)
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 6
%41 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %40)
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%43 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 7
%44 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %43)
%45 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 8
%47 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %46)
%48 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%49 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 9
%50 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %49)
%51 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 10
%53 = call i32 @sscanf(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %52)
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%55 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 11
%56 = call i32 @sscanf(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %55)
%57 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%58 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 12
%59 = call i32 @sscanf(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %58)
%60 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%61 = getelementptr inbounds [506 x [14 x double]], [506 x [14 x double]]* %1, i64 0, i64 %19, i64 13
%62 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %61)
%63 = add nuw i64 %19, 1
%64 = call i32 @getline(i8** %3, i64* %4, i32* %11)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %18
66: ; preds = %18, %13
%67 = call i32 @fclose(i32* %11)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([83 x i8], [83 x i8]* @str, i64 0, i64 0))
%69 = bitcast [506 x [14 x double]]* %1 to double**
%70 = getelementptr inbounds [14 x double], [14 x double]* %2, i64 0, i64 0
%71 = call i32 @train(double** %69, double* %70, i32 50, double 0x3EB0C6F7A0B5ED8D)
%72 = call double @calculate_cost(double** %69, double* %70)
%73 = fadd double %72, 0.000000e+00
%74 = call i32 @reset_coeff(double* %70)
%75 = call i32 @train(double** %69, double* %70, i32 100, double 0x3EB0C6F7A0B5ED8D)
%76 = call double @calculate_cost(double** %69, double* %70)
%77 = fadd double %73, %76
%78 = call i32 @reset_coeff(double* %70)
%79 = call i32 @train(double** %69, double* %70, i32 150, double 0x3EB0C6F7A0B5ED8D)
%80 = call double @calculate_cost(double** %69, double* %70)
%81 = fadd double %77, %80
%82 = call i32 @reset_coeff(double* %70)
%83 = call i32 @train(double** %69, double* %70, i32 200, double 0x3EB0C6F7A0B5ED8D)
%84 = call double @calculate_cost(double** %69, double* %70)
%85 = fadd double %81, %84
%86 = call i32 @reset_coeff(double* %70)
%87 = call i32 @train(double** %69, double* %70, i32 250, double 0x3EB0C6F7A0B5ED8D)
%88 = call double @calculate_cost(double** %69, double* %70)
%89 = fadd double %85, %88
%90 = call i32 @reset_coeff(double* %70)
%91 = call i32 @train(double** %69, double* %70, i32 300, double 0x3EB0C6F7A0B5ED8D)
%92 = call double @calculate_cost(double** %69, double* %70)
%93 = fadd double %89, %92
%94 = call i32 @reset_coeff(double* %70)
%95 = call i32 @train(double** %69, double* %70, i32 350, double 0x3EB0C6F7A0B5ED8D)
%96 = call double @calculate_cost(double** %69, double* %70)
%97 = fadd double %93, %96
%98 = call i32 @reset_coeff(double* %70)
%99 = call i32 @train(double** %69, double* %70, i32 400, double 0x3EB0C6F7A0B5ED8D)
%100 = call double @calculate_cost(double** %69, double* %70)
%101 = fadd double %97, %100
%102 = call i32 @reset_coeff(double* %70)
%103 = call i32 @train(double** %69, double* %70, i32 450, double 0x3EB0C6F7A0B5ED8D)
%104 = call double @calculate_cost(double** %69, double* %70)
%105 = fadd double %101, %104
%106 = call i32 @reset_coeff(double* %70)
%107 = call i32 @train(double** %69, double* %70, i32 500, double 0x3EB0C6F7A0B5ED8D)
%108 = call double @calculate_cost(double** %69, double* %70)
%109 = fadd double %105, %108
%110 = call i32 @reset_coeff(double* %70)
%111 = fdiv double %109, 1.000000e+01
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %111)
%113 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.13, i64 0, i64 0))
br label %114
114: ; preds = %66, %114
%115 = phi i32 [ 0, %66 ], [ %140, %114 ]
%116 = phi i32 [ 0, %66 ], [ %145, %114 ]
%117 = phi i32 [ 506, %66 ], [ %144, %114 ]
%118 = add nsw i32 %116, %117
%119 = sdiv i32 %118, 2
%120 = call i32 @train(double** %69, double* %70, i32 %119, double 0x3EB0C6F7A0B5ED8D)
%121 = call double @calculate_cost(double** %69, double* %70)
%122 = fadd double %121, 0.000000e+00
%123 = call i32 @reset_coeff(double* %70)
%124 = call i32 @train(double** %69, double* %70, i32 %119, double 0x3EB0C6F7A0B5ED8D)
%125 = call double @calculate_cost(double** %69, double* %70)
%126 = fadd double %122, %125
%127 = call i32 @reset_coeff(double* %70)
%128 = call i32 @train(double** %69, double* %70, i32 %119, double 0x3EB0C6F7A0B5ED8D)
%129 = call double @calculate_cost(double** %69, double* %70)
%130 = fadd double %126, %129
%131 = call i32 @reset_coeff(double* %70)
%132 = call i32 @train(double** %69, double* %70, i32 %119, double 0x3EB0C6F7A0B5ED8D)
%133 = call double @calculate_cost(double** %69, double* %70)
%134 = fadd double %130, %133
%135 = call i32 @reset_coeff(double* %70)
%136 = call i32 @train(double** %69, double* %70, i32 %119, double 0x3EB0C6F7A0B5ED8D)
%137 = call double @calculate_cost(double** %69, double* %70)
%138 = fadd double %134, %137
%139 = call i32 @reset_coeff(double* %70)
%140 = add nuw nsw i32 %115, 1
%141 = fdiv double %138, 5.000000e+00
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %119, double %141)
%143 = fcmp ogt double %141, %111
%144 = select i1 %143, i32 %117, i32 %119
%145 = select i1 %143, i32 %119, i32 %116
%146 = add nsw i32 %145, 2
%147 = icmp sge i32 %146, %144
%148 = icmp ugt i32 %115, 19
%149 = select i1 %147, i1 true, i1 %148
br i1 %149, label %150, label %114
150: ; preds = %114
%151 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i32 %119)
%152 = fmul double %111, 1.000000e+01
%153 = add nsw i32 %119, -10
%154 = add nsw i32 %119, 10
br label %155
155: ; preds = %150, %155
%156 = phi i32 [ %119, %150 ], [ %183, %155 ]
%157 = phi double [ %152, %150 ], [ %182, %155 ]
%158 = phi i32 [ %153, %150 ], [ %184, %155 ]
%159 = call i32 @train(double** %69, double* %70, i32 %158, double 0x3EB0C6F7A0B5ED8D)
%160 = call double @calculate_cost(double** %69, double* %70)
%161 = fadd double %160, 0.000000e+00
%162 = call i32 @reset_coeff(double* %70)
%163 = call i32 @train(double** %69, double* %70, i32 %158, double 0x3EB0C6F7A0B5ED8D)
%164 = call double @calculate_cost(double** %69, double* %70)
%165 = fadd double %161, %164
%166 = call i32 @reset_coeff(double* %70)
%167 = call i32 @train(double** %69, double* %70, i32 %158, double 0x3EB0C6F7A0B5ED8D)
%168 = call double @calculate_cost(double** %69, double* %70)
%169 = fadd double %165, %168
%170 = call i32 @reset_coeff(double* %70)
%171 = call i32 @train(double** %69, double* %70, i32 %158, double 0x3EB0C6F7A0B5ED8D)
%172 = call double @calculate_cost(double** %69, double* %70)
%173 = fadd double %169, %172
%174 = call i32 @reset_coeff(double* %70)
%175 = call i32 @train(double** %69, double* %70, i32 %158, double 0x3EB0C6F7A0B5ED8D)
%176 = call double @calculate_cost(double** %69, double* %70)
%177 = fadd double %173, %176
%178 = call i32 @reset_coeff(double* %70)
%179 = fdiv double %177, 5.000000e+00
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %158, double %179)
%181 = fcmp olt double %179, %157
%182 = select i1 %181, double %179, double %157
%183 = select i1 %181, i32 %158, i32 %156
%184 = add nsw i32 %158, 1
%185 = icmp eq i32 %158, %154
br i1 %185, label %186, label %155
186: ; preds = %155
%187 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0), i32 %183)
%188 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
br label %189
189: ; preds = %186, %16
%190 = phi i32 [ -1, %16 ], [ 0, %186 ]
ret i32 %190
}