#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*/ fflush(int /*<<< orphan*/);
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");
    fflush(stderr);
    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     11ab <jerasure_matrix_encode+0x6b>
cmpl   $0x10,-0xc(%rbp)
je     11ab <jerasure_matrix_encode+0x6b>
cmpl   $0x20,-0xc(%rbp)
je     11ab <jerasure_matrix_encode+0x6b>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1208 <jerasure_matrix_encode+0xc8>
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    11b2 <jerasure_matrix_encode+0x72>
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     11d1 <jerasure_matrix_encode+0x91>
mov    %rcx,%rbx
mov    %edx,%r13d
mov    %edx,%edx
movabs $0x100010100,%rcx
bt     %rdx,%rcx
jae    11d1 <jerasure_matrix_encode+0x91>
test   %esi,%esi
jle    11c2 <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    1190 <jerasure_matrix_encode+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e08(%rip),%rbx
mov    (%rbx),%edi
lea    0xe1f(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <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 %30
18: ; preds = %7
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 16
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %30
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 = load i32, i32* @stderr
%28 = call i32 @fflush(i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21, %18, %7
store i32 0, i32* %15
br label %31
31: ; preds = %51, %30
%32 = load i32, i32* %15
%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* %15
%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* %15
%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* %15
%53 = add nsw i32 %52, 1
store i32 %53, i32* %15
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 %14
i32 16, label %14
i32 8, label %14
]
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 = load i32, i32* @stderr
%12 = tail call i32 @fflush(i32 %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7, %7, %7
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %28
16: ; preds = %14
%17 = sext i32 %0 to i64
%18 = zext i32 %1 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %26, %19 ]
%21 = mul nsw i64 %20, %17
%22 = getelementptr inbounds i32, i32* %3, i64 %21
%23 = trunc i64 %20 to i32
%24 = add i32 %23, %0
%25 = tail call i32 @jerasure_matrix_dotprod(i32 %0, i32 %2, i32* %22, i32* null, i32 %24, i8** %4, i8** %5, i32 %6)
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %18
br i1 %27, label %28, label %19
28: ; preds = %19, %14
ret void
}