#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ read_mu_sigma_w(int, int, int /*<<< orphan*/ *, double **,
                                   double **, double *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strtok(char *, char *);
int /*<<< orphan*/ write_array(double **, int, int, char *);
int /*<<< orphan*/ write_vector(double *, int, char *);
int main(int argc, char *argv[]) {
  if (argc != 5) {
    fprintf(stderr, "Usage: $ %s (GMM file) (mu_out) (sigma_out) (w_out)\n",
            argv[0]);
    exit(EXIT_FAILURE);
  }
  FILE *fp_gmm;
  int i, k;
  char inbuf[10000];
  int dim, mixture;
  char *mu_out = argv[2], *sigma_out = argv[3], *w_out = argv[4];
  memset(inbuf, 0, 10000);
  if ((fp_gmm = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "File open error!\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 3; i++)
    fgets(inbuf, 10000, fp_gmm);
  strtok(inbuf, " ");
  dim = atoi(strtok(NULL, " "));
  for (i = 0; i < 5; i++)
    fgets(inbuf, 10000, fp_gmm);
  strtok(inbuf, " \n");
  mixture = atoi(strtok(NULL, " \n"));
  rewind(fp_gmm);
  double **mu_gmm, **sigma_gmm, *w_gmm;
  mu_gmm = (double **)malloc(sizeof(double *) * mixture);
  sigma_gmm = (double **)malloc(sizeof(double *) * mixture);
  mu_gmm[0] = (double *)malloc(sizeof(double) * mixture * dim);
  sigma_gmm[0] = (double *)malloc(sizeof(double) * mixture * dim);
  for (k = 1; k < mixture; k++) {
    mu_gmm[k] = mu_gmm[0] + k * dim;
    sigma_gmm[k] = sigma_gmm[0] + k * dim;
  }
  if (mu_gmm == NULL || sigma_gmm == NULL || mu_gmm[0] == NULL ||
      sigma_gmm[0] == NULL) {
    fprintf(stderr, "Error: Memory allocation for mu / sigma failed\n");
    exit(EXIT_FAILURE);
  }
  w_gmm = (double *)malloc(sizeof(double) * mixture);
  read_mu_sigma_w(dim, mixture, fp_gmm, mu_gmm, sigma_gmm, w_gmm);
  fclose(fp_gmm);
  write_array(mu_gmm, mixture, dim, mu_out);
  write_array(sigma_gmm, mixture, dim, sigma_out);
  write_vector(w_gmm, mixture, w_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2770,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     121f <main+0x4f>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x2740(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x2748(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x2750(%rbp)
lea    -0x2730(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12a6 <main+0xd6>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    12da <main+0x10a>
lea    -0x2730(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2710,%esi
call   1060 <fgets@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12ad <main+0xdd>
lea    -0x2730(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   10b0 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd51(%rip),%rsi
call   10b0 <strtok@plt>
mov    %eax,%edi
call   10e0 <atoi@plt>
mov    %eax,-0x2734(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    133e <main+0x16e>
lea    -0x2730(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2710,%esi
call   1060 <fgets@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1311 <main+0x141>
lea    -0x2730(%rbp),%rdi
lea    0xcff(%rip),%rsi
call   10b0 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcef(%rip),%rsi
call   10b0 <strtok@plt>
mov    %eax,%edi
call   10e0 <atoi@plt>
mov    %eax,-0x2738(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <rewind@plt>
movslq -0x2738(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x2758(%rbp)
movslq -0x2738(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x2760(%rbp)
movslq -0x2738(%rbp),%rax
shl    $0x3,%rax
movslq -0x2734(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x2758(%rbp),%rax
mov    %rcx,(%rax)
movslq -0x2738(%rbp),%rax
shl    $0x3,%rax
movslq -0x2734(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x2760(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x2738(%rbp),%eax
jge    1479 <main+0x2a9>
mov    -0x2758(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%eax
imul   -0x2734(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x2758(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2760(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%eax
imul   -0x2734(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x2760(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1404 <main+0x234>
cmpq   $0x0,-0x2758(%rbp)
je     14b7 <main+0x2e7>
cmpq   $0x0,-0x2760(%rbp)
je     14b7 <main+0x2e7>
mov    -0x2758(%rbp),%rax
cmpq   $0x0,(%rax)
je     14b7 <main+0x2e7>
mov    -0x2760(%rbp),%rax
cmpq   $0x0,(%rax)
jne    14dc <main+0x30c>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    0xb87(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b03(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movslq -0x2738(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x2768(%rbp)
mov    -0x2734(%rbp),%edi
mov    -0x2738(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x2758(%rbp),%rcx
mov    -0x2760(%rbp),%r8
mov    -0x2768(%rbp),%r9
call   10c0 <read_mu_sigma_w@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2758(%rbp),%rdi
mov    -0x2738(%rbp),%esi
mov    -0x2734(%rbp),%edx
mov    -0x2740(%rbp),%rcx
call   10d0 <write_array@plt>
mov    -0x2760(%rbp),%rdi
mov    -0x2738(%rbp),%esi
mov    -0x2734(%rbp),%edx
mov    -0x2748(%rbp),%rcx
call   10d0 <write_array@plt>
mov    -0x2768(%rbp),%rdi
mov    -0x2738(%rbp),%esi
mov    -0x2750(%rbp),%rdx
call   1090 <write_vector@plt>
xor    %eax,%eax
add    $0x2770,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2738,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jne    148f <main+0x2bf>
mov    0x10(%rbx),%rax
mov    %rax,0x8(%rsp)
mov    0x18(%rbx),%rax
mov    %rax,0x10(%rsp)
mov    0x20(%rbx),%rax
mov    %rax,0x18(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1050 <memset@plt>
mov    0x8(%rbx),%rdi
lea    0xe11(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14ab <main+0x2db>
mov    %rax,%r13
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
lea    0xdd8(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   10b0 <strtok@plt>
mov    %eax,%edi
call   10e0 <atoi@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
lea    0xd65(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   10b0 <strtok@plt>
mov    %eax,%edi
call   10e0 <atoi@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1040 <rewind@plt>
lea    0x0(,%rbp,8),%r12d
mov    %r12d,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %r12d,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %r12d,0x4(%rsp)
imul   %ebx,%r12d
mov    %r12d,%edi
call   1080 <malloc@plt>
mov    %rax,(%r15)
mov    %r12d,%edi
mov    %rbp,%r12
call   1080 <malloc@plt>
mov    %rax,(%r14)
cmp    $0x1,%r12d
jle    140a <main+0x23a>
mov    %ebx,%r10d
movslq %ebx,%r8
mov    %r12d,%r9d
add    $0xffffffffffffffff,%r9
cmp    $0x2,%r12d
jne    1370 <main+0x1a0>
mov    $0x1,%esi
jmp    13e3 <main+0x213>
lea    0x0(,%r8,8),%rdi
mov    %r8,%rbp
shl    $0x4,%rbp
mov    %r9,%rdx
and    $0xfffffffffffffffe,%rdx
neg    %rdx
mov    $0x1,%esi
mov    %rbp,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%rax
add    %rdi,%rax
mov    %rax,(%r15,%rsi,8)
mov    (%r14),%rax
add    %rdi,%rax
mov    %rax,(%r14,%rsi,8)
mov    (%r15),%rax
add    %rcx,%rax
mov    %rax,0x8(%r15,%rsi,8)
mov    (%r14),%rax
lea    (%rax,%rcx,1),%rbx
mov    %rbx,0x8(%r14,%rsi,8)
add    %rbp,%rdi
add    %rbp,%rcx
lea    (%rdx,%rsi,1),%rbx
add    $0x2,%rbx
add    $0x2,%rsi
cmp    $0x1,%rbx
jne    13a0 <main+0x1d0>
test   $0x1,%r9b
mov    %r10d,%ebx
je     140a <main+0x23a>
imul   %rsi,%r8
lea    0x0(,%r8,8),%rax
add    (%r15),%rax
mov    %rax,(%r15,%rsi,8)
mov    (%r14),%rax
lea    (%rax,%r8,8),%rcx
mov    %rcx,(%r14,%rsi,8)
cmpq   $0x0,(%r15)
je     14bd <main+0x2ed>
test   %rax,%rax
je     14bd <main+0x2ed>
mov    0x4(%rsp),%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    %rax,%r9
call   10c0 <read_mu_sigma_w@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    0x8(%rsp),%rcx
call   10d0 <write_array@plt>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    0x10(%rsp),%rcx
call   10d0 <write_array@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    0x18(%rsp),%rdx
call   1090 <write_vector@plt>
xor    %eax,%eax
add    $0x2738,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xb5e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    14d4 <main+0x304>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
lea    0xb7c(%rip),%rsi
jmp    14cd <main+0x2fd>
mov    0x2b1c(%rip),%rax
mov    (%rax),%edi
lea    0xb81(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2afd(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"Usage: $ %s (GMM file) (mu_out) (sigma_out) (w_out)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"File open error!\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c" \0A\00"
@.str.5 = [48 x i8] c"Error: Memory allocation for mu / sigma failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [10000 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca double**
%16 = alloca double**
%17 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 5
br i1 %19, label %20, label %28
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
store i8* %31, i8** %12
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
store i8* %34, i8** %13
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
store i8* %37, i8** %14
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 10000)
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %43, i32** %6
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %50
45: ; preds = %28
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %28
store i32 0, i32* %7
br label %51
51: ; preds = %58, %50
%52 = load i32, i32* %7
%53 = icmp slt i32 %52, 3
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%56 = load i32*, i32** %6
%57 = call i32 @fgets(i8* %55, i32 10000, i32* %56)
br label %58
58: ; preds = %54
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %51
61: ; preds = %51
%62 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%63 = call i32 @strtok(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%64 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 @atoi(i32 %64)
store i32 %65, i32* %10
store i32 0, i32* %7
br label %66
66: ; preds = %73, %61
%67 = load i32, i32* %7
%68 = icmp slt i32 %67, 5
br i1 %68, label %69, label %76
69: ; preds = %66
%70 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%71 = load i32*, i32** %6
%72 = call i32 @fgets(i8* %70, i32 10000, i32* %71)
br label %73
73: ; preds = %69
%74 = load i32, i32* %7
%75 = add nsw i32 %74, 1
store i32 %75, i32* %7
br label %66
76: ; preds = %66
%77 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%78 = call i32 @strtok(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%79 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%80 = call i32 @atoi(i32 %79)
store i32 %80, i32* %11
%81 = load i32*, i32** %6
%82 = call i32 @rewind(i32* %81)
%83 = load i32, i32* %11
%84 = sext i32 %83 to i64
%85 = mul i64 8, %84
%86 = trunc i64 %85 to i32
%87 = call i64 @malloc(i32 %86)
%88 = inttoptr i64 %87 to double**
store double** %88, double*** %15
%89 = load i32, i32* %11
%90 = sext i32 %89 to i64
%91 = mul i64 8, %90
%92 = trunc i64 %91 to i32
%93 = call i64 @malloc(i32 %92)
%94 = inttoptr i64 %93 to double**
store double** %94, double*** %16
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = mul i64 8, %96
%98 = load i32, i32* %10
%99 = sext i32 %98 to i64
%100 = mul i64 %97, %99
%101 = trunc i64 %100 to i32
%102 = call i64 @malloc(i32 %101)
%103 = inttoptr i64 %102 to double*
%104 = load double**, double*** %15
%105 = getelementptr inbounds double*, double** %104, i64 0
store double* %103, double** %105
%106 = load i32, i32* %11
%107 = sext i32 %106 to i64
%108 = mul i64 8, %107
%109 = load i32, i32* %10
%110 = sext i32 %109 to i64
%111 = mul i64 %108, %110
%112 = trunc i64 %111 to i32
%113 = call i64 @malloc(i32 %112)
%114 = inttoptr i64 %113 to double*
%115 = load double**, double*** %16
%116 = getelementptr inbounds double*, double** %115, i64 0
store double* %114, double** %116
store i32 1, i32* %8
br label %117
117: ; preds = %146, %76
%118 = load i32, i32* %8
%119 = load i32, i32* %11
%120 = icmp slt i32 %118, %119
br i1 %120, label %121, label %149
121: ; preds = %117
%122 = load double**, double*** %15
%123 = getelementptr inbounds double*, double** %122, i64 0
%124 = load double*, double** %123
%125 = load i32, i32* %8
%126 = load i32, i32* %10
%127 = mul nsw i32 %125, %126
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %124, i64 %128
%130 = load double**, double*** %15
%131 = load i32, i32* %8
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds double*, double** %130, i64 %132
store double* %129, double** %133
%134 = load double**, double*** %16
%135 = getelementptr inbounds double*, double** %134, i64 0
%136 = load double*, double** %135
%137 = load i32, i32* %8
%138 = load i32, i32* %10
%139 = mul nsw i32 %137, %138
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %136, i64 %140
%142 = load double**, double*** %16
%143 = load i32, i32* %8
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double*, double** %142, i64 %144
store double* %141, double** %145
br label %146
146: ; preds = %121
%147 = load i32, i32* %8
%148 = add nsw i32 %147, 1
store i32 %148, i32* %8
br label %117
149: ; preds = %117
%150 = load double**, double*** %15
%151 = icmp eq double** %150, null
br i1 %151, label %165, label %152
152: ; preds = %149
%153 = load double**, double*** %16
%154 = icmp eq double** %153, null
br i1 %154, label %165, label %155
155: ; preds = %152
%156 = load double**, double*** %15
%157 = getelementptr inbounds double*, double** %156, i64 0
%158 = load double*, double** %157
%159 = icmp eq double* %158, null
br i1 %159, label %165, label %160
160: ; preds = %155
%161 = load double**, double*** %16
%162 = getelementptr inbounds double*, double** %161, i64 0
%163 = load double*, double** %162
%164 = icmp eq double* %163, null
br i1 %164, label %165, label %170
165: ; preds = %160, %155, %152, %149
%166 = load i32, i32* @stderr
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%168 = load i32, i32* @EXIT_FAILURE
%169 = call i32 @exit(i32 %168)
unreachable
170: ; preds = %160
%171 = load i32, i32* %11
%172 = sext i32 %171 to i64
%173 = mul i64 8, %172
%174 = trunc i64 %173 to i32
%175 = call i64 @malloc(i32 %174)
%176 = inttoptr i64 %175 to double*
store double* %176, double** %17
%177 = load i32, i32* %10
%178 = load i32, i32* %11
%179 = load i32*, i32** %6
%180 = load double**, double*** %15
%181 = load double**, double*** %16
%182 = load double*, double** %17
%183 = call i32 @read_mu_sigma_w(i32 %177, i32 %178, i32* %179, double** %180, double** %181, double* %182)
%184 = load i32*, i32** %6
%185 = call i32 @fclose(i32* %184)
%186 = load double**, double*** %15
%187 = load i32, i32* %11
%188 = load i32, i32* %10
%189 = load i8*, i8** %12
%190 = call i32 @write_array(double** %186, i32 %187, i32 %188, i8* %189)
%191 = load double**, double*** %16
%192 = load i32, i32* %11
%193 = load i32, i32* %10
%194 = load i8*, i8** %13
%195 = call i32 @write_array(double** %191, i32 %192, i32 %193, i8* %194)
%196 = load double*, double** %17
%197 = load i32, i32* %11
%198 = load i8*, i8** %14
%199 = call i32 @write_vector(double* %196, i32 %197, i8* %198)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"Usage: $ %s (GMM file) (mu_out) (sigma_out) (w_out)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"File open error!\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c" \0A\00"
@.str.5 = [48 x i8] c"Error: Memory allocation for mu / sigma failed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8]
%4 = icmp eq i32 %0, 5
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = call i32 @memset(i8* %12, i32 0, i32 10000)
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %51, label %24
24: ; preds = %11
%25 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%26 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%27 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%28 = call i32 @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @atoi(i32 %29)
%31 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%32 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%33 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%34 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%35 = call i32 @fgets(i8* %12, i32 10000, i32* %22)
%36 = call i32 @strtok(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @atoi(i32 %37)
%39 = call i32 @rewind(i32* %22)
%40 = shl i32 %38, 3
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to double**
%43 = call i64 @malloc(i32 %40)
%44 = inttoptr i64 %43 to double**
%45 = mul i32 %40, %30
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to double*
store double* %47, double** %42
%48 = call i64 @malloc(i32 %45)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %44
%50 = icmp sgt i32 %38, 1
br i1 %50, label %56, label %97
51: ; preds = %11
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %24
%57 = sext i32 %30 to i64
%58 = zext i32 %38 to i64
%59 = add nsw i64 %58, -1
%60 = and i64 %59, 1
%61 = icmp eq i32 %38, 2
br i1 %61, label %85, label %62
62: ; preds = %56
%63 = and i64 %59, -2
br label %64
64: ; preds = %64, %62
%65 = phi i64 [ 1, %62 ], [ %82, %64 ]
%66 = phi i64 [ 0, %62 ], [ %83, %64 ]
%67 = load double*, double** %42
%68 = mul nsw i64 %65, %57
%69 = getelementptr inbounds double, double* %67, i64 %68
%70 = getelementptr inbounds double*, double** %42, i64 %65
store double* %69, double** %70
%71 = load double*, double** %44
%72 = getelementptr inbounds double, double* %71, i64 %68
%73 = getelementptr inbounds double*, double** %44, i64 %65
store double* %72, double** %73
%74 = add nuw nsw i64 %65, 1
%75 = load double*, double** %42
%76 = mul nsw i64 %74, %57
%77 = getelementptr inbounds double, double* %75, i64 %76
%78 = getelementptr inbounds double*, double** %42, i64 %74
store double* %77, double** %78
%79 = load double*, double** %44
%80 = getelementptr inbounds double, double* %79, i64 %76
%81 = getelementptr inbounds double*, double** %44, i64 %74
store double* %80, double** %81
%82 = add nuw nsw i64 %65, 2
%83 = add i64 %66, 2
%84 = icmp eq i64 %83, %63
br i1 %84, label %85, label %64
85: ; preds = %64, %56
%86 = phi double* [ undef, %56 ], [ %79, %64 ]
%87 = phi i64 [ 1, %56 ], [ %82, %64 ]
%88 = icmp eq i64 %60, 0
br i1 %88, label %97, label %89
89: ; preds = %85
%90 = load double*, double** %42
%91 = mul nsw i64 %87, %57
%92 = getelementptr inbounds double, double* %90, i64 %91
%93 = getelementptr inbounds double*, double** %42, i64 %87
store double* %92, double** %93
%94 = load double*, double** %44
%95 = getelementptr inbounds double, double* %94, i64 %91
%96 = getelementptr inbounds double*, double** %44, i64 %87
store double* %95, double** %96
br label %97
97: ; preds = %89, %85, %24
%98 = phi double* [ %49, %24 ], [ %86, %85 ], [ %94, %89 ]
%99 = load double*, double** %42
%100 = icmp eq double* %99, null
%101 = icmp eq double* %98, null
%102 = select i1 %100, i1 true, i1 %101
br i1 %102, label %103, label %108
103: ; preds = %97
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
%106 = load i32, i32* @EXIT_FAILURE
%107 = call i32 @exit(i32 %106)
unreachable
108: ; preds = %97
%109 = call i64 @malloc(i32 %40)
%110 = inttoptr i64 %109 to double*
%111 = call i32 @read_mu_sigma_w(i32 %30, i32 %38, i32* %22, double** %42, double** %44, double* %110)
%112 = call i32 @fclose(i32* %22)
%113 = call i32 @write_array(double** %42, i32 %38, i32 %30, i8* %14)
%114 = call i32 @write_array(double** %44, i32 %38, i32 %30, i8* %16)
%115 = call i32 @write_vector(double* %110, i32 %38, i8* %18)
ret i32 0
}