#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 jerasure_matrix_decode(int, int, int, int *, int, int *, char **, char **,
                           int);
int /*<<< orphan*/ jerasure_print_matrix(int *, int, int, int);
int lrand48();
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, long *, int);
int /*<<< orphan*/ print_data_and_coding(int, int, int, int, char **, char **);
int /*<<< orphan*/ printf(char *, ...);
int *reed_sol_r6_coding_matrix(int, int);
int /*<<< orphan*/ reed_sol_r6_encode(int, int, char **, char **, int);
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, int *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  long l;
  int k, w, i, j, m;
  int *matrix;
  char **data, **coding;
  int *erasures, *erased;
  int *decoding_matrix, *dm_ids;
  if (argc != 3)
    usage(NULL);
  if (sscanf(argv[1], "%d", &k) == 0 || k <= 0)
    usage("Bad k");
  if (sscanf(argv[2], "%d", &w) == 0 || (w != 8 && w != 16 && w != 32))
    usage("Bad w");
  m = 2;
  if (w <= 16 && k + m > (1 << w))
    usage("k + m is too big");
  matrix = reed_sol_r6_coding_matrix(k, w);
  printf("Last 2 rows of the Distribution Matrix:\n\n");
  jerasure_print_matrix(matrix, m, k, w);
  printf("\n");
  srand48(0);
  data = (char **)malloc(sizeof(char *) * (k));
  for (i = 0; i < k; i++) {
    data[i] = (char *)malloc(sizeof(char) * (sizeof(long)));
    l = lrand48();
    memcpy(data[i], &l, sizeof(long));
  }
  coding = (char **)malloc(sizeof(char *) * (m));
  for (i = 0; i < m; i++) {
    coding[i] = (char *)malloc(sizeof(char) * (sizeof(long)));
  }
  reed_sol_r6_encode(k, w, data, coding, sizeof(long));
  printf("Encoding Complete:\n\n");
  print_data_and_coding(k, m, w, sizeof(long), data, coding);
  erasures = (int *)malloc(sizeof(int) * ((m + 1)));
  erased = (int *)malloc(sizeof(int) * ((k + m)));
  for (i = 0; i < m + k; i++)
    erased[i] = 0;
  l = 0;
  for (i = 0; i < m;) {
    erasures[i] = lrand48() % (k + m);
    if (erased[erasures[i]] == 0) {
      erased[erasures[i]] = 1;
      memcpy((erasures[i] < k) ? data[erasures[i]] : coding[erasures[i] - k],
             &l, sizeof(long));
      i++;
    }
  }
  erasures[i] = -1;
  printf("Erased %d random devices:\n\n", m);
  print_data_and_coding(k, m, w, sizeof(long), data, coding);
  i = jerasure_matrix_decode(k, m, w, matrix, 1, erasures, data, coding,
                             sizeof(long));
  printf("State of the system after decoding:\n\n");
  print_data_and_coding(k, m, w, sizeof(long), data, coding);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ec <main+0x2c>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe05(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x0,%rax
je     1218 <main+0x58>
cmpl   $0x0,-0x1c(%rbp)
jg     1224 <main+0x64>
lea    0xde4(%rip),%rdi
call   10c0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdcd(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x0,%rax
je     1264 <main+0xa4>
cmpl   $0x8,-0x20(%rbp)
je     1270 <main+0xb0>
cmpl   $0x10,-0x20(%rbp)
je     1270 <main+0xb0>
cmpl   $0x20,-0x20(%rbp)
je     1270 <main+0xb0>
lea    0xd9e(%rip),%rdi
call   10c0 <usage@plt>
movl   $0x2,-0x2c(%rbp)
cmpl   $0x10,-0x20(%rbp)
jg     12a7 <main+0xe7>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jle    12a7 <main+0xe7>
lea    0xd6d(%rip),%rdi
call   10c0 <usage@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <reed_sol_r6_coding_matrix@plt>
mov    %rax,-0x38(%rbp)
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <jerasure_print_matrix@plt>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <srand48@plt>
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    135f <main+0x19f>
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x0,%al
call   10a0 <lrand48@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1305 <main+0x145>
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    13ac <main+0x1ec>
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1379 <main+0x1b9>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x8,%r8d
call   10e0 <reed_sol_r6_encode@plt>
lea    0xc7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    $0x8,%ecx
call   1030 <print_data_and_coding@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    1451 <main+0x291>
mov    -0x58(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1423 <main+0x263>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1526 <main+0x366>
mov    $0x0,%al
call   10a0 <lrand48@plt>
mov    -0x1c(%rbp),%ecx
add    -0x2c(%rbp),%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1521 <main+0x361>
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x50(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x1c(%rbp),%eax
jge    14e9 <main+0x329>
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x70(%rbp)
jmp    1506 <main+0x346>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x24(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1460 <main+0x2a0>
mov    -0x50(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x2c(%rbp),%esi
lea    0xb20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    $0x8,%ecx
call   1030 <print_data_and_coding@plt>
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    -0x50(%rbp),%r9
mov    -0x40(%rbp),%r10
mov    -0x48(%rbp),%rax
mov    $0x1,%r8d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movl   $0x8,0x10(%rsp)
call   10d0 <jerasure_matrix_decode@plt>
mov    %eax,-0x24(%rbp)
lea    0xadb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    $0x8,%ecx
call   1030 <print_data_and_coding@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     11fd <main+0x1d>
xor    %edi,%edi
call   10e0 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xdf8(%rip),%rsi
mov    %rsp,%rdx
call   10b0 <sscanf@plt>
test   %rax,%rax
je     121b <main+0x3b>
cmpl   $0x0,(%rsp)
jg     1227 <main+0x47>
lea    0xde1(%rip),%rdi
call   10e0 <usage@plt>
mov    0x10(%rbx),%rdi
lea    0xdce(%rip),%rsi
lea    0x4(%rsp),%rdx
call   10b0 <sscanf@plt>
test   %rax,%rax
je     1262 <main+0x82>
mov    0x4(%rsp),%esi
cmp    $0x20,%rsi
ja     1262 <main+0x82>
movabs $0x100010100,%rax
bt     %rsi,%rax
jae    1262 <main+0x82>
cmp    $0x10,%esi
jle    1277 <main+0x97>
jmp    129a <main+0xba>
lea    0xda0(%rip),%rdi
call   10e0 <usage@plt>
mov    0x4(%rsp),%esi
cmp    $0x10,%esi
jg     129a <main+0xba>
mov    (%rsp),%eax
add    $0x2,%eax
mov    $0x1,%edx
mov    %esi,%ecx
shl    %cl,%edx
cmp    %edx,%eax
jle    129a <main+0xba>
lea    0xd7e(%rip),%rdi
call   10e0 <usage@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edi
call   1050 <reed_sol_r6_coding_matrix@plt>
mov    %rax,%rbx
lea    0xd90(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x2,%esi
call   1080 <jerasure_print_matrix@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %edi,%edi
call   10d0 <srand48@plt>
mov    (%rsp),%edi
shl    $0x3,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
cmpl   $0x0,(%rsp)
jle    133a <main+0x15a>
lea    0x8(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
xor    %eax,%eax
call   10c0 <lrand48@plt>
cltq
mov    %rax,0x8(%rsp)
mov    (%r12,%rbp,8),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1090 <memcpy@plt>
add    $0x1,%rbp
movslq (%rsp),%rax
cmp    %rax,%rbp
jl     1300 <main+0x120>
mov    $0x10,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,(%r15)
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,0x8(%r15)
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    $0x8,%r8d
call   1100 <reed_sol_r6_encode@plt>
lea    0xce4(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%edx
mov    $0x2,%esi
mov    $0x8,%ecx
mov    %r12,%r8
mov    %r15,%r9
call   1030 <print_data_and_coding@plt>
mov    $0xc,%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    (%rsp),%eax
lea    0x8(,%rax,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
cmpl   $0xffffffff,(%rsp)
jl     13e5 <main+0x205>
mov    $0xffffffffffffffff,%rax
xchg   %ax,%ax
movl   $0x0,0x4(%rbx,%rax,4)
movslq (%rsp),%rcx
add    $0x1,%rax
cmp    %rcx,%rax
jle    13d0 <main+0x1f0>
movq   $0x0,0x8(%rsp)
xor    %r14d,%r14d
jmp    1406 <main+0x226>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x2,%r14d
jge    1460 <main+0x280>
xor    %eax,%eax
call   10c0 <lrand48@plt>
mov    (%rsp),%ecx
add    $0x2,%ecx
cltd
idiv   %ecx
movslq %r14d,%rbp
mov    %edx,0x0(%r13,%rbp,4)
movslq %edx,%rax
cmpl   $0x0,(%rbx,%rax,4)
jne    1400 <main+0x220>
movl   $0x1,(%rbx,%rax,4)
movslq 0x0(%r13,%rbp,4),%rax
mov    (%rsp),%ecx
lea    (%r12,%rax,8),%rdx
sub    %ecx,%eax
cltq
lea    (%r15,%rax,8),%rax
cmovl  %rdx,%rax
mov    (%rax),%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1090 <memcpy@plt>
add    $0x1,%ebp
mov    %ebp,%r14d
jmp    1400 <main+0x220>
mov    %r14d,%eax
movl   $0xffffffff,0x0(%r13,%rax,4)
ff ff
lea    0xbad(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%edx
mov    $0x2,%esi
mov    $0x8,%ecx
mov    %r12,%r8
mov    %r15,%r9
call   1030 <print_data_and_coding@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%edx
sub    $0x8,%rsp
mov    $0x2,%esi
mov    0x18(%rsp),%rcx
mov    $0x1,%r8d
mov    %r13,%r9
push   $0x8
push   %r15
push   %r12
call   10f0 <jerasure_matrix_decode@plt>
add    $0x20,%rsp
lea    0xbaa(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%edx
mov    $0x2,%esi
mov    $0x8,%ecx
mov    %r12,%r8
mov    %r15,%r9
call   1030 <print_data_and_coding@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"Bad k\00"
@.str.2 = [6 x i8] c"Bad w\00"
@.str.3 = [17 x i8] c"k + m is too big\00"
@.str.7 = [28 x i8] c"Erased %d random devices:\0A\0A\00"
@str = [41 x i8] c"Last 2 rows of the Distribution Matrix:\0A\00"
@str.9 = [20 x i8] c"Encoding Complete:\0A\00"
@str.10 = [37 x i8] c"State of the system after decoding:\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i64* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 3
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @usage(i8* null)
br label %12
12: ; preds = %10, %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 1
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %12, %20
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = load i32, i32* %5
switch i32 %28, label %29 [
i32 32, label %32
i32 16, label %32
i32 8, label %32
]
29: ; preds = %27, %22
%30 = call i32 @usage(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %5
br label %32
32: ; preds = %27, %27, %27, %29
%33 = phi i32 [ %28, %27 ], [ %28, %27 ], [ %28, %27 ], [ %31, %29 ]
%34 = icmp slt i32 %33, 17
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 2
%38 = shl nuw nsw i32 1, %33
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 @usage(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%42 = load i32, i32* %5
br label %43
43: ; preds = %40, %35, %32
%44 = phi i32 [ %42, %40 ], [ %33, %35 ], [ %33, %32 ]
%45 = load i32, i32* %4
%46 = call i32* @reed_sol_r6_coding_matrix(i32 %45, i32 %44)
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = call i32 @jerasure_print_matrix(i32* %46, i32 2, i32 %48, i32 %49)
%51 = call i32 @putchar(i32 10)
%52 = call i32 @srand48(i32 0)
%53 = load i32, i32* %4
%54 = shl i32 %53, 3
%55 = call i64 @malloc(i32 %54)
%56 = inttoptr i64 %55 to i8**
%57 = load i32, i32* %4
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %72
59: ; preds = %43, %59
%60 = phi i64 [ %68, %59 ], [ 0, %43 ]
%61 = call i64 @malloc(i32 8)
%62 = inttoptr i64 %61 to i8*
%63 = getelementptr inbounds i8*, i8** %56, i64 %60
store i8* %62, i8** %63
%64 = call i32 (...) @lrand48()
%65 = sext i32 %64 to i64
store i64 %65, i64* %3
%66 = load i8*, i8** %63
%67 = call i32 @memcpy(i8* %66, i64* %3, i32 8)
%68 = add nuw nsw i64 %60, 1
%69 = load i32, i32* %4
%70 = sext i32 %69 to i64
%71 = icmp slt i64 %68, %70
br i1 %71, label %59, label %72
72: ; preds = %59, %43
%73 = call i64 @malloc(i32 16)
%74 = inttoptr i64 %73 to i8**
%75 = call i64 @malloc(i32 8)
%76 = inttoptr i64 %75 to i8*
store i8* %76, i8** %74
%77 = call i64 @malloc(i32 8)
%78 = inttoptr i64 %77 to i8*
%79 = getelementptr inbounds i8*, i8** %74, i64 1
store i8* %78, i8** %79
%80 = load i32, i32* %4
%81 = load i32, i32* %5
%82 = call i32 @reed_sol_r6_encode(i32 %80, i32 %81, i8** %56, i8** %74, i32 8)
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%84 = load i32, i32* %4
%85 = load i32, i32* %5
%86 = call i32 @print_data_and_coding(i32 %84, i32 2, i32 %85, i32 8, i8** %56, i8** %74)
%87 = call i64 @malloc(i32 12)
%88 = inttoptr i64 %87 to i32*
%89 = load i32, i32* %4
%90 = shl i32 %89, 2
%91 = add i32 %90, 8
%92 = call i64 @malloc(i32 %91)
%93 = inttoptr i64 %92 to i32*
%94 = load i32, i32* %4
%95 = icmp sgt i32 %94, -2
br i1 %95, label %96, label %103
96: ; preds = %72, %96
%97 = phi i64 [ %99, %96 ], [ 0, %72 ]
%98 = getelementptr inbounds i32, i32* %93, i64 %97
store i32 0, i32* %98
%99 = add nuw nsw i64 %97, 1
%100 = load i32, i32* %4
%101 = sext i32 %100 to i64
%102 = icmp sgt i64 %97, %101
br i1 %102, label %103, label %96
103: ; preds = %96, %72
store i64 0, i64* %3
br label %104
104: ; preds = %103, %129
%105 = phi i32 [ 0, %103 ], [ %130, %129 ]
%106 = call i32 (...) @lrand48()
%107 = load i32, i32* %4
%108 = add nsw i32 %107, 2
%109 = srem i32 %106, %108
%110 = sext i32 %105 to i64
%111 = getelementptr inbounds i32, i32* %88, i64 %110
store i32 %109, i32* %111
%112 = sext i32 %109 to i64
%113 = getelementptr inbounds i32, i32* %93, i64 %112
%114 = load i32, i32* %113
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %129
116: ; preds = %104
store i32 1, i32* %113
%117 = load i32, i32* %111
%118 = load i32, i32* %4
%119 = icmp slt i32 %117, %118
%120 = sext i32 %117 to i64
%121 = getelementptr inbounds i8*, i8** %56, i64 %120
%122 = sub nsw i32 %117, %118
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %74, i64 %123
%125 = select i1 %119, i8** %121, i8** %124
%126 = load i8*, i8** %125
%127 = call i32 @memcpy(i8* %126, i64* %3, i32 8)
%128 = add nsw i32 %105, 1
br label %129
129: ; preds = %116, %104
%130 = phi i32 [ %128, %116 ], [ %105, %104 ]
%131 = icmp slt i32 %130, 2
br i1 %131, label %104, label %132
132: ; preds = %129
%133 = zext i32 %130 to i64
%134 = getelementptr inbounds i32, i32* %88, i64 %133
store i32 -1, i32* %134
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 2)
%136 = load i32, i32* %4
%137 = load i32, i32* %5
%138 = call i32 @print_data_and_coding(i32 %136, i32 2, i32 %137, i32 8, i8** %56, i8** %74)
%139 = load i32, i32* %4
%140 = load i32, i32* %5
%141 = call i32 @jerasure_matrix_decode(i32 %139, i32 2, i32 %140, i32* %46, i32 1, i32* %88, i8** %56, i8** %74, i32 8)
%142 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
%143 = load i32, i32* %4
%144 = load i32, i32* %5
%145 = call i32 @print_data_and_coding(i32 %143, i32 2, i32 %144, i32 8, i8** %56, i8** %74)
ret i32 0
}