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

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
}