#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
char *strtok(char *, char *);
double **ParHIGGS(int *feature_list, int num_features) {
  int n = 13007;
  char filename[28];
  int i, j, k;
  FILE *file;
  char line[1000];
  char *ptr;
  double **data = malloc(n * sizeof(double *));
  for (i = 0; i < n; ++i)
    data[i] = malloc((num_features + 1) * sizeof(double));
  double holder[29];
  for (i = 0; i < 10; ++i) {
    sprintf(filename, "/scratch/HIGGS/HIGGS%03d.txt", i);
    file = fopen(filename, "r");
    for (j = 0; j < 100000; ++j) {
      fgets(line, 1000, file);
      ptr = strtok(line, ",\n");
      holder[0] = atof(ptr);
      for (k = 1; k < 29; ++k) {
        ptr = strtok(NULL, ",\n");
        holder[k] = atof(ptr);
      }
      for (k = 0; k < num_features; ++k)
        data[100000 * i + j][k] = holder[feature_list[k] + 1];
      data[j][num_features] = holder[0];
    }
    fclose(file);
  }
  return data;
}


x86 assembly (clang, -O0):
<ParHIGGS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x32cf,-0x10(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x440(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e5 <ParHIGGS+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x440(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a6 <ParHIGGS+0x36>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1363 <ParHIGGS+0x1f3>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xdfc(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x186a0,-0x38(%rbp)
jge    134c <ParHIGGS+0x1dc>
lea    -0x430(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x430(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x530(%rbp)
ff
movl   $0x1,-0x3c(%rbp)
cmpl   $0x1d,-0x3c(%rbp)
jge    12c3 <ParHIGGS+0x153>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd8f(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
call   1030 <atof@plt>
movslq -0x3c(%rbp),%rax
movsd  %xmm0,-0x530(%rbp,%rax,8)
ff ff
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    127b <ParHIGGS+0x10b>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    131e <ParHIGGS+0x1ae>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
cltq
movsd  -0x530(%rbp,%rax,8),%xmm0
ff ff
mov    -0x440(%rbp),%rax
imul   $0x186a0,-0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12ca <ParHIGGS+0x15a>
movsd  -0x530(%rbp),%xmm0
ff
mov    -0x440(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1224 <ParHIGGS+0xb4>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ec <ParHIGGS+0x7c>
mov    -0x440(%rbp),%rax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParHIGGS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x538,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x19678,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rbp,0x8(%rsp)
lea    0x8(,%rbp,8),%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%edi
call   1060 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    $0x32cf,%rbp
jne    11b0 <ParHIGGS+0x40>
mov    0x8(%rsp),%rax
movslq %eax,%rcx
mov    %rcx,0x30(%rsp)
mov    %eax,%r13d
mov    %r13,0x20(%rsp)
and    $0xfffffffe,%r13d
xor    %r14d,%r14d
lea    0xe33(%rip),%rbp
jmp    120d <ParHIGGS+0x9d>
xchg   %ax,%ax
mov    0x10(%rsp),%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%r14
add    $0x1,%r14
cmp    $0xa,%r14
je     1368 <ParHIGGS+0x1f8>
lea    0x40(%rsp),%r12
mov    %r12,%rdi
lea    0xde4(%rip),%rsi
mov    %r14d,%edx
call   1090 <sprintf@plt>
mov    %r12,%rdi
lea    0xdef(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,0x10(%rsp)
mov    %r14,0x18(%rsp)
imul   $0x186a0,%r14,%rax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
jmp    1275 <ParHIGGS+0x105>
xchg   %ax,%ax
mov    (%r15,%r12,8),%rax
mov    0x30(%rsp),%rcx
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%r12
cmp    $0x186a0,%r12
je     11f0 <ParHIGGS+0x80>
lea    0x150(%rsp),%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    0x10(%rsp),%rdx
call   1050 <fgets@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x38(%rsp)
movsd  %xmm0,0x60(%rsp)
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
mov    %rbp,%rsi
call   1080 <strtok@plt>
mov    %rax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x60(%rsp,%r14,8)
add    $0x1,%r14
cmp    $0x1d,%r14
jne    12c0 <ParHIGGS+0x150>
cmpl   $0x0,0x8(%rsp)
jle    1250 <ParHIGGS+0xe0>
mov    0x28(%rsp),%rax
add    %r12,%rax
mov    (%r15,%rax,8),%rax
cmpl   $0x1,0x8(%rsp)
jne    1310 <ParHIGGS+0x1a0>
xor    %ecx,%ecx
jmp    1349 <ParHIGGS+0x1d9>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq (%rbx,%rcx,4),%rdx
movsd  0x68(%rsp,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movslq 0x4(%rbx,%rcx,4),%rdx
movsd  0x68(%rsp,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r13
jne    1320 <ParHIGGS+0x1b0>
testb  $0x1,0x20(%rsp)
je     1250 <ParHIGGS+0xe0>
movslq (%rbx,%rcx,4),%rdx
movsd  0x68(%rsp,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1250 <ParHIGGS+0xe0>
mov    %r15,%rax
add    $0x538,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"/scratch/HIGGS/HIGGS%03d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c",\0A\00"
define double** @ParHIGGS(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [28 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca [1000 x i8]
%12 = alloca i8*
%13 = alloca double**
%14 = alloca [29 x double]
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 13007, i32* %5
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i8* @malloc(i32 %18)
%20 = bitcast i8* %19 to double**
store double** %20, double*** %13
store i32 0, i32* %7
br label %21
21: ; preds = %37, %2
%22 = load i32, i32* %7
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %40
25: ; preds = %21
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call i8* @malloc(i32 %30)
%32 = bitcast i8* %31 to double*
%33 = load double**, double*** %13
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
store double* %32, double** %36
br label %37
37: ; preds = %25
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %21
40: ; preds = %21
store i32 0, i32* %7
br label %41
41: ; preds = %121, %40
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 10
br i1 %43, label %44, label %124
44: ; preds = %41
%45 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%46 = load i32, i32* %7
%47 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %49, i32** %10
store i32 0, i32* %8
br label %50
50: ; preds = %115, %44
%51 = load i32, i32* %8
%52 = icmp slt i32 %51, 100000
br i1 %52, label %53, label %118
53: ; preds = %50
%54 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%55 = load i32*, i32** %10
%56 = call i32 @fgets(i8* %54, i32 1000, i32* %55)
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%58 = call i8* @strtok(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %58, i8** %12
%59 = load i8*, i8** %12
%60 = call double @atof(i8* %59)
%61 = getelementptr inbounds [29 x double], [29 x double]* %14, i64 0, i64 0
store double %60, double* %61
store i32 1, i32* %9
br label %62
62: ; preds = %72, %53
%63 = load i32, i32* %9
%64 = icmp slt i32 %63, 29
br i1 %64, label %65, label %75
65: ; preds = %62
%66 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %66, i8** %12
%67 = load i8*, i8** %12
%68 = call double @atof(i8* %67)
%69 = load i32, i32* %9
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [29 x double], [29 x double]* %14, i64 0, i64 %70
store double %68, double* %71
br label %72
72: ; preds = %65
%73 = load i32, i32* %9
%74 = add nsw i32 %73, 1
store i32 %74, i32* %9
br label %62
75: ; preds = %62
store i32 0, i32* %9
br label %76
76: ; preds = %101, %75
%77 = load i32, i32* %9
%78 = load i32, i32* %4
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %104
80: ; preds = %76
%81 = load i32*, i32** %3
%82 = load i32, i32* %9
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
%85 = load i32, i32* %84
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [29 x double], [29 x double]* %14, i64 0, i64 %87
%89 = load double, double* %88
%90 = load double**, double*** %13
%91 = load i32, i32* %7
%92 = mul nsw i32 100000, %91
%93 = load i32, i32* %8
%94 = add nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double*, double** %90, i64 %95
%97 = load double*, double** %96
%98 = load i32, i32* %9
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
store double %89, double* %100
br label %101
101: ; preds = %80
%102 = load i32, i32* %9
%103 = add nsw i32 %102, 1
store i32 %103, i32* %9
br label %76
104: ; preds = %76
%105 = getelementptr inbounds [29 x double], [29 x double]* %14, i64 0, i64 0
%106 = load double, double* %105
%107 = load double**, double*** %13
%108 = load i32, i32* %8
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double*, double** %107, i64 %109
%111 = load double*, double** %110
%112 = load i32, i32* %4
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
store double %106, double* %114
br label %115
115: ; preds = %104
%116 = load i32, i32* %8
%117 = add nsw i32 %116, 1
store i32 %117, i32* %8
br label %50
118: ; preds = %50
%119 = load i32*, i32** %10
%120 = call i32 @fclose(i32* %119)
br label %121
121: ; preds = %118
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 1
store i32 %123, i32* %7
br label %41
124: ; preds = %41
%125 = load double**, double*** %13
ret double** %125
}

LLVM IR (-O2):
@.str = [29 x i8] c"/scratch/HIGGS/HIGGS%03d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c",\0A\00"
define noalias double** @ParHIGGS(i32* nocapture %0, i32 %1) {
%3 = alloca [28 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [29 x double]
%6 = getelementptr inbounds [28 x i8], [28 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = tail call dereferenceable_or_null(104056) i8* @malloc(i32 104056)
%9 = bitcast i8* %8 to double**
%10 = shl i32 %1, 3
%11 = add i32 %10, 8
br label %12
12: ; preds = %2, %12
%13 = phi i64 [ 0, %2 ], [ %17, %12 ]
%14 = tail call i8* @malloc(i32 %11)
%15 = getelementptr inbounds double*, double** %9, i64 %13
%16 = bitcast double** %15 to i8**
store i8* %14, i8** %16
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, 13007
br i1 %18, label %19, label %12
19: ; preds = %12
%20 = bitcast [29 x double]* %5 to i8*
%21 = getelementptr inbounds [29 x double], [29 x double]* %5, i64 0, i64 0
%22 = icmp sgt i32 %1, 0
%23 = sext i32 %1 to i64
%24 = zext i32 %1 to i64
%25 = and i64 %24, 1
%26 = icmp eq i32 %1, 1
%27 = and i64 %24, 4294967294
%28 = icmp eq i64 %25, 0
br label %29
29: ; preds = %19, %89
%30 = phi i64 [ 0, %19 ], [ %91, %89 ]
%31 = trunc i64 %30 to i32
%32 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = mul nuw nsw i64 %30, 100000
br label %35
35: ; preds = %29, %83
%36 = phi i64 [ 0, %29 ], [ %87, %83 ]
%37 = call i32 @fgets(i8* %7, i32 1000, i32* %33)
%38 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = call double @atof(i8* %38)
store double %39, double* %21
br label %45
40: ; preds = %45
br i1 %22, label %41, label %83
41: ; preds = %40
%42 = add nuw nsw i64 %36, %34
%43 = getelementptr inbounds double*, double** %9, i64 %42
%44 = load double*, double** %43
br i1 %26, label %73, label %52
45: ; preds = %35, %45
%46 = phi i64 [ 1, %35 ], [ %50, %45 ]
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%48 = call double @atof(i8* %47)
%49 = getelementptr inbounds [29 x double], [29 x double]* %5, i64 0, i64 %46
store double %48, double* %49
%50 = add nuw nsw i64 %46, 1
%51 = icmp eq i64 %50, 29
br i1 %51, label %40, label %45
52: ; preds = %41, %52
%53 = phi i64 [ %70, %52 ], [ 0, %41 ]
%54 = phi i64 [ %71, %52 ], [ 0, %41 ]
%55 = getelementptr inbounds i32, i32* %0, i64 %53
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [29 x double], [29 x double]* %5, i64 0, i64 %58
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %44, i64 %53
store double %60, double* %61
%62 = or i64 %53, 1
%63 = getelementptr inbounds i32, i32* %0, i64 %62
%64 = load i32, i32* %63
%65 = add nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [29 x double], [29 x double]* %5, i64 0, i64 %66
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %44, i64 %62
store double %68, double* %69
%70 = add nuw nsw i64 %53, 2
%71 = add i64 %54, 2
%72 = icmp eq i64 %71, %27
br i1 %72, label %73, label %52
73: ; preds = %52, %41
%74 = phi i64 [ 0, %41 ], [ %70, %52 ]
br i1 %28, label %83, label %75
75: ; preds = %73
%76 = getelementptr inbounds i32, i32* %0, i64 %74
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [29 x double], [29 x double]* %5, i64 0, i64 %79
%81 = load double, double* %80
%82 = getelementptr inbounds double, double* %44, i64 %74
store double %81, double* %82
br label %83
83: ; preds = %75, %73, %40
%84 = getelementptr inbounds double*, double** %9, i64 %36
%85 = load double*, double** %84
%86 = getelementptr inbounds double, double* %85, i64 %23
store double %39, double* %86
%87 = add nuw nsw i64 %36, 1
%88 = icmp eq i64 %87, 100000
br i1 %88, label %89, label %35
89: ; preds = %83
%90 = call i32 @fclose(i32* %33)
%91 = add nuw nsw i64 %30, 1
%92 = icmp eq i64 %91, 10
br i1 %92, label %93, label %29
93: ; preds = %89
ret double** %9
}