#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, ...);
int /*<<< orphan*/ jerasure_bitmatrix_dotprod(int, int, int *,
                                              int /*<<< orphan*/ *, int,
                                              char **, char **, int, int);
int /*<<< orphan*/ stderr;
void jerasure_bitmatrix_encode(int k, int m, int w, int *bitmatrix,
                               char **data_ptrs, char **coding_ptrs, int size,
                               int packetsize) {
  int i, j, x, y, sptr, pstarted, index;
  char *dptr, *pptr;
  if (packetsize % sizeof(long) != 0) {
    fprintf(stderr,
            "jerasure_bitmatrix_encode - packetsize(%d) %% sizeof(long) != 0\n",
            packetsize);
    exit(1);
  }
  if (size % (packetsize * w) != 0) {
    fprintf(stderr,
            "jerasure_bitmatrix_encode - size(%d) %% (packetsize(%d)*w(%d))) "
            "!= 0\n",
            size, packetsize, w);
    exit(1);
  }
  for (i = 0; i < m; i++) {
    jerasure_bitmatrix_dotprod(k, w, bitmatrix + i * k * w * w, NULL, k + i,
                               data_ptrs, coding_ptrs, size, packetsize);
  }
}


x86 assembly (clang, -O0):
<jerasure_bitmatrix_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%eax
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)
movslq 0x18(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
je     1189 <jerasure_bitmatrix_encode+0x59>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%edx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x10(%rbp),%eax
mov    0x18(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ca <jerasure_bitmatrix_encode+0x9a>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1238 <jerasure_bitmatrix_encode+0x108>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%eax
imul   -0x4(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x4(%rbp),%r8d
add    -0x2c(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%r11
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
xor    %ecx,%ecx
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <jerasure_bitmatrix_dotprod@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d1 <jerasure_bitmatrix_encode+0xa1>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jerasure_bitmatrix_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x68(%rsp),%ebx
test   $0x7,%bl
jne    11f9 <jerasure_bitmatrix_encode+0xc9>
mov    %edx,%r14d
mov    0x60(%rsp),%r11d
mov    %ebx,%ebp
imul   %edx,%ebp
mov    %r11d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    121c <jerasure_bitmatrix_encode+0xec>
test   %esi,%esi
jle    11ea <jerasure_bitmatrix_encode+0xba>
mov    %r9,%r15
mov    %r8,%r13
mov    %edi,%eax
mov    %rax,0x18(%rsp)
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    %r14d,%eax
imul   %r14d,%eax
imul   %edi,%eax
mov    %eax,0x8(%rsp)
xor    %r12d,%r12d
xor    %ebp,%ebp
mov    %rcx,0x20(%rsp)
mov    %r14d,0xc(%rsp)
nop
movslq %r12d,%r12
lea    (%rcx,%r12,4),%rdx
mov    0x18(%rsp),%rdi
lea    (%rdi,%rbp,1),%r8d
sub    $0x8,%rsp
mov    %r14d,%esi
xor    %ecx,%ecx
mov    %r13,%r9
push   %rbx
push   %r11
push   %r15
mov    %r11,%r14
call   1050 <jerasure_bitmatrix_dotprod@plt>
mov    %r14,%r11
mov    0x40(%rsp),%rcx
mov    0x2c(%rsp),%r14d
add    $0x20,%rsp
add    $0x1,%rbp
add    0x8(%rsp),%r12d
cmp    %rbp,0x10(%rsp)
jne    11a0 <jerasure_bitmatrix_encode+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
mov    %r11d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [65 x i8] c"jerasure_bitmatrix_encode - packetsize(%d) %% sizeof(long) != 0\0A\00"
@.str.1 = [70 x i8] c"jerasure_bitmatrix_encode - size(%d) %% (packetsize(%d)*w(%d))) != 0\0A\00"
define void @jerasure_bitmatrix_encode(i32 %0, i32 %1, i32 %2, i32* %3, i8** %4, i8** %5, i32 %6, i32 %7) {
%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
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i8*
%25 = alloca i8*
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32* %3, i32** %12
store i8** %4, i8*** %13
store i8** %5, i8*** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%26 = load i32, i32* %16
%27 = sext i32 %26 to i64
%28 = urem i64 %27, 8
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %8
%31 = load i32, i32* @stderr
%32 = load i32, i32* %16
%33 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %8
%36 = load i32, i32* %15
%37 = load i32, i32* %16
%38 = load i32, i32* %11
%39 = mul nsw i32 %37, %38
%40 = srem i32 %36, %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i32, i32* %15
%45 = load i32, i32* %16
%46 = load i32, i32* %11
%47 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %35
store i32 0, i32* %17
br label %50
50: ; preds = %75, %49
%51 = load i32, i32* %17
%52 = load i32, i32* %10
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %78
54: ; preds = %50
%55 = load i32, i32* %9
%56 = load i32, i32* %11
%57 = load i32*, i32** %12
%58 = load i32, i32* %17
%59 = load i32, i32* %9
%60 = mul nsw i32 %58, %59
%61 = load i32, i32* %11
%62 = mul nsw i32 %60, %61
%63 = load i32, i32* %11
%64 = mul nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i32, i32* %57, i64 %65
%67 = load i32, i32* %9
%68 = load i32, i32* %17
%69 = add nsw i32 %67, %68
%70 = load i8**, i8*** %13
%71 = load i8**, i8*** %14
%72 = load i32, i32* %15
%73 = load i32, i32* %16
%74 = call i32 @jerasure_bitmatrix_dotprod(i32 %55, i32 %56, i32* %66, i32* null, i32 %69, i8** %70, i8** %71, i32 %72, i32 %73)
br label %75
75: ; preds = %54
%76 = load i32, i32* %17
%77 = add nsw i32 %76, 1
store i32 %77, i32* %17
br label %50
78: ; preds = %50
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [65 x i8] c"jerasure_bitmatrix_encode - packetsize(%d) %% sizeof(long) != 0\0A\00"
@.str.1 = [70 x i8] c"jerasure_bitmatrix_encode - size(%d) %% (packetsize(%d)*w(%d))) != 0\0A\00"
define void @jerasure_bitmatrix_encode(i32 %0, i32 %1, i32 %2, i32* %3, i8** %4, i8** %5, i32 %6, i32 %7) {
%9 = and i32 %7, 7
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %7)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = mul nsw i32 %7, %2
%17 = srem i32 %6, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = icmp sgt i32 %1, 0
br i1 %20, label %21, label %40
21: ; preds = %19
%22 = mul i32 %2, %0
%23 = mul i32 %22, %2
%24 = zext i32 %1 to i64
br label %29
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7, i32 %2)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %21, %29
%30 = phi i64 [ 0, %21 ], [ %38, %29 ]
%31 = trunc i64 %30 to i32
%32 = mul i32 %23, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %3, i64 %33
%35 = trunc i64 %30 to i32
%36 = add i32 %35, %0
%37 = tail call i32 @jerasure_bitmatrix_dotprod(i32 %0, i32 %2, i32* %34, i32* null, i32 %36, i8** %4, i8** %5, i32 %6, i32 %7)
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, %24
br i1 %39, label %40, label %29
40: ; preds = %29, %19
ret void
}