#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ jerasure_matrix_dotprod(int, int, int *,
                                           int /*<<< orphan*/ *, int, char **,
                                           char **, int);
int /*<<< orphan*/ stderr;
void jerasure_matrix_encode(int k, int m, int w, int *matrix, char **data_ptrs,
                            char **coding_ptrs, int size) {
  int *init;
  int i, j;
  if (w != 8 && w != 16 && w != 32) {
    fprintf(stderr,
            "ERROR: jerasure_matrix_encode() and w is not 8, 16 or 32\n");
    exit(1);
  }
  for (i = 0; i < m; i++) {
    jerasure_matrix_dotprod(k, w, matrix + (i * k), NULL, k + i, data_ptrs,
                            coding_ptrs, size);
  }
}


x86 assembly (clang, -O0):
<jerasure_matrix_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
cmpl   $0x8,-0xc(%rbp)
je     118d <jerasure_matrix_encode+0x5d>
cmpl   $0x10,-0xc(%rbp)
je     118d <jerasure_matrix_encode+0x5d>
cmpl   $0x20,-0xc(%rbp)
je     118d <jerasure_matrix_encode+0x5d>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ea <jerasure_matrix_encode+0xba>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x34(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x4(%rbp),%r8d
add    -0x34(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%r10
mov    0x10(%rbp),%eax
xor    %ecx,%ecx
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <jerasure_matrix_dotprod@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1194 <jerasure_matrix_encode+0x64>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jerasure_matrix_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x20,%edx
ja     11c1 <jerasure_matrix_encode+0x91>
mov    %rcx,%rbx
mov    %edx,%r13d
mov    %edx,%edx
movabs $0x100010100,%rcx
bt     %rdx,%rcx
jae    11c1 <jerasure_matrix_encode+0x91>
test   %esi,%esi
jle    11b2 <jerasure_matrix_encode+0x82>
mov    %r9,%r12
mov    %r8,%rbp
mov    %edi,%r14d
movslq %edi,%rcx
mov    %esi,%edx
mov    %rdx,0x8(%rsp)
shl    $0x2,%rcx
mov    %rcx,0x10(%rsp)
xor    %r15d,%r15d
xchg   %ax,%ax
lea    (%r14,%r15,1),%r8d
mov    %r14d,%edi
mov    %r13d,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %rbp,%r9
mov    0x50(%rsp),%eax
push   %rax
push   %r12
call   1030 <jerasure_matrix_dotprod@plt>
add    $0x10,%rsp
add    $0x1,%r15
add    0x10(%rsp),%rbx
cmp    %r15,0x8(%rsp)
jne    1180 <jerasure_matrix_encode+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [58 x i8] c"ERROR: jerasure_matrix_encode() and w is not 8, 16 or 32\0A\00"
define void @jerasure_matrix_encode(i32 %0, i32 %1, i32 %2, i32* %3, i8** %4, i8** %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i8** %4, i8*** %12
store i8** %5, i8*** %13
store i32 %6, i32* %14
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 8
br i1 %19, label %20, label %30
20: ; preds = %7
%21 = load i32, i32* %10
%22 = icmp ne i32 %21, 16
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %10
%25 = icmp ne i32 %24, 32
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23, %20, %7
store i32 0, i32* %16
br label %31
31: ; preds = %51, %30
%32 = load i32, i32* %16
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %54
35: ; preds = %31
%36 = load i32, i32* %8
%37 = load i32, i32* %10
%38 = load i32*, i32** %11
%39 = load i32, i32* %16
%40 = load i32, i32* %8
%41 = mul nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %38, i64 %42
%44 = load i32, i32* %8
%45 = load i32, i32* %16
%46 = add nsw i32 %44, %45
%47 = load i8**, i8*** %12
%48 = load i8**, i8*** %13
%49 = load i32, i32* %14
%50 = call i32 @jerasure_matrix_dotprod(i32 %36, i32 %37, i32* %43, i32* null, i32 %46, i8** %47, i8** %48, i32 %49)
br label %51
51: ; preds = %35
%52 = load i32, i32* %16
%53 = add nsw i32 %52, 1
store i32 %53, i32* %16
br label %31
54: ; preds = %31
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [58 x i8] c"ERROR: jerasure_matrix_encode() and w is not 8, 16 or 32\0A\00"
define void @jerasure_matrix_encode(i32 %0, i32 %1, i32 %2, i32* %3, i8** %4, i8** %5, i32 %6) {
switch i32 %2, label %8 [
i32 32, label %12
i32 16, label %12
i32 8, label %12
]
8: ; preds = %7
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %7, %7, %7
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %26
14: ; preds = %12
%15 = sext i32 %0 to i64
%16 = zext i32 %1 to i64
br label %17
17: ; preds = %14, %17
%18 = phi i64 [ 0, %14 ], [ %24, %17 ]
%19 = mul nsw i64 %18, %15
%20 = getelementptr inbounds i32, i32* %3, i64 %19
%21 = trunc i64 %18 to i32
%22 = add i32 %21, %0
%23 = tail call i32 @jerasure_matrix_dotprod(i32 %0, i32 %2, i32* %20, i32* null, i32 %22, i8** %4, i8** %5, i32 %6)
%24 = add nuw nsw i64 %18, 1
%25 = icmp eq i64 %24, %16
br i1 %25, label %26, label %17
26: ; preds = %17, %12
ret void
}