#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fileerror(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *openandfindlastbeefens(char *, char *);
int /*<<< orphan*/ printf(char *, double);
double sq(double);
double sqrt(double);
int /*<<< orphan*/ stderr;
scalar_t__ strstr(char *, char *);
double strtod(char *, int /*<<< orphan*/ *);
int strtol(scalar_t__, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  char buf[65536];
  double *samples;
  FILE *dftout;
  double d, e;
  int nsamples;
  if (argc < 3) {
    fprintf(stderr, "usage: %s factor1 outputfile1 ... factorN outputfileN\n",
            argv[0]);
    return 1;
  }
  dftout = openandfindlastbeefens(argv[2], buf);
  nsamples = strtol(strstr(buf, "BEEFens") + 7, NULL, 10);
  samples = (double *)malloc(nsamples * sizeof(double));
  if (!samples) {
    fclose(dftout);
    fputs("not enough memory for ensemble energies\n", stderr);
    return 2;
  }
  d = strtod(argv[1], NULL);
  for (int j = 0; j < nsamples; j++) {
    if (!fgets(buf, 65536, dftout))
      fileerror(argv[2], dftout);
    samples[j] = d * strtod(buf, NULL);
  }
  fclose(dftout);
  for (int i = 3; i < argc; i += 2) {
    d = strtod(argv[i], NULL);
    dftout = openandfindlastbeefens(argv[i + 1], buf);
    for (int j = 0; j < nsamples; j++) {
      if (!fgets(buf, 65536, dftout))
        fileerror(argv[i + 1], dftout);
      samples[j] += d * strtod(buf, NULL);
    }
    fclose(dftout);
  }
  d = samples[0];
  for (int i = 1; i < nsamples; i++)
    d += samples[i];
  d /= (double)nsamples;
  e = sq(samples[0] - d);
  for (int i = 1; i < nsamples; i++)
    e += sq(samples[i] - d);
  free(samples);
  printf("%.5g standard deviation\n", sqrt(e / nsamples));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10060,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    122b <main+0x4b>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    160a <main+0x42a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x10010(%rbp),%rsi
call   10d0 <openandfindlastbeefens@plt>
mov    %rax,-0x10020(%rbp)
lea    -0x10010(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1100 <strstr@plt>
mov    %rax,%rdi
add    $0x7,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
mov    %eax,-0x10034(%rbp)
movslq -0x10034(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x10018(%rbp)
cmpq   $0x0,-0x10018(%rbp)
jne    12c8 <main+0xe8>
mov    -0x10020(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
lea    0xd88(%rip),%rdi
call   1070 <fputs@plt>
movl   $0x2,-0x4(%rbp)
jmp    160a <main+0x42a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x10028(%rbp)
ff
movl   $0x0,-0x10038(%rbp)
mov    -0x10038(%rbp),%eax
cmp    -0x10034(%rbp),%eax
jge    1388 <main+0x1a8>
lea    -0x10010(%rbp),%rdi
mov    -0x10020(%rbp),%rdx
mov    $0x10000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%eax
jne    1332 <main+0x152>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10020(%rbp),%rsi
call   10f0 <fileerror@plt>
movsd  -0x10028(%rbp),%xmm0
ff
movsd  %xmm0,-0x10050(%rbp)
ff
lea    -0x10010(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movaps %xmm0,%xmm1
movsd  -0x10050(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x10018(%rbp),%rax
movslq -0x10038(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10038(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10038(%rbp)
jmp    12eb <main+0x10b>
mov    -0x10020(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x3,-0x1003c(%rbp)
mov    -0x1003c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14d0 <main+0x2f0>
mov    -0x10(%rbp),%rax
movslq -0x1003c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x10028(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    -0x1003c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x10010(%rbp),%rsi
call   10d0 <openandfindlastbeefens@plt>
mov    %rax,-0x10020(%rbp)
movl   $0x0,-0x10040(%rbp)
mov    -0x10040(%rbp),%eax
cmp    -0x10034(%rbp),%eax
jge    14b0 <main+0x2d0>
lea    -0x10010(%rbp),%rdi
mov    -0x10020(%rbp),%rdx
mov    $0x10000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%eax
jne    1451 <main+0x271>
mov    -0x10(%rbp),%rax
mov    -0x1003c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10020(%rbp),%rsi
call   10f0 <fileerror@plt>
movsd  -0x10028(%rbp),%xmm0
ff
movsd  %xmm0,-0x10058(%rbp)
ff
lea    -0x10010(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movaps %xmm0,%xmm2
movsd  -0x10058(%rbp),%xmm0
ff
mov    -0x10018(%rbp),%rax
movslq -0x10040(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10040(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10040(%rbp)
jmp    13fe <main+0x21e>
mov    -0x10020(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1003c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1003c(%rbp)
jmp    139e <main+0x1be>
mov    -0x10018(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x10028(%rbp)
ff
movl   $0x1,-0x10044(%rbp)
mov    -0x10044(%rbp),%eax
cmp    -0x10034(%rbp),%eax
jge    1536 <main+0x356>
mov    -0x10018(%rbp),%rax
movslq -0x10044(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x10028(%rbp),%xmm0
ff
movsd  %xmm0,-0x10028(%rbp)
ff
mov    -0x10044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10044(%rbp)
jmp    14ed <main+0x30d>
cvtsi2sdl -0x10034(%rbp),%xmm1
ff
movsd  -0x10028(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10028(%rbp)
ff
mov    -0x10018(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x10028(%rbp),%xmm0
ff
call   10c0 <sq@plt>
movsd  %xmm0,-0x10030(%rbp)
ff
movl   $0x1,-0x10048(%rbp)
mov    -0x10048(%rbp),%eax
cmp    -0x10034(%rbp),%eax
jge    15d2 <main+0x3f2>
mov    -0x10018(%rbp),%rax
movslq -0x10048(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x10028(%rbp),%xmm0
ff
call   10c0 <sq@plt>
addsd  -0x10030(%rbp),%xmm0
ff
movsd  %xmm0,-0x10030(%rbp)
ff
mov    -0x10048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10048(%rbp)
jmp    157c <main+0x39c>
mov    -0x10018(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x10030(%rbp),%xmm0
ff
cvtsi2sdl -0x10034(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
call   10e0 <sqrt@plt>
lea    0xa6a(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10028,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jg     121c <main+0x3c>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xdf3(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    1533 <main+0x353>
mov    %edi,0x8(%rsp)
mov    0x10(%rbp),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   10d0 <openandfindlastbeefens@plt>
mov    %rax,%r14
lea    0xdfc(%rip),%rsi
mov    %rbx,%rdi
call   1100 <strstr@plt>
lea    0x7(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
mov    %eax,%r15d
lea    0x0(,%r15,8),%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13fe <main+0x21e>
mov    %rax,%r13
mov    %rbp,0x10(%rsp)
mov    0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,(%rsp)
mov    %r15d,%r12d
test   %r15d,%r15d
jle    12e6 <main+0x106>
xor    %ebp,%ebp
lea    0x20(%rsp),%rbx
jmp    12bf <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
je     12e6 <main+0x106>
mov    %rbx,%rdi
mov    $0x10000,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %eax,%eax
jne    12a0 <main+0xc0>
mov    0x10(%rsp),%rax
mov    0x10(%rax),%rdi
mov    %r14,%rsi
call   10f0 <fileerror@plt>
jmp    12a0 <main+0xc0>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%eax
cmp    $0x4,%eax
jl     13be <main+0x1de>
mov    %eax,%eax
mov    %rax,0x8(%rsp)
mov    $0x3,%r14d
lea    0x20(%rsp),%rbp
mov    %r15,0x18(%rsp)
jmp    133c <main+0x15c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x2,%r14
cmp    0x8(%rsp),%r14
mov    0x18(%rsp),%r15
jae    13be <main+0x1de>
mov    0x10(%rsp),%rbx
mov    (%rbx,%r14,8),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,(%rsp)
mov    0x8(%rbx,%r14,8),%rdi
mov    %rbp,%rsi
call   10d0 <openandfindlastbeefens@plt>
mov    %rax,%rbx
test   %r15d,%r15d
jle    1320 <main+0x140>
xor    %r15d,%r15d
jmp    1396 <main+0x1b6>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
mulsd  (%rsp),%xmm0
addsd  0x0(%r13,%r15,8),%xmm0
movsd  %xmm0,0x0(%r13,%r15,8)
add    $0x1,%r15
cmp    %r15,%r12
je     1320 <main+0x140>
mov    %rbp,%rdi
mov    $0x10000,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %eax,%eax
jne    1370 <main+0x190>
mov    0x10(%rsp),%rax
mov    0x8(%rax,%r14,8),%rdi
mov    %rbx,%rsi
call   10f0 <fileerror@plt>
jmp    1370 <main+0x190>
movsd  0x0(%r13),%xmm0
movapd %xmm0,%xmm1
cmp    $0x2,%r15d
jl     149e <main+0x2be>
lea    -0x1(%r12),%rdx
lea    -0x2(%r12),%rcx
mov    %edx,%eax
and    $0x7,%eax
cmp    $0x7,%rcx
jae    1425 <main+0x245>
mov    $0x1,%ecx
movapd %xmm0,%xmm1
test   %rax,%rax
jne    147a <main+0x29a>
jmp    149e <main+0x2be>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%esi
lea    0xc29(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x2,%eax
jmp    1533 <main+0x353>
and    $0xfffffffffffffff8,%rdx
xor    %ecx,%ecx
movapd %xmm0,%xmm1
nop
addsd  0x8(%r13,%rcx,8),%xmm1
addsd  0x10(%r13,%rcx,8),%xmm1
addsd  0x18(%r13,%rcx,8),%xmm1
addsd  0x20(%r13,%rcx,8),%xmm1
addsd  0x28(%r13,%rcx,8),%xmm1
addsd  0x30(%r13,%rcx,8),%xmm1
addsd  0x38(%r13,%rcx,8),%xmm1
addsd  0x40(%r13,%rcx,8),%xmm1
add    $0x8,%rcx
cmp    %rcx,%rdx
jne    1430 <main+0x250>
add    $0x1,%rcx
test   %rax,%rax
je     149e <main+0x2be>
lea    0x0(,%rcx,8),%rcx
add    %r13,%rcx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
addsd  (%rcx,%rdx,8),%xmm1
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1490 <main+0x2b0>
cvtsi2sd %r15d,%xmm2
movsd  %xmm2,0x8(%rsp)
divsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
subsd  %xmm1,%xmm0
call   10c0 <sq@plt>
cmp    $0x2,%r15d
movsd  %xmm0,(%rsp)
jl     14f9 <main+0x319>
mov    $0x1,%ebx
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
subsd  0x10(%rsp),%xmm0
call   10c0 <sq@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    14d0 <main+0x2f0>
mov    %r13,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm1
divsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     1520 <main+0x340>
sqrtsd %xmm0,%xmm0
jmp    1525 <main+0x345>
call   10e0 <sqrt@plt>
lea    0xb3c(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"usage: %s factor1 outputfile1 ... factorN outputfileN\0A\00"
@.str.1 = [8 x i8] c"BEEFens\00"
@.str.2 = [41 x i8] c"not enough memory for ensemble energies\0A\00"
@.str.3 = [25 x i8] c"%.5g standard deviation\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [65536 x i8]
%7 = alloca double*
%8 = alloca i32*
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %196
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%30 = call i32* @openandfindlastbeefens(i8* %28, i8* %29)
store i32* %30, i32** %8
%31 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%33 = add nsw i64 %32, 7
%34 = call i32 @strtol(i64 %33, i32* null, i32 10)
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = trunc i64 %37 to i32
%39 = call i64 @malloc(i32 %38)
%40 = inttoptr i64 %39 to double*
store double* %40, double** %7
%41 = load double*, double** %7
%42 = icmp ne double* %41, null
br i1 %42, label %48, label %43
43: ; preds = %25
%44 = load i32*, i32** %8
%45 = call i32 @fclose(i32* %44)
%46 = load i32, i32* @stderr
%47 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %46)
store i32 2, i32* %3
br label %196
48: ; preds = %25
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call double @strtod(i8* %51, i32* null)
store double %52, double* %9
store i32 0, i32* %12
br label %53
53: ; preds = %77, %48
%54 = load i32, i32* %12
%55 = load i32, i32* %11
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %80
57: ; preds = %53
%58 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%59 = load i32*, i32** %8
%60 = call i32 @fgets(i8* %58, i32 65536, i32* %59)
%61 = icmp ne i32 %60, 0
br i1 %61, label %68, label %62
62: ; preds = %57
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = load i32*, i32** %8
%67 = call i32 @fileerror(i8* %65, i32* %66)
br label %68
68: ; preds = %62, %57
%69 = load double, double* %9
%70 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%71 = call double @strtod(i8* %70, i32* null)
%72 = fmul double %69, %71
%73 = load double*, double** %7
%74 = load i32, i32* %12
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double %72, double* %76
br label %77
77: ; preds = %68
%78 = load i32, i32* %12
%79 = add nsw i32 %78, 1
store i32 %79, i32* %12
br label %53
80: ; preds = %53
%81 = load i32*, i32** %8
%82 = call i32 @fclose(i32* %81)
store i32 3, i32* %13
br label %83
83: ; preds = %136, %80
%84 = load i32, i32* %13
%85 = load i32, i32* %4
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %139
87: ; preds = %83
%88 = load i8**, i8*** %5
%89 = load i32, i32* %13
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %88, i64 %90
%92 = load i8*, i8** %91
%93 = call double @strtod(i8* %92, i32* null)
store double %93, double* %9
%94 = load i8**, i8*** %5
%95 = load i32, i32* %13
%96 = add nsw i32 %95, 1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %94, i64 %97
%99 = load i8*, i8** %98
%100 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%101 = call i32* @openandfindlastbeefens(i8* %99, i8* %100)
store i32* %101, i32** %8
store i32 0, i32* %14
br label %102
102: ; preds = %130, %87
%103 = load i32, i32* %14
%104 = load i32, i32* %11
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %133
106: ; preds = %102
%107 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%108 = load i32*, i32** %8
%109 = call i32 @fgets(i8* %107, i32 65536, i32* %108)
%110 = icmp ne i32 %109, 0
br i1 %110, label %120, label %111
111: ; preds = %106
%112 = load i8**, i8*** %5
%113 = load i32, i32* %13
%114 = add nsw i32 %113, 1
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %112, i64 %115
%117 = load i8*, i8** %116
%118 = load i32*, i32** %8
%119 = call i32 @fileerror(i8* %117, i32* %118)
br label %120
120: ; preds = %111, %106
%121 = load double, double* %9
%122 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%123 = call double @strtod(i8* %122, i32* null)
%124 = load double*, double** %7
%125 = load i32, i32* %14
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %124, i64 %126
%128 = load double, double* %127
%129 = call double @llvm.fmuladd.f64(double %121, double %123, double %128)
store double %129, double* %127
br label %130
130: ; preds = %120
%131 = load i32, i32* %14
%132 = add nsw i32 %131, 1
store i32 %132, i32* %14
br label %102
133: ; preds = %102
%134 = load i32*, i32** %8
%135 = call i32 @fclose(i32* %134)
br label %136
136: ; preds = %133
%137 = load i32, i32* %13
%138 = add nsw i32 %137, 2
store i32 %138, i32* %13
br label %83
139: ; preds = %83
%140 = load double*, double** %7
%141 = getelementptr inbounds double, double* %140, i64 0
%142 = load double, double* %141
store double %142, double* %9
store i32 1, i32* %15
br label %143
143: ; preds = %155, %139
%144 = load i32, i32* %15
%145 = load i32, i32* %11
%146 = icmp slt i32 %144, %145
br i1 %146, label %147, label %158
147: ; preds = %143
%148 = load double*, double** %7
%149 = load i32, i32* %15
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %148, i64 %150
%152 = load double, double* %151
%153 = load double, double* %9
%154 = fadd double %153, %152
store double %154, double* %9
br label %155
155: ; preds = %147
%156 = load i32, i32* %15
%157 = add nsw i32 %156, 1
store i32 %157, i32* %15
br label %143
158: ; preds = %143
%159 = load i32, i32* %11
%160 = sitofp i32 %159 to double
%161 = load double, double* %9
%162 = fdiv double %161, %160
store double %162, double* %9
%163 = load double*, double** %7
%164 = getelementptr inbounds double, double* %163, i64 0
%165 = load double, double* %164
%166 = load double, double* %9
%167 = fsub double %165, %166
%168 = call double @sq(double %167)
store double %168, double* %10
store i32 1, i32* %16
br label %169
169: ; preds = %184, %158
%170 = load i32, i32* %16
%171 = load i32, i32* %11
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %187
173: ; preds = %169
%174 = load double*, double** %7
%175 = load i32, i32* %16
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds double, double* %174, i64 %176
%178 = load double, double* %177
%179 = load double, double* %9
%180 = fsub double %178, %179
%181 = call double @sq(double %180)
%182 = load double, double* %10
%183 = fadd double %182, %181
store double %183, double* %10
br label %184
184: ; preds = %173
%185 = load i32, i32* %16
%186 = add nsw i32 %185, 1
store i32 %186, i32* %16
br label %169
187: ; preds = %169
%188 = load double*, double** %7
%189 = call i32 @free(double* %188)
%190 = load double, double* %10
%191 = load i32, i32* %11
%192 = sitofp i32 %191 to double
%193 = fdiv double %190, %192
%194 = call double @sqrt(double %193)
%195 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %194)
store i32 0, i32* %3
br label %196
196: ; preds = %187, %43, %19
%197 = load i32, i32* %3
ret i32 %197
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"usage: %s factor1 outputfile1 ... factorN outputfileN\0A\00"
@.str.1 = [8 x i8] c"BEEFens\00"
@.str.2 = [41 x i8] c"not enough memory for ensemble energies\0A\00"
@.str.3 = [25 x i8] c"%.5g standard deviation\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %166
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = call i32* @openandfindlastbeefens(i8* %12, i8* %4)
%14 = call i64 @strstr(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = add nsw i64 %14, 7
%16 = call i32 @strtol(i64 %15, i32* null, i32 10)
%17 = shl i32 %16, 3
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %25
21: ; preds = %10
%22 = call i32 @fclose(i32* %13)
%23 = load i32, i32* @stderr
%24 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %166
25: ; preds = %10
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call double @strtod(i8* nocapture %27, i32* null)
%29 = icmp sgt i32 %16, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = zext i32 %16 to i64
br label %38
32: ; preds = %45, %25
%33 = call i32 @fclose(i32* %13)
%34 = icmp sgt i32 %0, 3
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = zext i32 %0 to i64
%37 = zext i32 %16 to i64
br label %62
38: ; preds = %30, %45
%39 = phi i64 [ 0, %30 ], [ %49, %45 ]
%40 = call i32 @fgets(i8* %4, i32 65536, i32* %13)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8*, i8** %11
%44 = call i32 @fileerror(i8* %43, i32* %13)
br label %45
45: ; preds = %42, %38
%46 = call double @strtod(i8* nocapture %4, i32* null)
%47 = fmul double %28, %46
%48 = getelementptr inbounds double, double* %19, i64 %39
store double %47, double* %48
%49 = add nuw nsw i64 %39, 1
%50 = icmp eq i64 %49, %31
br i1 %50, label %32, label %38
51: ; preds = %71, %32
%52 = load double, double* %19
%53 = icmp sgt i32 %16, 1
br i1 %53, label %54, label %104
54: ; preds = %51
%55 = zext i32 %16 to i64
%56 = add nsw i64 %55, -1
%57 = add nsw i64 %55, -2
%58 = and i64 %56, 7
%59 = icmp ult i64 %57, 7
br i1 %59, label %89, label %60
60: ; preds = %54
%61 = and i64 %56, -8
br label %112
62: ; preds = %35, %71
%63 = phi i64 [ 3, %35 ], [ %73, %71 ]
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = call double @strtod(i8* nocapture %65, i32* null)
%67 = add nuw nsw i64 %63, 1
%68 = getelementptr inbounds i8*, i8** %1, i64 %67
%69 = load i8*, i8** %68
%70 = call i32* @openandfindlastbeefens(i8* %69, i8* %4)
br i1 %29, label %75, label %71
71: ; preds = %82, %62
%72 = call i32 @fclose(i32* %70)
%73 = add nuw nsw i64 %63, 2
%74 = icmp ult i64 %73, %36
br i1 %74, label %62, label %51
75: ; preds = %62, %82
%76 = phi i64 [ %87, %82 ], [ 0, %62 ]
%77 = call i32 @fgets(i8* %4, i32 65536, i32* %70)
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load i8*, i8** %68
%81 = call i32 @fileerror(i8* %80, i32* %70)
br label %82
82: ; preds = %79, %75
%83 = call double @strtod(i8* nocapture %4, i32* null)
%84 = getelementptr inbounds double, double* %19, i64 %76
%85 = load double, double* %84
%86 = call double @llvm.fmuladd.f64(double %66, double %83, double %85)
store double %86, double* %84
%87 = add nuw nsw i64 %76, 1
%88 = icmp eq i64 %87, %37
br i1 %88, label %71, label %75
89: ; preds = %112, %54
%90 = phi double [ undef, %54 ], [ %146, %112 ]
%91 = phi i64 [ 1, %54 ], [ %147, %112 ]
%92 = phi double [ %52, %54 ], [ %146, %112 ]
%93 = icmp eq i64 %58, 0
br i1 %93, label %104, label %94
94: ; preds = %89, %94
%95 = phi i64 [ %101, %94 ], [ %91, %89 ]
%96 = phi double [ %100, %94 ], [ %92, %89 ]
%97 = phi i64 [ %102, %94 ], [ 0, %89 ]
%98 = getelementptr inbounds double, double* %19, i64 %95
%99 = load double, double* %98
%100 = fadd double %96, %99
%101 = add nuw nsw i64 %95, 1
%102 = add i64 %97, 1
%103 = icmp eq i64 %102, %58
br i1 %103, label %104, label %94
104: ; preds = %89, %94, %51
%105 = phi double [ %52, %51 ], [ %90, %89 ], [ %100, %94 ]
%106 = sitofp i32 %16 to double
%107 = fdiv double %105, %106
%108 = fsub double %52, %107
%109 = call double @sq(double %108)
br i1 %53, label %110, label %150
110: ; preds = %104
%111 = zext i32 %16 to i64
br label %156
112: ; preds = %112, %60
%113 = phi i64 [ 1, %60 ], [ %147, %112 ]
%114 = phi double [ %52, %60 ], [ %146, %112 ]
%115 = phi i64 [ 0, %60 ], [ %148, %112 ]
%116 = getelementptr inbounds double, double* %19, i64 %113
%117 = load double, double* %116
%118 = fadd double %114, %117
%119 = add nuw nsw i64 %113, 1
%120 = getelementptr inbounds double, double* %19, i64 %119
%121 = load double, double* %120
%122 = fadd double %118, %121
%123 = add nuw nsw i64 %113, 2
%124 = getelementptr inbounds double, double* %19, i64 %123
%125 = load double, double* %124
%126 = fadd double %122, %125
%127 = add nuw nsw i64 %113, 3
%128 = getelementptr inbounds double, double* %19, i64 %127
%129 = load double, double* %128
%130 = fadd double %126, %129
%131 = add nuw nsw i64 %113, 4
%132 = getelementptr inbounds double, double* %19, i64 %131
%133 = load double, double* %132
%134 = fadd double %130, %133
%135 = add nuw nsw i64 %113, 5
%136 = getelementptr inbounds double, double* %19, i64 %135
%137 = load double, double* %136
%138 = fadd double %134, %137
%139 = add nuw nsw i64 %113, 6
%140 = getelementptr inbounds double, double* %19, i64 %139
%141 = load double, double* %140
%142 = fadd double %138, %141
%143 = add nuw nsw i64 %113, 7
%144 = getelementptr inbounds double, double* %19, i64 %143
%145 = load double, double* %144
%146 = fadd double %142, %145
%147 = add nuw nsw i64 %113, 8
%148 = add i64 %115, 8
%149 = icmp eq i64 %148, %61
br i1 %149, label %89, label %112
150: ; preds = %156, %104
%151 = phi double [ %109, %104 ], [ %163, %156 ]
%152 = call i32 @free(double* %19)
%153 = fdiv double %151, %106
%154 = call double @sqrt(double %153)
%155 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %154)
br label %166
156: ; preds = %110, %156
%157 = phi i64 [ 1, %110 ], [ %164, %156 ]
%158 = phi double [ %109, %110 ], [ %163, %156 ]
%159 = getelementptr inbounds double, double* %19, i64 %157
%160 = load double, double* %159
%161 = fsub double %160, %107
%162 = call double @sq(double %161)
%163 = fadd double %158, %162
%164 = add nuw nsw i64 %157, 1
%165 = icmp eq i64 %164, %111
br i1 %165, label %150, label %156
166: ; preds = %150, %21, %6
%167 = phi i32 [ 1, %6 ], [ 0, %150 ], [ 2, %21 ]
ret i32 %167
}