#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, char, ...);
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;
  if (packetsize % sizeof(long) != 0) {
    fprintf(stderr,
            "jerasure_bitmatrix_encode - packetsize(%d) %c sizeof(long) != 0\n",
            packetsize, '%');
    fflush(stderr);
    exit(1);
  }
  if (size % (packetsize * w) != 0) {
    fprintf(stderr,
            "jerasure_bitmatrix_encode - size(%d) %c (packetsize(%d)*w(%d))) "
            "!= 0\n",
            size, '%', packetsize, w);
    fflush(stderr);
    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    $0x50,%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     11ac <jerasure_bitmatrix_encode+0x6c>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%edx
lea    0xe78(%rip),%rsi
mov    $0x25,%ecx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x10(%rbp),%eax
mov    0x18(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1201 <jerasure_bitmatrix_encode+0xc1>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%r8d
mov    -0xc(%rbp),%r9d
lea    0xe64(%rip),%rsi
mov    $0x25,%ecx
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126f <jerasure_bitmatrix_encode+0x12f>
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   1060 <jerasure_bitmatrix_dotprod@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1208 <jerasure_bitmatrix_encode+0xc8>
add    $0x50,%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    1209 <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    122a <jerasure_bitmatrix_encode+0xea>
test   %esi,%esi
jle    11fa <jerasure_bitmatrix_encode+0xba>
mov    %r9,%r15
mov    %r8,%r12
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    %r13d,%r13d
xor    %ebp,%ebp
mov    %r14d,0xc(%rsp)
mov    %rcx,0x20(%rsp)
nop
movslq %r13d,%r13
lea    (%rcx,%r13,4),%rdx
mov    0x18(%rsp),%rdi
lea    (%rdi,%rbp,1),%r8d
sub    $0x8,%rsp
mov    %r14d,%esi
xor    %ecx,%ecx
mov    %r12,%r9
push   %rbx
push   %r11
push   %r15
mov    %r11,%r14
call   1060 <jerasure_bitmatrix_dotprod@plt>
mov    0x40(%rsp),%rcx
mov    %r14,%r11
mov    0x2c(%rsp),%r14d
add    $0x20,%rsp
add    $0x1,%rbp
add    0x8(%rsp),%r13d
cmp    %rbp,0x10(%rsp)
jne    11b0 <jerasure_bitmatrix_encode+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd0(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xde6(%rip),%rsi
mov    %ebx,%edx
mov    $0x25,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1250 <jerasure_bitmatrix_encode+0x110>
mov    0x2daf(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe06(%rip),%rsi
mov    %r11d,%edx
mov    $0x25,%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1040 <fflush@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

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