#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 i;
  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    $0x40,%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,-0x2c(%rbp)
mov    -0x2c(%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    -0x2c(%rbp),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x4(%rbp),%r8d
add    -0x2c(%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    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1194 <jerasure_matrix_encode+0x64>
add    $0x40,%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
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
%16 = load i32, i32* %10
%17 = icmp ne i32 %16, 8
br i1 %17, label %18, label %28
18: ; preds = %7
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 16
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %21, %18, %7
store i32 0, i32* %15
br label %29
29: ; preds = %49, %28
%30 = load i32, i32* %15
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %52
33: ; preds = %29
%34 = load i32, i32* %8
%35 = load i32, i32* %10
%36 = load i32*, i32** %11
%37 = load i32, i32* %15
%38 = load i32, i32* %8
%39 = mul nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %36, i64 %40
%42 = load i32, i32* %8
%43 = load i32, i32* %15
%44 = add nsw i32 %42, %43
%45 = load i8**, i8*** %12
%46 = load i8**, i8*** %13
%47 = load i32, i32* %14
%48 = call i32 @jerasure_matrix_dotprod(i32 %34, i32 %35, i32* %41, i32* null, i32 %44, i8** %45, i8** %46, i32 %47)
br label %49
49: ; preds = %33
%50 = load i32, i32* %15
%51 = add nsw i32 %50, 1
store i32 %51, i32* %15
br label %29
52: ; preds = %29
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
}