#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 */

/* Variables and functions */
int /*<<< orphan*/ free(int *);
int *jerasure_erasures_to_erased(int, int, int *);
scalar_t__ jerasure_make_decoding_matrix(int, int, int, int *, int *, int *,
                                         int *);
int /*<<< orphan*/ jerasure_matrix_dotprod(int, int, int *, int *, int, char **,
                                           char **, int);
scalar_t__ malloc(int);
int jerasure_matrix_decode(int k, int m, int w, int *matrix, int row_k_ones,
                           int *erasures, char **data_ptrs, char **coding_ptrs,
                           int size) {
  int i, j, edd, lastdrive;
  int *tmpids;
  int *erased, *decoding_matrix, *dm_ids;
  if (w != 8 && w != 16 && w != 32)
    return -1;
  erased = jerasure_erasures_to_erased(k, m, erasures);
  if (erased == NULL)
    return -1;
  lastdrive = k;
  edd = 0;
  for (i = 0; i < k; i++) {
    if (erased[i]) {
      edd++;
      lastdrive = i;
    }
  }
  if (!row_k_ones || erased[k])
    lastdrive = k;
  dm_ids = NULL;
  decoding_matrix = NULL;
  if (edd > 1 || (edd > 0 && (!row_k_ones || erased[k]))) {
    dm_ids = (int *)malloc(sizeof(int) * (k));
    if (dm_ids == NULL) {
      free(erased);
      return -1;
    }
    decoding_matrix = (int *)malloc(sizeof(int) * (k * k));
    if (decoding_matrix == NULL) {
      free(erased);
      free(dm_ids);
      return -1;
    }
    if (jerasure_make_decoding_matrix(k, m, w, matrix, erased, decoding_matrix,
                                      dm_ids) < 0) {
      free(erased);
      free(dm_ids);
      free(decoding_matrix);
      return -1;
    }
  }
  for (i = 0; edd > 0 && i < lastdrive; i++) {
    if (erased[i]) {
      jerasure_matrix_dotprod(k, w, decoding_matrix + (i * k), dm_ids, i,
                              data_ptrs, coding_ptrs, size);
      edd--;
    }
  }
  if (edd > 0) {
    tmpids = (int *)malloc(sizeof(int) * (k));
    for (i = 0; i < k; i++) {
      tmpids[i] = (i < lastdrive) ? i : i + 1;
    }
    jerasure_matrix_dotprod(k, w, matrix, tmpids, lastdrive, data_ptrs,
                            coding_ptrs, size);
    free(tmpids);
  }
  for (i = 0; i < m; i++) {
    if (erased[k + i]) {
      jerasure_matrix_dotprod(k, w, matrix + (i * k), NULL, i + k, data_ptrs,
                              coding_ptrs, size);
    }
  }
  free(erased);
  if (dm_ids != NULL)
    free(dm_ids);
  if (decoding_matrix != NULL)
    free(decoding_matrix);
  return 0;
}


