#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*/ exit(int);
double fabs(double);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ isspace(char);
double log2(double);
int /*<<< orphan*/ stderr;
int strlen(char *);
char *strtok(char *, char *);
void load_probs_file(char *fname, int len, void *r) {
  FILE *f = fopen(fname, "r");
  char buf[1024];
  double(*res)[len][4];
  int linenum;
  int blank_lines;
  res = r;
  if (!f) {
    fprintf(stderr, "Unable to open file '%s'. Exiting...\n", fname);
    exit(1);
  }
  linenum = 0;
  blank_lines = 0;
  while (!feof(f)) {
    int l;
    char *p;
    int i;
    if (!fgets(buf, 1024, f))
      break;
    if (buf[0] == '#') {
      blank_lines++;
      continue;
    }
    l = strlen(buf);
    i = 0;
    for (p = strtok(buf, " \t"); p; p = strtok(NULL, " \t")) {
      int j;
      int blank_field = 1;
      for (j = 0; p[j] && blank_field; j++)
        if (!isspace(p[j]))
          blank_field = 0;
      if (blank_field)
        continue;
      if (i >= 4) {
        fprintf(stderr,
                "Probs file '%s', line %d: too many probabilities.  Got %d, "
                "expect %d. Exiting...\n",
                fname, linenum + blank_lines + 1, i + 1, 4);
        exit(1);
      }
      if (linenum >= len) {
        fprintf(stderr, "Probs file '%s': too many lines.  Exiting...\n",
                fname);
        exit(1);
      }
      (*res)[linenum][i] = atof(p);
      i++;
    }
    if (i == 0) {
      blank_lines++;
      continue;
    }
    if (i != 4) {
      fprintf(stderr,
              "Probs file '%s', line %d: too few probabilities.  Exiting...\n",
              fname, linenum + blank_lines + 1);
      exit(1);
    }
    {
      double sum = 0;
      for (i = 0; i < 4; i++) {
        sum += (*res)[linenum][i];
        (*res)[linenum][i] = -log2((*res)[linenum][i]);
      }
      if (fabs(1.0 - sum) > 0.001) {
        fprintf(stderr,
                "Probs file '%s', line %d: Probabilities don't sum to 1.  "
                "Sum=%f. Exiting...\n",
                fname, linenum + blank_lines + 1, sum);
        exit(1);
      }
    }
    linenum++;
  }
  if (linenum != len) {
    fprintf(stderr,
            "Probs file '%s': too few lines. Got %d, expect %d. Exiting...\n",
            fname, linenum, len);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<load_probs_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1205 <load_probs_file+0x65>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x42c(%rbp)
movl   $0x0,-0x430(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1237 <load_probs_file+0x97>
jmp    15f3 <load_probs_file+0x453>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%eax
jne    125a <load_probs_file+0xba>
jmp    15f3 <load_probs_file+0x453>
movsbl -0x420(%rbp),%eax
cmp    $0x23,%eax
jne    127e <load_probs_file+0xde>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    1219 <load_probs_file+0x79>
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x434(%rbp)
movl   $0x0,-0x444(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
je     144f <load_probs_file+0x2af>
movl   $0x1,-0x44c(%rbp)
movl   $0x0,-0x448(%rbp)
mov    -0x440(%rbp),%rax
movslq -0x448(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x459(%rbp)
je     1309 <load_probs_file+0x169>
cmpl   $0x0,-0x44c(%rbp)
setne  %al
mov    %al,-0x459(%rbp)
mov    -0x459(%rbp),%al
test   $0x1,%al
jne    131c <load_probs_file+0x17c>
jmp    135f <load_probs_file+0x1bf>
mov    -0x440(%rbp),%rax
movslq -0x448(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    1346 <load_probs_file+0x1a6>
movl   $0x0,-0x44c(%rbp)
jmp    134b <load_probs_file+0x1ab>
mov    -0x448(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x448(%rbp)
jmp    12d6 <load_probs_file+0x136>
cmpl   $0x0,-0x44c(%rbp)
je     1371 <load_probs_file+0x1d1>
jmp    1433 <load_probs_file+0x293>
cmpl   $0x4,-0x444(%rbp)
jl     13c3 <load_probs_file+0x223>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x42c(%rbp),%ecx
add    -0x430(%rbp),%ecx
add    $0x1,%ecx
mov    -0x444(%rbp),%r8d
add    $0x1,%r8d
lea    0xc9f(%rip),%rsi
mov    $0x4,%r9d
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x42c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     13f7 <load_probs_file+0x257>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x440(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x428(%rbp),%rax
movslq -0x42c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x444(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc0a(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x440(%rbp)
jmp    12b4 <load_probs_file+0x114>
cmpl   $0x0,-0x444(%rbp)
jne    1470 <load_probs_file+0x2d0>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    1219 <load_probs_file+0x79>
cmpl   $0x4,-0x444(%rbp)
je     14b1 <load_probs_file+0x311>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x42c(%rbp),%ecx
add    -0x430(%rbp),%ecx
add    $0x1,%ecx
lea    0xc2b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x458(%rbp)
ff
movl   $0x0,-0x444(%rbp)
cmpl   $0x4,-0x444(%rbp)
jge    1576 <load_probs_file+0x3d6>
mov    -0x428(%rbp),%rax
movslq -0x42c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x444(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x458(%rbp),%xmm0
ff
movsd  %xmm0,-0x458(%rbp)
ff
mov    -0x428(%rbp),%rax
movslq -0x42c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x444(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <log2@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x428(%rbp),%rax
movslq -0x42c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x444(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    14c6 <load_probs_file+0x326>
movsd  0xa8a(%rip),%xmm0
subsd  -0x458(%rbp),%xmm0
ff
movaps 0xa83(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xa67(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    15df <load_probs_file+0x43f>
mov    0x2a36(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x42c(%rbp),%ecx
add    -0x430(%rbp),%ecx
add    $0x1,%ecx
movsd  -0x458(%rbp),%xmm0
ff
lea    0xb3b(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
jmp    1219 <load_probs_file+0x79>
mov    -0x42c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1631 <load_probs_file+0x491>
mov    0x29d7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x42c(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xb36(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_probs_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %rdx,0x38(%rsp)
mov    %esi,0x2c(%rsp)
lea    0xe77(%rip),%rsi
mov    %rdi,0x18(%rsp)
call   10a0 <fopen@plt>
test   %rax,%rax
je     149f <load_probs_file+0x2ff>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <feof@plt>
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
test   %eax,%eax
je     120f <load_probs_file+0x6f>
mov    0x2c(%rsp),%r8d
mov    0x8(%rsp),%rcx
cmp    %r8d,%ecx
jne    14b1 <load_probs_file+0x311>
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x40(%rsp),%rbx
lea    0xe3e(%rip),%r14
xor    %ebp,%ebp
mov    %r15,0x30(%rsp)
jmp    123f <load_probs_file+0x9f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r15,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    11ea <load_probs_file+0x4a>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %eax,%eax
je     11ea <load_probs_file+0x4a>
cmpb   $0x23,0x40(%rsp)
je     1230 <load_probs_file+0x90>
mov    %rbp,0x20(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1420 <load_probs_file+0x280>
mov    %rax,%r15
movslq 0x8(%rsp),%r12
xor    %r13d,%r13d
mov    0x38(%rsp),%rbp
jmp    12a2 <load_probs_file+0x102>
nopl   (%rax)
xor    %edi,%edi
mov    %r14,%rsi
call   10b0 <strtok@plt>
mov    %rax,%r15
test   %rax,%rax
je     1310 <load_probs_file+0x170>
mov    (%r15),%cl
test   %cl,%cl
je     1290 <load_probs_file+0xf0>
lea    0x1(%r15),%rbx
nopl   (%rax)
movsbl %cl,%edi
call   1060 <isspace@plt>
test   %eax,%eax
je     12c7 <load_probs_file+0x127>
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    12b0 <load_probs_file+0x110>
test   %eax,%eax
jne    1290 <load_probs_file+0xf0>
cmp    $0x4,%r13d
jge    1437 <load_probs_file+0x297>
mov    0x8(%rsp),%rax
cmp    0x2c(%rsp),%eax
jge    1479 <load_probs_file+0x2d9>
mov    %r15,%rdi
call   1040 <atof@plt>
movslq %r13d,%rax
mov    %r12,%rcx
shl    $0x5,%rcx
add    %rbp,%rcx
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%r13d
jmp    1290 <load_probs_file+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r13d,%r13d
je     1420 <load_probs_file+0x280>
cmp    $0x4,%r13d
jne    14d7 <load_probs_file+0x337>
shl    $0x5,%r12
mov    0x38(%rsp),%rbx
movsd  (%rbx,%r12,1),%xmm0
movapd %xmm0,%xmm1
addsd  0xcf2(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
call   1030 <log2@plt>
movapd 0xcaf(%rip),%xmm1
xorpd  %xmm1,%xmm0
movlpd %xmm0,(%rbx,%r12,1)
movsd  0x8(%rbx,%r12,1),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1030 <log2@plt>
xorpd  0xc81(%rip),%xmm0
movlpd %xmm0,0x8(%rbx,%r12,1)
movsd  0x10(%rbx,%r12,1),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1030 <log2@plt>
xorpd  0xc56(%rip),%xmm0
movlpd %xmm0,0x10(%rbx,%r12,1)
movsd  0x18(%rbx,%r12,1),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1030 <log2@plt>
movsd  0x10(%rsp),%xmm1
xorpd  0xc25(%rip),%xmm0
movlpd %xmm0,0x18(%rbx,%r12,1)
movsd  0xc36(%rip),%xmm0
subsd  %xmm1,%xmm0
andpd  0xc1a(%rip),%xmm0
ucomisd 0xc2a(%rip),%xmm0
ja     150c <load_probs_file+0x36c>
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    0x30(%rsp),%r15
mov    0x20(%rsp),%rbp
jmp    142d <load_probs_file+0x28d>
nopl   (%rax)
mov    0x20(%rsp),%rbp
add    $0x1,%ebp
mov    0x30(%rsp),%r15
lea    0x40(%rsp),%rbx
jmp    1233 <load_probs_file+0x93>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    0x20(%rsp),%rcx
add    %eax,%ecx
add    $0x1,%ecx
add    $0x1,%r13d
lea    0xc09(%rip),%rsi
mov    0x18(%rsp),%rdx
mov    %r13d,%r8d
mov    $0x4,%r9d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
lea    0xc2c(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
lea    0xb8b(%rip),%rsi
jmp    1489 <load_probs_file+0x2e9>
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
lea    0xcad(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    0x20(%rsp),%rcx
add    %eax,%ecx
add    $0x1,%ecx
lea    0xbed(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2acd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    0x20(%rsp),%rcx
add    %eax,%ecx
add    $0x1,%ecx
lea    0xbf6(%rip),%rsi
mov    0x18(%rsp),%rdx
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Unable to open file '%s'. Exiting...\0A\00"
@.str.2 = [3 x i8] c" \09\00"
@.str.3 = [82 x i8] c"Probs file '%s', line %d: too many probabilities. Got %d, expect %d. Exiting...\0A\00"
@.str.4 = [46 x i8] c"Probs file '%s': too many lines. Exiting...\0A\00"
@.str.5 = [62 x i8] c"Probs file '%s', line %d: too few probabilities. Exiting...\0A\00"
@.str.6 = [77 x i8] c"Probs file '%s', line %d: Probabilities don't sum to 1. Sum=%f. Exiting...\0A\00"
@.str.7 = [63 x i8] c"Probs file '%s': too few lines. Got %d, expect %d. Exiting...\0A\00"
define void @load_probs_file(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [1024 x i8]
%9 = alloca [4 x double]*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%18 = load i8*, i8** %4
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = load i8*, i8** %6
%23 = bitcast i8* %22 to [4 x double]*
store [4 x double]* %23, [4 x double]** %9
%24 = load i32*, i32** %7
%25 = icmp ne i32* %24, null
br i1 %25, label %31, label %26
26: ; preds = %3
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %4
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %3
store i32 0, i32* %10
store i32 0, i32* %11
br label %32
32: ; preds = %195, %130, %48, %31
%33 = load i32*, i32** %7
%34 = call i32 @feof(i32* %33)
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
br i1 %36, label %37, label %198
37: ; preds = %32
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%39 = load i32*, i32** %7
%40 = call i32 @fgets(i8* %38, i32 1024, i32* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %37
br label %198
43: ; preds = %37
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 35
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %32
51: ; preds = %43
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
store i32 %53, i32* %12
store i32 0, i32* %14
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%55 = call i8* @strtok(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %55, i8** %13
br label %56
56: ; preds = %125, %51
%57 = load i8*, i8** %13
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %127
59: ; preds = %56
store i32 1, i32* %16
store i32 0, i32* %15
br label %60
60: ; preds = %83, %59
%61 = load i8*, i8** %13
%62 = load i32, i32* %15
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %60
%69 = load i32, i32* %16
%70 = icmp ne i32 %69, 0
br label %71
71: ; preds = %68, %60
%72 = phi i1 [ false, %60 ], [ %70, %68 ]
br i1 %72, label %73, label %86
73: ; preds = %71
%74 = load i8*, i8** %13
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = call i32 @isspace(i8 signext %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %82, label %81
81: ; preds = %73
store i32 0, i32* %16
br label %82
82: ; preds = %81, %73
br label %83
83: ; preds = %82
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 1
store i32 %85, i32* %15
br label %60
86: ; preds = %71
%87 = load i32, i32* %16
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %86
br label %125
90: ; preds = %86
%91 = load i32, i32* %14
%92 = icmp sge i32 %91, 4
br i1 %92, label %93, label %104
93: ; preds = %90
%94 = load i32, i32* @stderr
%95 = load i8*, i8** %4
%96 = load i32, i32* %10
%97 = load i32, i32* %11
%98 = add nsw i32 %96, %97
%99 = add nsw i32 %98, 1
%100 = load i32, i32* %14
%101 = add nsw i32 %100, 1
%102 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0), i8* %95, i32 %99, i32 %101, i32 4)
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %90
%105 = load i32, i32* %10
%106 = load i32, i32* %5
%107 = icmp sge i32 %105, %106
br i1 %107, label %108, label %113
108: ; preds = %104
%109 = load i32, i32* @stderr
%110 = load i8*, i8** %4
%111 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %104
%114 = load i8*, i8** %13
%115 = call double @atof(i8* %114)
%116 = load [4 x double]*, [4 x double]** %9
%117 = load i32, i32* %10
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [4 x double], [4 x double]* %116, i64 %118
%120 = load i32, i32* %14
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [4 x double], [4 x double]* %119, i64 0, i64 %121
store double %115, double* %122
%123 = load i32, i32* %14
%124 = add nsw i32 %123, 1
store i32 %124, i32* %14
br label %125
125: ; preds = %113, %89
%126 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %126, i8** %13
br label %56
127: ; preds = %56
%128 = load i32, i32* %14
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = load i32, i32* %11
%132 = add nsw i32 %131, 1
store i32 %132, i32* %11
br label %32
133: ; preds = %127
%134 = load i32, i32* %14
%135 = icmp ne i32 %134, 4
br i1 %135, label %136, label %145
136: ; preds = %133
%137 = load i32, i32* @stderr
%138 = load i8*, i8** %4
%139 = load i32, i32* %10
%140 = load i32, i32* %11
%141 = add nsw i32 %139, %140
%142 = add nsw i32 %141, 1
%143 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i8* %138, i32 %142)
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %133
store double 0.000000e+00, double* %17
store i32 0, i32* %14
br label %146
146: ; preds = %177, %145
%147 = load i32, i32* %14
%148 = icmp slt i32 %147, 4
br i1 %148, label %149, label %180
149: ; preds = %146
%150 = load [4 x double]*, [4 x double]** %9
%151 = load i32, i32* %10
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [4 x double], [4 x double]* %150, i64 %152
%154 = load i32, i32* %14
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [4 x double], [4 x double]* %153, i64 0, i64 %155
%157 = load double, double* %156
%158 = load double, double* %17
%159 = fadd double %158, %157
store double %159, double* %17
%160 = load [4 x double]*, [4 x double]** %9
%161 = load i32, i32* %10
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [4 x double], [4 x double]* %160, i64 %162
%164 = load i32, i32* %14
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [4 x double], [4 x double]* %163, i64 0, i64 %165
%167 = load double, double* %166
%168 = call double @log2(double %167)
%169 = fneg double %168
%170 = load [4 x double]*, [4 x double]** %9
%171 = load i32, i32* %10
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [4 x double], [4 x double]* %170, i64 %172
%174 = load i32, i32* %14
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [4 x double], [4 x double]* %173, i64 0, i64 %175
store double %169, double* %176
br label %177
177: ; preds = %149
%178 = load i32, i32* %14
%179 = add nsw i32 %178, 1
store i32 %179, i32* %14
br label %146
180: ; preds = %146
%181 = load double, double* %17
%182 = fsub double 1.000000e+00, %181
%183 = call double @llvm.fabs.f64(double %182)
%184 = fcmp ogt double %183, 1.000000e-03
br i1 %184, label %185, label %195
185: ; preds = %180
%186 = load i32, i32* @stderr
%187 = load i8*, i8** %4
%188 = load i32, i32* %10
%189 = load i32, i32* %11
%190 = add nsw i32 %188, %189
%191 = add nsw i32 %190, 1
%192 = load double, double* %17
%193 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.6, i64 0, i64 0), i8* %187, i32 %191, double %192)
%194 = call i32 @exit(i32 1)
unreachable
195: ; preds = %180
%196 = load i32, i32* %10
%197 = add nsw i32 %196, 1
store i32 %197, i32* %10
br label %32
198: ; preds = %42, %32
%199 = load i32, i32* %10
%200 = load i32, i32* %5
%201 = icmp ne i32 %199, %200
br i1 %201, label %202, label %209
202: ; preds = %198
%203 = load i32, i32* @stderr
%204 = load i8*, i8** %4
%205 = load i32, i32* %10
%206 = load i32, i32* %5
%207 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i8* %204, i32 %205, i32 %206)
%208 = call i32 @exit(i32 1)
unreachable
209: ; preds = %198
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"Unable to open file '%s'. Exiting...\0A\00"
@.str.2 = [3 x i8] c" \09\00"
@.str.3 = [82 x i8] c"Probs file '%s', line %d: too many probabilities. Got %d, expect %d. Exiting...\0A\00"
@.str.4 = [46 x i8] c"Probs file '%s': too many lines. Exiting...\0A\00"
@.str.5 = [62 x i8] c"Probs file '%s', line %d: too few probabilities. Exiting...\0A\00"
@.str.6 = [77 x i8] c"Probs file '%s', line %d: Probabilities don't sum to 1. Sum=%f. Exiting...\0A\00"
@.str.7 = [63 x i8] c"Probs file '%s': too few lines. Got %d, expect %d. Exiting...\0A\00"
define void @load_probs_file(i8* %0, i32 %1, i8* nocapture %2) {
%4 = alloca [1024 x i8]
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i8* %2 to [4 x double]*
%8 = icmp eq i32* %5, null
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i32 @feof(i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %119
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %114
%17 = phi i32 [ %116, %114 ], [ 0, %9 ]
%18 = phi i32 [ %115, %114 ], [ 0, %9 ]
%19 = call i32 @fgets(i8* %6, i32 1024, i32* %5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %119, label %21
21: ; preds = %16
%22 = load i8, i8* %6
%23 = icmp eq i8 %22, 35
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = add nsw i32 %18, 1
br label %114
26: ; preds = %21
%27 = call i32 @strlen(i8* %6)
%28 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %98, label %30
30: ; preds = %26
%31 = icmp slt i32 %17, %1
%32 = sext i32 %17 to i64
br label %33
33: ; preds = %30, %68
%34 = phi i32 [ 0, %30 ], [ %69, %68 ]
%35 = phi i8* [ %28, %30 ], [ %70, %68 ]
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %68, label %38
38: ; preds = %33, %38
%39 = phi i64 [ %43, %38 ], [ 0, %33 ]
%40 = phi i8 [ %45, %38 ], [ %36, %33 ]
%41 = call i32 @isspace(i8 signext %40)
%42 = icmp ne i32 %41, 0
%43 = add nuw i64 %39, 1
%44 = getelementptr inbounds i8, i8* %35, i64 %43
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 0
%47 = and i1 %42, %46
br i1 %47, label %38, label %48
48: ; preds = %38
br i1 %42, label %68, label %49
49: ; preds = %48
%50 = icmp sgt i32 %34, 3
br i1 %50, label %51, label %58
51: ; preds = %49
%52 = load i32, i32* @stderr
%53 = add i32 %18, 1
%54 = add i32 %53, %17
%55 = add nuw nsw i32 %34, 1
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %54, i32 %55, i32 4)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49
br i1 %31, label %63, label %59
59: ; preds = %58
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %58
%64 = call double @atof(i8* %35)
%65 = sext i32 %34 to i64
%66 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 %32, i64 %65
store double %64, double* %66
%67 = add nsw i32 %34, 1
br label %68
68: ; preds = %33, %48, %63
%69 = phi i32 [ %67, %63 ], [ %34, %48 ], [ %34, %33 ]
%70 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %33
72: ; preds = %68
switch i32 %69, label %100 [
i32 0, label %98
i32 4, label %73
]
73: ; preds = %72
%74 = sext i32 %17 to i64
%75 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 %74, i64 0
%76 = load double, double* %75
%77 = fadd double %76, 0.000000e+00
%78 = call double @log2(double %76)
%79 = fneg double %78
store double %79, double* %75
%80 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 %74, i64 1
%81 = load double, double* %80
%82 = fadd double %77, %81
%83 = call double @log2(double %81)
%84 = fneg double %83
store double %84, double* %80
%85 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 %74, i64 2
%86 = load double, double* %85
%87 = fadd double %82, %86
%88 = call double @log2(double %86)
%89 = fneg double %88
store double %89, double* %85
%90 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 %74, i64 3
%91 = load double, double* %90
%92 = fadd double %87, %91
%93 = call double @log2(double %91)
%94 = fneg double %93
store double %94, double* %90
%95 = fsub double 1.000000e+00, %92
%96 = call double @llvm.fabs.f64(double %95)
%97 = fcmp ogt double %96, 1.000000e-03
br i1 %97, label %106, label %112
98: ; preds = %26, %72
%99 = add nsw i32 %18, 1
br label %114
100: ; preds = %72
%101 = load i32, i32* @stderr
%102 = add i32 %18, 1
%103 = add i32 %102, %17
%104 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %103)
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %73
%107 = load i32, i32* @stderr
%108 = add i32 %18, 1
%109 = add i32 %108, %17
%110 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %109, double %92)
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %73
%113 = add nsw i32 %17, 1
br label %114
114: ; preds = %112, %98, %24
%115 = phi i32 [ %25, %24 ], [ %99, %98 ], [ %18, %112 ]
%116 = phi i32 [ %17, %24 ], [ %17, %98 ], [ %113, %112 ]
%117 = call i32 @feof(i32* %5)
%118 = icmp eq i32 %117, 0
br i1 %118, label %16, label %119
119: ; preds = %114, %16, %9
%120 = phi i32 [ 0, %9 ], [ %17, %16 ], [ %116, %114 ]
%121 = icmp eq i32 %120, %1
br i1 %121, label %126, label %122
122: ; preds = %119
%123 = load i32, i32* @stderr
%124 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i8* %0, i32 %120, i32 %1)
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %119
ret void
}