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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fit_gaussian_mixture(double *, size_t, size_t, double *,
                                        double *, double *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(double *);
double log(double);
double *malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
double *realloc(double *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
double strtod(char *, char **);
int main(int argc, char *argv[]) {
  FILE *fin;
  if (argc > 1) {
    fin = fopen(argv[1], "r");
    if (fin == NULL) {
      fprintf(stderr, "fit_lnorm_mix: can't open file \"%s\".\n", argv[1]);
      return EXIT_FAILURE;
    }
  } else
    fin = stdin;
  size_t k = 2;
  size_t n = 0;
  size_t size = 10000;
  char *endptr;
  double x;
  double *xs = malloc(size * sizeof(double));
  char line[512];
  while (fgets(line, sizeof(line), fin)) {
    if (n == size) {
      size += 1000;
      xs = realloc(xs, size * sizeof(double));
    }
    x = strtod(line, &endptr);
    if (x == 0.0 || endptr == line)
      continue;
    xs[n++] = log(x);
  }
  if (fin != stdin)
    fclose(fin);
  fprintf(stderr, "read %zu values.\n", n);
  fprintf(stderr, "fitting ... \n");
  double *ps = malloc(k * sizeof(double));
  double *mus = malloc(k * sizeof(double));
  double *sds = malloc(k * sizeof(double));
  fit_gaussian_mixture(xs, n, k, ps, mus, sds);
  size_t i;
  printf("ps  = [ %e", ps[0]);
  for (i = 1; i < k; ++i)
    printf(", %e", ps[i]);
  printf(" ]\n");
  printf("mus = [ %e", mus[0]);
  for (i = 1; i < k; ++i)
    printf(", %e", mus[i]);
  printf(" ]\n");
  printf("sds = [ %e", sds[0]);
  for (i = 1; i < k; ++i)
    printf(", %e", sds[i]);
  printf(" ]\n");
  free(ps);
  free(mus);
  free(sds);
  free(xs);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    122b <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1226 <main+0x76>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    157f <main+0x3cf>
jmp    1239 <main+0x89>
mov    0x2db6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x2,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x2710,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
shl    $0x3,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
lea    -0x250(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1324 <main+0x174>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    12b2 <main+0x102>
mov    -0x30(%rbp),%rax
add    $0x3e8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
shl    $0x3,%rsi
call   10b0 <realloc@plt>
mov    %rax,-0x48(%rbp)
lea    -0x250(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e4 <main+0x134>
jp     12e4 <main+0x134>
jmp    12f8 <main+0x148>
mov    -0x38(%rbp),%rax
lea    -0x250(%rbp),%rcx
cmp    %rcx,%rax
jne    12fd <main+0x14d>
jmp    1262 <main+0xb2>
movsd  -0x40(%rbp),%xmm0
call   10c0 <log@plt>
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
movsd  %xmm0,(%rax,%rcx,8)
jmp    1262 <main+0xb2>
mov    -0x18(%rbp),%rax
mov    0x2cb9(%rip),%rcx
cmp    (%rcx),%rax
je     1341 <main+0x191>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xcd3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x258(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x260(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x268(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x258(%rbp),%rcx
mov    -0x260(%rbp),%r8
mov    -0x268(%rbp),%r9
call   1070 <fit_gaussian_mixture@plt>
mov    -0x258(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xc61(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movq   $0x1,-0x270(%rbp)
mov    -0x270(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1442 <main+0x292>
mov    -0x258(%rbp),%rax
mov    -0x270(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xc2f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x270(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x270(%rbp)
jmp    13f9 <main+0x249>
lea    0xc0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x260(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xbfa(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movq   $0x1,-0x270(%rbp)
mov    -0x270(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    14bd <main+0x30d>
mov    -0x260(%rbp),%rax
mov    -0x270(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xbb4(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x270(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x270(%rbp)
jmp    1474 <main+0x2c4>
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x268(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xb8a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movq   $0x1,-0x270(%rbp)
mov    -0x270(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1538 <main+0x388>
mov    -0x268(%rbp),%rax
mov    -0x270(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xb39(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x270(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x270(%rbp)
jmp    14ef <main+0x33f>
lea    0xb19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x258(%rbp),%rdi
call   1030 <free@plt>
mov    -0x260(%rbp),%rdi
call   1030 <free@plt>
mov    -0x268(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jl     1218 <main+0x58>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe24(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1222 <main+0x62>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe05(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2dbd(%rip),%rax
jmp    13eb <main+0x22b>
mov    0x2dc9(%rip),%rax
mov    (%rax),%r12
mov    $0x13880,%edi
call   10b0 <malloc@plt>
mov    %rax,(%rsp)
mov    $0x2710,%r14d
xor    %r15d,%r15d
lea    0x10(%rsp),%rbx
lea    0x3e8(%r15),%r13
lea    0x1f40(,%r15,8),%rbp
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12b2 <main+0xf2>
cmp    %r14,%r15
jne    127d <main+0xbd>
mov    (%rsp),%rdi
mov    %rbp,%rsi
call   10c0 <realloc@plt>
mov    %rax,(%rsp)
mov    %r13,%r14
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <strtod@plt>
ucomisd 0xd6e(%rip),%xmm0
jne    1296 <main+0xd6>
jnp    1250 <main+0x90>
cmp    %rbx,0x8(%rsp)
je     1250 <main+0x90>
call   10d0 <log@plt>
mov    (%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
add    $0x1,%r15
jmp    123e <main+0x7e>
mov    0x2d2f(%rip),%rax
cmp    (%rax),%r12
je     12c6 <main+0x106>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x2d0b(%rip),%rbx
mov    (%rbx),%edi
lea    0xd5a(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x10,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    $0x10,%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
mov    $0x10,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    $0x2,%edx
mov    (%rsp),%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rcx
mov    %r13,%r8
mov    %rax,%r9
call   1080 <fit_gaussian_mixture@plt>
movsd  (%r12),%xmm0
lea    0xd0f(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%r12),%xmm0
lea    0xd05(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xd0f(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
movsd  0x0(%r13),%xmm0
lea    0xce4(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%r13),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
movsd  (%rbx),%xmm0
lea    0xcc5(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%rbx),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2bdd(%rip),%rax
mov    (%rax),%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"fit_lnorm_mix: can't open file \22%s\22.\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32* null
@.str.2 = [18 x i8] c"read %zu values.\0A\00"
@.str.3 = [14 x i8] c"fitting ... \0A\00"
@.str.4 = [11 x i8] c"ps = [ %e\00"
@.str.5 = [5 x i8] c", %e\00"
@.str.6 = [4 x i8] c" ]\0A\00"
@.str.7 = [11 x i8] c"mus = [ %e\00"
@.str.8 = [11 x i8] c"sds = [ %e\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca double
%12 = alloca double*
%13 = alloca [512 x i8]
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %35
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %34
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %3
br label %169
34: ; preds = %20
br label %37
35: ; preds = %2
%36 = load i32*, i32** @stdin
store i32* %36, i32** %6
br label %37
37: ; preds = %35, %34
store i64 2, i64* %7
store i64 0, i64* %8
store i64 10000, i64* %9
%38 = load i64, i64* %9
%39 = mul i64 %38, 8
%40 = call double* @malloc(i64 %39)
store double* %40, double** %12
br label %41
41: ; preds = %67, %66, %37
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%43 = load i32*, i32** %6
%44 = call i64 @fgets(i8* %42, i32 512, i32* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %74
46: ; preds = %41
%47 = load i64, i64* %8
%48 = load i64, i64* %9
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load i64, i64* %9
%52 = add i64 %51, 1000
store i64 %52, i64* %9
%53 = load double*, double** %12
%54 = load i64, i64* %9
%55 = mul i64 %54, 8
%56 = call double* @realloc(double* %53, i64 %55)
store double* %56, double** %12
br label %57
57: ; preds = %50, %46
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%59 = call double @strtod(i8* %58, i8** %10)
store double %59, double* %11
%60 = load double, double* %11
%61 = fcmp oeq double %60, 0.000000e+00
br i1 %61, label %66, label %62
62: ; preds = %57
%63 = load i8*, i8** %10
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%65 = icmp eq i8* %63, %64
br i1 %65, label %66, label %67
66: ; preds = %62, %57
br label %41
67: ; preds = %62
%68 = load double, double* %11
%69 = call double @log(double %68)
%70 = load double*, double** %12
%71 = load i64, i64* %8
%72 = add i64 %71, 1
store i64 %72, i64* %8
%73 = getelementptr inbounds double, double* %70, i64 %71
store double %69, double* %73
br label %41
74: ; preds = %41
%75 = load i32*, i32** %6
%76 = load i32*, i32** @stdin
%77 = icmp ne i32* %75, %76
br i1 %77, label %78, label %81
78: ; preds = %74
%79 = load i32*, i32** %6
%80 = call i32 @fclose(i32* %79)
br label %81
81: ; preds = %78, %74
%82 = load i32, i32* @stderr
%83 = load i64, i64* %8
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %83)
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%87 = load i64, i64* %7
%88 = mul i64 %87, 8
%89 = call double* @malloc(i64 %88)
store double* %89, double** %14
%90 = load i64, i64* %7
%91 = mul i64 %90, 8
%92 = call double* @malloc(i64 %91)
store double* %92, double** %15
%93 = load i64, i64* %7
%94 = mul i64 %93, 8
%95 = call double* @malloc(i64 %94)
store double* %95, double** %16
%96 = load double*, double** %12
%97 = load i64, i64* %8
%98 = load i64, i64* %7
%99 = load double*, double** %14
%100 = load double*, double** %15
%101 = load double*, double** %16
%102 = call i32 @fit_gaussian_mixture(double* %96, i64 %97, i64 %98, double* %99, double* %100, double* %101)
%103 = load double*, double** %14
%104 = getelementptr inbounds double, double* %103, i64 0
%105 = load double, double* %104
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %105)
store i64 1, i64* %17
br label %107
107: ; preds = %117, %81
%108 = load i64, i64* %17
%109 = load i64, i64* %7
%110 = icmp ult i64 %108, %109
br i1 %110, label %111, label %120
111: ; preds = %107
%112 = load double*, double** %14
%113 = load i64, i64* %17
%114 = getelementptr inbounds double, double* %112, i64 %113
%115 = load double, double* %114
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %115)
br label %117
117: ; preds = %111
%118 = load i64, i64* %17
%119 = add i64 %118, 1
store i64 %119, i64* %17
br label %107
120: ; preds = %107
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%122 = load double*, double** %15
%123 = getelementptr inbounds double, double* %122, i64 0
%124 = load double, double* %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), double %124)
store i64 1, i64* %17
br label %126
126: ; preds = %136, %120
%127 = load i64, i64* %17
%128 = load i64, i64* %7
%129 = icmp ult i64 %127, %128
br i1 %129, label %130, label %139
130: ; preds = %126
%131 = load double*, double** %15
%132 = load i64, i64* %17
%133 = getelementptr inbounds double, double* %131, i64 %132
%134 = load double, double* %133
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %134)
br label %136
136: ; preds = %130
%137 = load i64, i64* %17
%138 = add i64 %137, 1
store i64 %138, i64* %17
br label %126
139: ; preds = %126
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%141 = load double*, double** %16
%142 = getelementptr inbounds double, double* %141, i64 0
%143 = load double, double* %142
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), double %143)
store i64 1, i64* %17
br label %145
145: ; preds = %155, %139
%146 = load i64, i64* %17
%147 = load i64, i64* %7
%148 = icmp ult i64 %146, %147
br i1 %148, label %149, label %158
149: ; preds = %145
%150 = load double*, double** %16
%151 = load i64, i64* %17
%152 = getelementptr inbounds double, double* %150, i64 %151
%153 = load double, double* %152
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %153)
br label %155
155: ; preds = %149
%156 = load i64, i64* %17
%157 = add i64 %156, 1
store i64 %157, i64* %17
br label %145
158: ; preds = %145
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%160 = load double*, double** %14
%161 = call i32 @free(double* %160)
%162 = load double*, double** %15
%163 = call i32 @free(double* %162)
%164 = load double*, double** %16
%165 = call i32 @free(double* %164)
%166 = load double*, double** %12
%167 = call i32 @free(double* %166)
%168 = load i32, i32* @EXIT_SUCCESS
store i32 %168, i32* %3
br label %169
169: ; preds = %158, %27
%170 = load i32, i32* %3
ret i32 %170
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"fit_lnorm_mix: can't open file \22%s\22.\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32* null
@.str.2 = [18 x i8] c"read %zu values.\0A\00"
@.str.3 = [14 x i8] c"fitting ... \0A\00"
@.str.4 = [11 x i8] c"ps = [ %e\00"
@.str.5 = [5 x i8] c", %e\00"
@.str.7 = [11 x i8] c"mus = [ %e\00"
@.str.8 = [11 x i8] c"sds = [ %e\00"
@EXIT_SUCCESS = global i32 0
@str.10 = [3 x i8] c" ]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [512 x i8]
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %7
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
br label %87
16: ; preds = %2
%17 = load i32*, i32** @stdin
br label %18
18: ; preds = %6, %16
%19 = phi i32* [ %9, %6 ], [ %17, %16 ]
%20 = bitcast i8** %3 to i8*
%21 = tail call double* @malloc(i64 80000)
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
br label %23
23: ; preds = %46, %18
%24 = phi i64 [ %39, %46 ], [ 10000, %18 ]
%25 = phi i64 [ %48, %46 ], [ 0, %18 ]
%26 = phi double* [ %40, %46 ], [ %21, %18 ]
%27 = add i64 %25, 1000
%28 = shl i64 %27, 3
br label %29
29: ; preds = %23, %38
%30 = phi i64 [ %39, %38 ], [ %24, %23 ]
%31 = phi double* [ %40, %38 ], [ %26, %23 ]
%32 = call i64 @fgets(i8* %22, i32 512, i32* %19)
%33 = icmp eq i64 %32, 0
br i1 %33, label %50, label %34
34: ; preds = %29
%35 = icmp eq i64 %25, %30
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = call double* @realloc(double* %31, i64 %28)
br label %38
38: ; preds = %36, %34
%39 = phi i64 [ %27, %36 ], [ %30, %34 ]
%40 = phi double* [ %37, %36 ], [ %31, %34 ]
%41 = call double @strtod(i8* %22, i8** %3)
%42 = fcmp oeq double %41, 0.000000e+00
%43 = load i8*, i8** %3
%44 = icmp eq i8* %43, %22
%45 = select i1 %42, i1 true, i1 %44
br i1 %45, label %29, label %46
46: ; preds = %38
%47 = call double @log(double %41)
%48 = add i64 %25, 1
%49 = getelementptr inbounds double, double* %40, i64 %25
store double %47, double* %49
br label %23
50: ; preds = %29
%51 = load i32*, i32** @stdin
%52 = icmp eq i32* %19, %51
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = call i32 @fclose(i32* %19)
br label %55
55: ; preds = %53, %50
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %25)
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%60 = call double* @malloc(i64 16)
%61 = call double* @malloc(i64 16)
%62 = call double* @malloc(i64 16)
%63 = call i32 @fit_gaussian_mixture(double* %31, i64 %25, i64 2, double* %60, double* %61, double* %62)
%64 = load double, double* %60
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %64)
%66 = getelementptr inbounds double, double* %60, i64 1
%67 = load double, double* %66
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %67)
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%70 = load double, double* %61
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), double %70)
%72 = getelementptr inbounds double, double* %61, i64 1
%73 = load double, double* %72
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %73)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%76 = load double, double* %62
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), double %76)
%78 = getelementptr inbounds double, double* %62, i64 1
%79 = load double, double* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), double %79)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%82 = call i32 @free(double* %60)
%83 = call i32 @free(double* %61)
%84 = call i32 @free(double* %62)
%85 = call i32 @free(double* %31)
%86 = load i32, i32* @EXIT_SUCCESS
br label %87
87: ; preds = %55, %11
%88 = phi i32 [ %15, %11 ], [ %86, %55 ]
ret i32 %88
}