x86 assembly (clang, -O0):
<jerasure_matrix_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
cmpl   $0x8,-0x10(%rbp)
je     11a2 <jerasure_matrix_decode+0x52>
cmpl   $0x10,-0x10(%rbp)
je     11a2 <jerasure_matrix_decode+0x52>
cmpl   $0x20,-0x10(%rbp)
je     11a2 <jerasure_matrix_decode+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <jerasure_matrix_decode+0x3e8>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1050 <jerasure_erasures_to_erased@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11cc <jerasure_matrix_decode+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <jerasure_matrix_decode+0x3e8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1220 <jerasure_matrix_decode+0xd0>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     120d <jerasure_matrix_decode+0xbd>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1212 <jerasure_matrix_decode+0xc2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e0 <jerasure_matrix_decode+0x90>
cmpl   $0x0,-0x1c(%rbp)
je     123c <jerasure_matrix_decode+0xec>
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1242 <jerasure_matrix_decode+0xf2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x1,-0x34(%rbp)
jg     1282 <jerasure_matrix_decode+0x132>
cmpl   $0x0,-0x34(%rbp)
jle    134e <jerasure_matrix_decode+0x1fe>
cmpl   $0x0,-0x1c(%rbp)
je     1282 <jerasure_matrix_decode+0x132>
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     134e <jerasure_matrix_decode+0x1fe>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12b5 <jerasure_matrix_decode+0x165>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <jerasure_matrix_decode+0x3e8>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12f6 <jerasure_matrix_decode+0x1a6>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <jerasure_matrix_decode+0x3e8>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    -0x58(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <jerasure_make_decoding_matrix@plt>
cmp    $0x0,%rax
jge    1349 <jerasure_matrix_decode+0x1f9>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <jerasure_matrix_decode+0x3e8>
jmp    134e <jerasure_matrix_decode+0x1fe>
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x59(%rbp)
jle    1370 <jerasure_matrix_decode+0x220>
mov    -0x2c(%rbp),%eax
cmp    -0x38(%rbp),%eax
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    1380 <jerasure_matrix_decode+0x230>
jmp    13e8 <jerasure_matrix_decode+0x298>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     13d5 <jerasure_matrix_decode+0x285>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    -0x2c(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x58(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    13da <jerasure_matrix_decode+0x28a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1355 <jerasure_matrix_decode+0x205>
cmpl   $0x0,-0x34(%rbp)
jle    1487 <jerasure_matrix_decode+0x337>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1454 <jerasure_matrix_decode+0x304>
mov    -0x2c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    142f <jerasure_matrix_decode+0x2df>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x60(%rbp)
jmp    1438 <jerasure_matrix_decode+0x2e8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%edx
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    140c <jerasure_matrix_decode+0x2bc>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1500 <jerasure_matrix_decode+0x3b0>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     14ed <jerasure_matrix_decode+0x39d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x2c(%rbp),%r8d
add    -0x8(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
xor    %ecx,%ecx
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
jmp    14f2 <jerasure_matrix_decode+0x3a2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    148e <jerasure_matrix_decode+0x33e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x58(%rbp)
je     151d <jerasure_matrix_decode+0x3cd>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1531 <jerasure_matrix_decode+0x3e1>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jerasure_matrix_decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0xffffffff,0x18(%rsp)
ff
cmp    $0x20,%edx
ja     1525 <jerasure_matrix_decode+0x3d5>
mov    %rcx,%r13
mov    %edx,%ebx
mov    %edx,%eax
movabs $0x100010100,%rcx
bt     %rax,%rcx
jae    1525 <jerasure_matrix_decode+0x3d5>
mov    %esi,%r15d
mov    %edi,%ebp
mov    %r8d,%r12d
mov    %r9,%rdx
call   1050 <jerasure_erasures_to_erased@plt>
test   %rax,%rax
je     1525 <jerasure_matrix_decode+0x3d5>
mov    %rax,%r14
mov    %ebp,%edi
test   %ebp,%ebp
mov    %rbp,(%rsp)
mov    %r12d,%r8d
mov    %ebx,0xc(%rsp)
mov    %r15d,0x8(%rsp)
jle    11cb <jerasure_matrix_decode+0x7b>
cmp    $0x1,%ebp
jne    11d3 <jerasure_matrix_decode+0x83>
xor    %eax,%eax
mov    %ebp,%r12d
xor    %r15d,%r15d
jmp    1214 <jerasure_matrix_decode+0xc4>
xor    %r15d,%r15d
mov    %ebp,%r12d
jmp    122e <jerasure_matrix_decode+0xde>
mov    %edi,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
mov    %ebp,%r12d
xor    %r15d,%r15d
xor    %edx,%edx
cmpl   $0x0,(%r14,%rax,4)
mov    %r12d,%esi
cmovne %eax,%esi
setne  %dl
add    %r15d,%edx
lea    0x1(%rax),%r12d
xor    %r15d,%r15d
cmpl   $0x0,0x4(%r14,%rax,4)
cmove  %esi,%r12d
setne  %r15b
add    %edx,%r15d
add    $0x2,%rax
cmp    %rcx,%rax
jne    11e0 <jerasure_matrix_decode+0x90>
test   $0x1,%dil
je     122e <jerasure_matrix_decode+0xde>
xor    %ecx,%ecx
cmpl   $0x0,(%r14,%rax,4)
setne  %cl
cmove  %r12d,%eax
add    %ecx,%r15d
mov    %eax,%r12d
test   %r8d,%r8d
je     123e <jerasure_matrix_decode+0xee>
movslq (%rsp),%rax
cmpl   $0x0,(%r14,%rax,4)
je     1245 <jerasure_matrix_decode+0xf5>
mov    (%rsp),%rax
mov    %eax,%r12d
cmp    $0x1,%r15d
mov    %rdi,0x28(%rsp)
jbe    12c9 <jerasure_matrix_decode+0x179>
mov    (%rsp),%rbp
lea    0x0(,%rbp,4),%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
movl   $0xffffffff,0x18(%rsp)
ff
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     13b5 <jerasure_matrix_decode+0x265>
imul   %ebp,%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     13d0 <jerasure_matrix_decode+0x280>
mov    %rax,%rbx
sub    $0x8,%rsp
mov    %ebp,%edi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %r13,%rcx
mov    %r14,%r8
mov    %rax,%r9
mov    0x18(%rsp),%rbp
push   %rbp
call   1060 <jerasure_make_decoding_matrix@plt>
add    $0x10,%rsp
test   %rax,%rax
jns    12eb <jerasure_matrix_decode+0x19b>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%r14
jmp    13d5 <jerasure_matrix_decode+0x285>
jne    13bd <jerasure_matrix_decode+0x26d>
test   %r8d,%r8d
je     1250 <jerasure_matrix_decode+0x100>
movslq (%rsp),%rax
cmpl   $0x0,(%r14,%rax,4)
jne    1250 <jerasure_matrix_decode+0x100>
xor    %ebx,%ebx
xor    %ebp,%ebp
test   %r15d,%r15d
setg   %al
mov    %rbx,0x10(%rsp)
mov    %rbp,0x20(%rsp)
jle    1373 <jerasure_matrix_decode+0x223>
test   %r12d,%r12d
jle    1373 <jerasure_matrix_decode+0x223>
movslq (%rsp),%rax
mov    %r12d,%ecx
mov    %rcx,0x30(%rsp)
shl    $0x2,%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
mov    0x10(%rsp),%rbx
xchg   %ax,%ax
cmpl   $0x0,(%r14,%rbp,4)
je     135b <jerasure_matrix_decode+0x20b>
mov    (%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %rbx,%rdx
mov    0x20(%rsp),%rcx
mov    %ebp,%r8d
mov    0x70(%rsp),%r9
mov    0x80(%rsp),%eax
push   %rax
push   0x80(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
add    $0x10,%rsp
add    $0xffffffff,%r15d
test   %r15d,%r15d
setg   %al
jle    1373 <jerasure_matrix_decode+0x223>
add    $0x1,%rbp
add    0x18(%rsp),%rbx
cmp    0x30(%rsp),%rbp
jb     1320 <jerasure_matrix_decode+0x1d0>
test   %al,%al
je     148f <jerasure_matrix_decode+0x33f>
mov    (%rsp),%rbx
lea    0x0(,%rbx,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %ebx,%ebx
jle    1459 <jerasure_matrix_decode+0x309>
movslq %r12d,%rax
mov    0x28(%rsp),%r8
lea    -0x1(%r8),%rdx
mov    %r8d,%ecx
and    $0x3,%ecx
cmp    $0x3,%rdx
jae    13e2 <jerasure_matrix_decode+0x292>
xor    %edx,%edx
jmp    143b <jerasure_matrix_decode+0x2eb>
mov    %r14,%rbx
jmp    151d <jerasure_matrix_decode+0x3cd>
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
jmp    148f <jerasure_matrix_decode+0x33f>
mov    0x10(%rsp),%rbx
mov    %r14,%rdi
call   1030 <free@plt>
jmp    151d <jerasure_matrix_decode+0x3cd>
and    $0xfffffffc,%r8d
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rdi
add    $0x1,%rdx
cmp    %rax,%rdi
mov    %edx,%ebx
cmovl  %edi,%ebx
mov    %ebx,(%r15,%rdi,4)
lea    0x2(%rdi),%rbx
cmp    %rax,%rdx
mov    %ebx,%esi
cmovl  %edx,%esi
lea    0x3(%rdi),%rbp
cmp    %rax,%rbx
mov    %ebp,%edx
cmovl  %ebx,%edx
mov    %esi,0x4(%r15,%rdi,4)
mov    %edx,0x8(%r15,%rdi,4)
lea    0x4(%rdi),%rdx
cmp    %rax,%rbp
mov    %edx,%esi
cmovl  %ebp,%esi
mov    %esi,0xc(%r15,%rdi,4)
cmp    %r8,%rdx
jne    13f0 <jerasure_matrix_decode+0x2a0>
test   %rcx,%rcx
je     1459 <jerasure_matrix_decode+0x309>
lea    0x1(%rdx),%rsi
cmp    %rax,%rdx
mov    %esi,%edi
cmovl  %edx,%edi
mov    %edi,(%r15,%rdx,4)
mov    %rsi,%rdx
add    $0xffffffffffffffff,%rcx
jne    1440 <jerasure_matrix_decode+0x2f0>
mov    (%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12d,%r8d
mov    0x70(%rsp),%r9
mov    0x80(%rsp),%eax
push   %rax
push   0x80(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
add    $0x10,%rsp
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    14f4 <jerasure_matrix_decode+0x3a4>
movslq (%rsp),%rbx
mov    %eax,%r15d
lea    (%r14,%rbx,4),%r12
shl    $0x2,%rbx
xor    %ebp,%ebp
jmp    14bc <jerasure_matrix_decode+0x36c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
add    %rbx,%r13
cmp    %rbp,%r15
je     14f4 <jerasure_matrix_decode+0x3a4>
cmpl   $0x0,(%r12,%rbp,4)
je     14b0 <jerasure_matrix_decode+0x360>
mov    0x28(%rsp),%rdi
lea    (%rdi,%rbp,1),%r8d
mov    0xc(%rsp),%esi
mov    %r13,%rdx
xor    %ecx,%ecx
mov    0x70(%rsp),%r9
mov    0x80(%rsp),%eax
push   %rax
push   0x80(%rsp)
call   1040 <jerasure_matrix_dotprod@plt>
add    $0x10,%rsp
jmp    14b0 <jerasure_matrix_decode+0x360>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
test   %rdi,%rdi
je     150b <jerasure_matrix_decode+0x3bb>
call   1030 <free@plt>
movl   $0x0,0x18(%rsp)
mov    0x10(%rsp),%rbx
test   %rbx,%rbx
je     1525 <jerasure_matrix_decode+0x3d5>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jerasure_matrix_decode(i32 %0, i32 %1, i32 %2, i32* %3, i32 %4, i32* %5, i8** %6, i8** %7, i32 %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i8**
%18 = alloca i8**
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
store i32 %0, i32* %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32* %3, i32** %14
store i32 %4, i32* %15
store i32* %5, i32** %16
store i8** %6, i8*** %17
store i8** %7, i8*** %18
store i32 %8, i32* %19
%28 = load i32, i32* %13
%29 = icmp ne i32 %28, 8
br i1 %29, label %30, label %37
30: ; preds = %9
%31 = load i32, i32* %13
%32 = icmp ne i32 %31, 16
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %13
%35 = icmp ne i32 %34, 32
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 -1, i32* %10
br label %271
37: ; preds = %33, %30, %9
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = load i32*, i32** %16
%41 = call i32* @jerasure_erasures_to_erased(i32 %38, i32 %39, i32* %40)
store i32* %41, i32** %25
%42 = load i32*, i32** %25
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %45
44: ; preds = %37
store i32 -1, i32* %10
br label %271
45: ; preds = %37
%46 = load i32, i32* %11
store i32 %46, i32* %23
store i32 0, i32* %22
store i32 0, i32* %20
br label %47
47: ; preds = %63, %45
%48 = load i32, i32* %20
%49 = load i32, i32* %11
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %66
51: ; preds = %47
%52 = load i32*, i32** %25
%53 = load i32, i32* %20
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = load i32, i32* %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %51
%59 = load i32, i32* %22
%60 = add nsw i32 %59, 1
store i32 %60, i32* %22
%61 = load i32, i32* %20
store i32 %61, i32* %23
br label %62
62: ; preds = %58, %51
br label %63
63: ; preds = %62
%64 = load i32, i32* %20
%65 = add nsw i32 %64, 1
store i32 %65, i32* %20
br label %47
66: ; preds = %47
%67 = load i32, i32* %15
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %66
%70 = load i32*, i32** %25
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
%74 = load i32, i32* %73
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %69, %66
%77 = load i32, i32* %11
store i32 %77, i32* %23
br label %78
78: ; preds = %76, %69
store i32* null, i32** %27
store i32* null, i32** %26
%79 = load i32, i32* %22
%80 = icmp sgt i32 %79, 1
br i1 %80, label %94, label %81
81: ; preds = %78
%82 = load i32, i32* %22
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %140
84: ; preds = %81
%85 = load i32, i32* %15
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %94
87: ; preds = %84
%88 = load i32*, i32** %25
%89 = load i32, i32* %11
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
%92 = load i32, i32* %91
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %140
94: ; preds = %87, %84, %78
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = mul i64 4, %96
%98 = trunc i64 %97 to i32
%99 = call i64 @malloc(i32 %98)
%100 = inttoptr i64 %99 to i32*
store i32* %100, i32** %27
%101 = load i32*, i32** %27
%102 = icmp eq i32* %101, null
br i1 %102, label %103, label %106
103: ; preds = %94
%104 = load i32*, i32** %25
%105 = call i32 @free(i32* %104)
store i32 -1, i32* %10
br label %271
106: ; preds = %94
%107 = load i32, i32* %11
%108 = load i32, i32* %11
%109 = mul nsw i32 %107, %108
%110 = sext i32 %109 to i64
%111 = mul i64 4, %110
%112 = trunc i64 %111 to i32
%113 = call i64 @malloc(i32 %112)
%114 = inttoptr i64 %113 to i32*
store i32* %114, i32** %26
%115 = load i32*, i32** %26
%116 = icmp eq i32* %115, null
br i1 %116, label %117, label %122
117: ; preds = %106
%118 = load i32*, i32** %25
%119 = call i32 @free(i32* %118)
%120 = load i32*, i32** %27
%121 = call i32 @free(i32* %120)
store i32 -1, i32* %10
br label %271
122: ; preds = %106
%123 = load i32, i32* %11
%124 = load i32, i32* %12
%125 = load i32, i32* %13
%126 = load i32*, i32** %14
%127 = load i32*, i32** %25
%128 = load i32*, i32** %26
%129 = load i32*, i32** %27
%130 = call i64 @jerasure_make_decoding_matrix(i32 %123, i32 %124, i32 %125, i32* %126, i32* %127, i32* %128, i32* %129)
%131 = icmp slt i64 %130, 0
br i1 %131, label %132, label %139
132: ; preds = %122
%133 = load i32*, i32** %25
%134 = call i32 @free(i32* %133)
%135 = load i32*, i32** %27
%136 = call i32 @free(i32* %135)
%137 = load i32*, i32** %26
%138 = call i32 @free(i32* %137)
store i32 -1, i32* %10
br label %271
139: ; preds = %122
br label %140
140: ; preds = %139, %87, %81
store i32 0, i32* %20
br label %141
141: ; preds = %175, %140
%142 = load i32, i32* %22
%143 = icmp sgt i32 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %141
%145 = load i32, i32* %20
%146 = load i32, i32* %23
%147 = icmp slt i32 %145, %146
br label %148
148: ; preds = %144, %141
%149 = phi i1 [ false, %141 ], [ %147, %144 ]
br i1 %149, label %150, label %178
150: ; preds = %148
%151 = load i32*, i32** %25
%152 = load i32, i32* %20
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %151, i64 %153
%155 = load i32, i32* %154
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %174
157: ; preds = %150
%158 = load i32, i32* %11
%159 = load i32, i32* %13
%160 = load i32*, i32** %26
%161 = load i32, i32* %20
%162 = load i32, i32* %11
%163 = mul nsw i32 %161, %162
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32, i32* %160, i64 %164
%166 = load i32*, i32** %27
%167 = load i32, i32* %20
%168 = load i8**, i8*** %17
%169 = load i8**, i8*** %18
%170 = load i32, i32* %19
%171 = call i32 @jerasure_matrix_dotprod(i32 %158, i32 %159, i32* %165, i32* %166, i32 %167, i8** %168, i8** %169, i32 %170)
%172 = load i32, i32* %22
%173 = add nsw i32 %172, -1
store i32 %173, i32* %22
br label %174
174: ; preds = %157, %150
br label %175
175: ; preds = %174
%176 = load i32, i32* %20
%177 = add nsw i32 %176, 1
store i32 %177, i32* %20
br label %141
178: ; preds = %148
%179 = load i32, i32* %22
%180 = icmp sgt i32 %179, 0
br i1 %180, label %181, label %222
181: ; preds = %178
%182 = load i32, i32* %11
%183 = sext i32 %182 to i64
%184 = mul i64 4, %183
%185 = trunc i64 %184 to i32
%186 = call i64 @malloc(i32 %185)
%187 = inttoptr i64 %186 to i32*
store i32* %187, i32** %24
store i32 0, i32* %20
br label %188
188: ; preds = %207, %181
%189 = load i32, i32* %20
%190 = load i32, i32* %11
%191 = icmp slt i32 %189, %190
br i1 %191, label %192, label %210
192: ; preds = %188
%193 = load i32, i32* %20
%194 = load i32, i32* %23
%195 = icmp slt i32 %193, %194
br i1 %195, label %196, label %198
196: ; preds = %192
%197 = load i32, i32* %20
br label %201
198: ; preds = %192
%199 = load i32, i32* %20
%200 = add nsw i32 %199, 1
br label %201
201: ; preds = %198, %196
%202 = phi i32 [ %197, %196 ], [ %200, %198 ]
%203 = load i32*, i32** %24
%204 = load i32, i32* %20
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds i32, i32* %203, i64 %205
store i32 %202, i32* %206
br label %207
207: ; preds = %201
%208 = load i32, i32* %20
%209 = add nsw i32 %208, 1
store i32 %209, i32* %20
br label %188
210: ; preds = %188
%211 = load i32, i32* %11
%212 = load i32, i32* %13
%213 = load i32*, i32** %14
%214 = load i32*, i32** %24
%215 = load i32, i32* %23
%216 = load i8**, i8*** %17
%217 = load i8**, i8*** %18
%218 = load i32, i32* %19
%219 = call i32 @jerasure_matrix_dotprod(i32 %211, i32 %212, i32* %213, i32* %214, i32 %215, i8** %216, i8** %217, i32 %218)
%220 = load i32*, i32** %24
%221 = call i32 @free(i32* %220)
br label %222
222: ; preds = %210, %178
store i32 0, i32* %20
br label %223
223: ; preds = %253, %222
%224 = load i32, i32* %20
%225 = load i32, i32* %12
%226 = icmp slt i32 %224, %225
br i1 %226, label %227, label %256
227: ; preds = %223
%228 = load i32*, i32** %25
%229 = load i32, i32* %11
%230 = load i32, i32* %20
%231 = add nsw i32 %229, %230
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds i32, i32* %228, i64 %232
%234 = load i32, i32* %233
%235 = icmp ne i32 %234, 0
br i1 %235, label %236, label %252
236: ; preds = %227
%237 = load i32, i32* %11
%238 = load i32, i32* %13
%239 = load i32*, i32** %14
%240 = load i32, i32* %20
%241 = load i32, i32* %11
%242 = mul nsw i32 %240, %241
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i32, i32* %239, i64 %243
%245 = load i32, i32* %20
%246 = load i32, i32* %11
%247 = add nsw i32 %245, %246
%248 = load i8**, i8*** %17
%249 = load i8**, i8*** %18
%250 = load i32, i32* %19
%251 = call i32 @jerasure_matrix_dotprod(i32 %237, i32 %238, i32* %244, i32* null, i32 %247, i8** %248, i8** %249, i32 %250)
br label %252
252: ; preds = %236, %227
br label %253
253: ; preds = %252
%254 = load i32, i32* %20
%255 = add nsw i32 %254, 1
store i32 %255, i32* %20
br label %223
256: ; preds = %223
%257 = load i32*, i32** %25
%258 = call i32 @free(i32* %257)
%259 = load i32*, i32** %27
%260 = icmp ne i32* %259, null
br i1 %260, label %261, label %264
261: ; preds = %256
%262 = load i32*, i32** %27
%263 = call i32 @free(i32* %262)
br label %264
264: ; preds = %261, %256
%265 = load i32*, i32** %26
%266 = icmp ne i32* %265, null
br i1 %266, label %267, label %270
267: ; preds = %264
%268 = load i32*, i32** %26
%269 = call i32 @free(i32* %268)
br label %270
270: ; preds = %267, %264
store i32 0, i32* %10
br label %271
271: ; preds = %270, %132, %117, %103, %44, %36
%272 = load i32, i32* %10
ret i32 %272
}

LLVM IR (-O2):
define i32 @jerasure_matrix_decode(i32 %0, i32 %1, i32 %2, i32* %3, i32 %4, i32* %5, i8** %6, i8** %7, i32 %8) {
switch i32 %2, label %216 [
i32 32, label %10
i32 16, label %10
i32 8, label %10
]
10: ; preds = %9, %9, %9
%11 = tail call i32* @jerasure_erasures_to_erased(i32 %0, i32 %1, i32* %5)
%12 = icmp eq i32* %11, null
br i1 %12, label %216, label %13
13: ; preds = %10
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %62
15: ; preds = %13
%16 = zext i32 %0 to i64
%17 = and i64 %16, 1
%18 = icmp eq i32 %0, 1
br i1 %18, label %46, label %19
19: ; preds = %15
%20 = and i64 %16, 4294967294
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %43, %21 ]
%23 = phi i32 [ %0, %19 ], [ %42, %21 ]
%24 = phi i32 [ 0, %19 ], [ %40, %21 ]
%25 = phi i64 [ 0, %19 ], [ %44, %21 ]
%26 = getelementptr inbounds i32, i32* %11, i64 %22
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
%31 = add nuw nsw i32 %24, %30
%32 = trunc i64 %22 to i32
%33 = select i1 %28, i32 %23, i32 %32
%34 = or i64 %22, 1
%35 = getelementptr inbounds i32, i32* %11, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 0
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
%40 = add nuw nsw i32 %31, %39
%41 = trunc i64 %34 to i32
%42 = select i1 %37, i32 %33, i32 %41
%43 = add nuw nsw i64 %22, 2
%44 = add i64 %25, 2
%45 = icmp eq i64 %44, %20
br i1 %45, label %46, label %21
46: ; preds = %21, %15
%47 = phi i32 [ undef, %15 ], [ %40, %21 ]
%48 = phi i32 [ undef, %15 ], [ %42, %21 ]
%49 = phi i64 [ 0, %15 ], [ %43, %21 ]
%50 = phi i32 [ %0, %15 ], [ %42, %21 ]
%51 = phi i32 [ 0, %15 ], [ %40, %21 ]
%52 = icmp eq i64 %17, 0
br i1 %52, label %62, label %53
53: ; preds = %46
%54 = getelementptr inbounds i32, i32* %11, i64 %49
%55 = load i32, i32* %54
%56 = icmp eq i32 %55, 0
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
%59 = add nuw nsw i32 %51, %58
%60 = trunc i64 %49 to i32
%61 = select i1 %56, i32 %50, i32 %60
br label %62
62: ; preds = %53, %46, %13
%63 = phi i32 [ 0, %13 ], [ %47, %46 ], [ %59, %53 ]
%64 = phi i32 [ %0, %13 ], [ %48, %46 ], [ %61, %53 ]
%65 = icmp eq i32 %4, 0
br i1 %65, label %71, label %66
66: ; preds = %62
%67 = sext i32 %0 to i64
%68 = getelementptr inbounds i32, i32* %11, i64 %67
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, 0
br i1 %70, label %72, label %71
71: ; preds = %66, %62
br label %72
72: ; preds = %71, %66
%73 = phi i32 [ %0, %71 ], [ %64, %66 ]
%74 = icmp ugt i32 %63, 1
br i1 %74, label %83, label %75
75: ; preds = %72
%76 = icmp eq i32 %63, 1
br i1 %76, label %77, label %180
77: ; preds = %75
br i1 %65, label %83, label %78
78: ; preds = %77
%79 = sext i32 %0 to i64
%80 = getelementptr inbounds i32, i32* %11, i64 %79
%81 = load i32, i32* %80
%82 = icmp eq i32 %81, 0
br i1 %82, label %98, label %83
83: ; preds = %78, %77, %72
%84 = shl i32 %0, 2
%85 = tail call i64 @malloc(i32 %84)
%86 = inttoptr i64 %85 to i32*
%87 = icmp eq i64 %85, 0
br i1 %87, label %212, label %88
88: ; preds = %83
%89 = mul i32 %84, %0
%90 = tail call i64 @malloc(i32 %89)
%91 = inttoptr i64 %90 to i32*
%92 = icmp eq i64 %90, 0
br i1 %92, label %208, label %93
93: ; preds = %88
%94 = tail call i64 @jerasure_make_decoding_matrix(i32 %0, i32 %1, i32 %2, i32* %3, i32* %11, i32* %91, i32* %86)
%95 = icmp slt i64 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = tail call i32 @free(i32* %11)
br label %208
98: ; preds = %93, %78
%99 = phi i32* [ %91, %93 ], [ null, %78 ]
%100 = phi i32* [ %86, %93 ], [ null, %78 ]
%101 = icmp sgt i32 %63, 0
%102 = icmp sgt i32 %73, 0
%103 = select i1 %101, i1 %102, i1 false
br i1 %103, label %104, label %125
104: ; preds = %98
%105 = sext i32 %0 to i64
%106 = zext i32 %73 to i64
br label %107
107: ; preds = %104, %119
%108 = phi i64 [ 0, %104 ], [ %121, %119 ]
%109 = phi i32 [ %63, %104 ], [ %120, %119 ]
%110 = getelementptr inbounds i32, i32* %11, i64 %108
%111 = load i32, i32* %110
%112 = icmp eq i32 %111, 0
br i1 %112, label %119, label %113
113: ; preds = %107
%114 = mul nsw i64 %108, %105
%115 = getelementptr inbounds i32, i32* %99, i64 %114
%116 = trunc i64 %108 to i32
%117 = tail call i32 @jerasure_matrix_dotprod(i32 %0, i32 %2, i32* %115, i32* %100, i32 %116, i8** %6, i8** %7, i32 %8)
%118 = add nsw i32 %109, -1
br label %119
119: ; preds = %107, %113
%120 = phi i32 [ %118, %113 ], [ %109, %107 ]
%121 = add nuw nsw i64 %108, 1
%122 = icmp sgt i32 %120, 0
%123 = icmp ult i64 %121, %106
%124 = select i1 %122, i1 %123, i1 false
br i1 %124, label %107, label %125
125: ; preds = %119, %98
%126 = phi i1 [ %101, %98 ], [ %122, %119 ]
br i1 %126, label %127, label %180
127: ; preds = %125
%128 = shl i32 %0, 2
%129 = tail call i64 @malloc(i32 %128)
%130 = inttoptr i64 %129 to i32*
br i1 %14, label %131, label %177
131: ; preds = %127
%132 = sext i32 %73 to i64
%133 = zext i32 %0 to i64
%134 = add nsw i64 %133, -1
%135 = and i64 %133, 3
%136 = icmp ult i64 %134, 3
br i1 %136, label %164, label %137
137: ; preds = %131
%138 = and i64 %133, 4294967292
br label %139
139: ; preds = %139, %137
%140 = phi i64 [ 0, %137 ], [ %158, %139 ]
%141 = phi i64 [ 0, %137 ], [ %162, %139 ]
%142 = icmp slt i64 %140, %132
%143 = or i64 %140, 1
%144 = select i1 %142, i64 %140, i64 %143
%145 = trunc i64 %144 to i32
%146 = getelementptr inbounds i32, i32* %130, i64 %140
store i32 %145, i32* %146
%147 = icmp slt i64 %143, %132
%148 = or i64 %140, 2
%149 = select i1 %147, i64 %143, i64 %148
%150 = trunc i64 %149 to i32
%151 = getelementptr inbounds i32, i32* %130, i64 %143
store i32 %150, i32* %151
%152 = icmp slt i64 %148, %132
%153 = or i64 %140, 3
%154 = select i1 %152, i64 %148, i64 %153
%155 = trunc i64 %154 to i32
%156 = getelementptr inbounds i32, i32* %130, i64 %148
store i32 %155, i32* %156
%157 = icmp slt i64 %153, %132
%158 = add nuw nsw i64 %140, 4
%159 = select i1 %157, i64 %153, i64 %158
%160 = trunc i64 %159 to i32
%161 = getelementptr inbounds i32, i32* %130, i64 %153
store i32 %160, i32* %161
%162 = add i64 %141, 4
%163 = icmp eq i64 %162, %138
br i1 %163, label %164, label %139
164: ; preds = %139, %131
%165 = phi i64 [ 0, %131 ], [ %158, %139 ]
%166 = icmp eq i64 %135, 0
br i1 %166, label %177, label %167
167: ; preds = %164, %167
%168 = phi i64 [ %171, %167 ], [ %165, %164 ]
%169 = phi i64 [ %175, %167 ], [ 0, %164 ]
%170 = icmp slt i64 %168, %132
%171 = add nuw nsw i64 %168, 1
%172 = select i1 %170, i64 %168, i64 %171
%173 = trunc i64 %172 to i32
%174 = getelementptr inbounds i32, i32* %130, i64 %168
store i32 %173, i32* %174
%175 = add i64 %169, 1
%176 = icmp eq i64 %175, %135
br i1 %176, label %177, label %167
177: ; preds = %164, %167, %127
%178 = tail call i32 @jerasure_matrix_dotprod(i32 %0, i32 %2, i32* %3, i32* %130, i32 %73, i8** %6, i8** %7, i32 %8)
%179 = tail call i32 @free(i32* %130)
br label %180
180: ; preds = %75, %177, %125
%181 = phi i32* [ %99, %177 ], [ %99, %125 ], [ null, %75 ]
%182 = phi i32* [ %100, %177 ], [ %100, %125 ], [ null, %75 ]
%183 = icmp sgt i32 %1, 0
br i1 %183, label %184, label %201
184: ; preds = %180
%185 = sext i32 %0 to i64
%186 = zext i32 %1 to i64
br label %187
187: ; preds = %184, %198
%188 = phi i64 [ 0, %184 ], [ %199, %198 ]
%189 = add nsw i64 %188, %185
%190 = getelementptr inbounds i32, i32* %11, i64 %189
%191 = load i32, i32* %190
%192 = icmp eq i32 %191, 0
br i1 %192, label %198, label %193
193: ; preds = %187
%194 = mul nsw i64 %188, %185
%195 = getelementptr inbounds i32, i32* %3, i64 %194
%196 = trunc i64 %189 to i32
%197 = tail call i32 @jerasure_matrix_dotprod(i32 %0, i32 %2, i32* %195, i32* null, i32 %196, i8** %6, i8** %7, i32 %8)
br label %198
198: ; preds = %187, %193
%199 = add nuw nsw i64 %188, 1
%200 = icmp eq i64 %199, %186
br i1 %200, label %201, label %187
201: ; preds = %198, %180
%202 = tail call i32 @free(i32* %11)
%203 = icmp eq i32* %182, null
br i1 %203, label %206, label %204
204: ; preds = %201
%205 = tail call i32 @free(i32* %182)
br label %206
206: ; preds = %204, %201
%207 = icmp eq i32* %181, null
br i1 %207, label %216, label %212
208: ; preds = %88, %96
%209 = phi i32* [ %86, %96 ], [ %11, %88 ]
%210 = phi i32* [ %91, %96 ], [ %86, %88 ]
%211 = tail call i32 @free(i32* %209)
br label %212
212: ; preds = %208, %206, %83
%213 = phi i32* [ %11, %83 ], [ %181, %206 ], [ %210, %208 ]
%214 = phi i32 [ -1, %83 ], [ 0, %206 ], [ -1, %208 ]
%215 = tail call i32 @free(i32* %213)
br label %216
216: ; preds = %212, %206, %10, %9
%217 = phi i32 [ -1, %9 ], [ -1, %10 ], [ 0, %206 ], [ %214, %212 ]
ret i32 %217
}