#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*/ ec_encode_data_update_base(int, int, int, int,
                                              unsigned char *, unsigned char *,
                                              unsigned char **);
int /*<<< orphan*/ gf_2vect_mad_avx2(int, int, int, unsigned char *,
                                     unsigned char *, unsigned char **);
int /*<<< orphan*/ gf_3vect_mad_avx2(int, int, int, unsigned char *,
                                     unsigned char *, unsigned char **);
int /*<<< orphan*/ gf_4vect_mad_avx2(int, int, int, unsigned char *,
                                     unsigned char *, unsigned char **);
int /*<<< orphan*/ gf_5vect_mad_avx2(int, int, int, unsigned char *,
                                     unsigned char *, unsigned char **);
int /*<<< orphan*/ gf_6vect_mad_avx2(int, int, int, unsigned char *,
                                     unsigned char *, unsigned char **);
int /*<<< orphan*/ gf_vect_mad_avx2(int, int, int, unsigned char *,
                                    unsigned char *, unsigned char *);
void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i,
                                unsigned char *g_tbls, unsigned char *data,
                                unsigned char **coding) {
  if (len < 32) {
    ec_encode_data_update_base(len, k, rows, vec_i, g_tbls, data, coding);
    return;
  }
  while (rows > 6) {
    gf_6vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    g_tbls += 6 * k * 32;
    coding += 6;
    rows -= 6;
  }
  switch (rows) {
  case 6:
    gf_6vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    break;
  case 5:
    gf_5vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    break;
  case 4:
    gf_4vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    break;
  case 3:
    gf_3vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    break;
  case 2:
    gf_2vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
    break;
  case 1:
    gf_vect_mad_avx2(len, k, vec_i, g_tbls, data, *coding);
    break;
  case 0:
    break;
  }
}


x86 assembly (clang, -O0):
<ec_encode_data_update_avx2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    11c0 <ec_encode_data_update_avx2+0x50>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <ec_encode_data_update_base@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
jmp    11c5 <ec_encode_data_update_avx2+0x55>
cmpl   $0x6,-0xc(%rbp)
jle    1218 <ec_encode_data_update_avx2+0xa8>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1030 <gf_6vect_mad_avx2@plt>
imul   $0x6,-0x8(%rbp),%ecx
shl    $0x5,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    0x10(%rbp),%rax
add    $0x30,%rax
mov    %rax,0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0xc(%rbp)
jmp    11c5 <ec_encode_data_update_avx2+0x55>
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x6,%rax
ja     12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x28(%rbp),%rax
lea    0xdcc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1030 <gf_6vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1070 <gf_5vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1050 <gf_4vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1060 <gf_3vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1090 <gf_2vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%rax
mov    (%rax),%r9
call   1080 <gf_vect_mad_avx2@plt>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
jmp    12ff <ec_encode_data_update_avx2+0x18f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ec_encode_data_update_avx2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbp
mov    %r8,%rbx
mov    %edx,%r13d
mov    %esi,%r12d
mov    %edi,%r15d
mov    0x50(%rsp),%r14
cmp    $0x20,%edi
jge    11be <ec_encode_data_update_avx2+0x4e>
mov    %r14,(%rsp)
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %rbx,%r8
mov    %rbp,%r9
call   1040 <ec_encode_data_update_base@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x7,%r13d
jl     1212 <ec_encode_data_update_avx2+0xa2>
mov    %r12d,%eax
shl    $0x6,%eax
lea    (%rax,%rax,2),%eax
cltq
mov    %rax,0x10(%rsp)
mov    %ecx,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
call   1030 <gf_6vect_mad_avx2@plt>
mov    0xc(%rsp),%ecx
add    0x10(%rsp),%rbx
add    $0x30,%r14
lea    -0x6(%r13),%eax
cmp    $0xc,%r13d
mov    %eax,%r13d
ja     11e0 <ec_encode_data_update_avx2+0x70>
jmp    1215 <ec_encode_data_update_avx2+0xa5>
mov    %r13d,%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     11af <ec_encode_data_update_avx2+0x3f>
lea    0xddc(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
mov    (%r14),%r9
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <gf_vect_mad_avx2@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <gf_2vect_mad_avx2@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <gf_3vect_mad_avx2@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <gf_4vect_mad_avx2@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <gf_5vect_mad_avx2@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ecx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
mov    %r14,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <gf_6vect_mad_avx2@plt>

LLVM IR (-O0):
define void @ec_encode_data_update_avx2(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i8** %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8**
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 i8** %6, i8*** %14
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 32
br i1 %16, label %17, label %26
17: ; preds = %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32, i32* %11
%22 = load i8*, i8** %12
%23 = load i8*, i8** %13
%24 = load i8**, i8*** %14
%25 = call i32 @ec_encode_data_update_base(i32 %18, i32 %19, i32 %20, i32 %21, i8* %22, i8* %23, i8** %24)
br label %100
26: ; preds = %7
br label %27
27: ; preds = %30, %26
%28 = load i32, i32* %10
%29 = icmp sgt i32 %28, 6
br i1 %29, label %30, label %48
30: ; preds = %27
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = load i32, i32* %11
%34 = load i8*, i8** %12
%35 = load i8*, i8** %13
%36 = load i8**, i8*** %14
%37 = call i32 @gf_6vect_mad_avx2(i32 %31, i32 %32, i32 %33, i8* %34, i8* %35, i8** %36)
%38 = load i32, i32* %9
%39 = mul nsw i32 6, %38
%40 = mul nsw i32 %39, 32
%41 = load i8*, i8** %12
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %12
%44 = load i8**, i8*** %14
%45 = getelementptr inbounds i8*, i8** %44, i64 6
store i8** %45, i8*** %14
%46 = load i32, i32* %10
%47 = sub nsw i32 %46, 6
store i32 %47, i32* %10
br label %27
48: ; preds = %27
%49 = load i32, i32* %10
switch i32 %49, label %100 [
i32 6, label %50
i32 5, label %58
i32 4, label %66
i32 3, label %74
i32 2, label %82
i32 1, label %90
i32 0, label %99
]
50: ; preds = %48
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = load i32, i32* %11
%54 = load i8*, i8** %12
%55 = load i8*, i8** %13
%56 = load i8**, i8*** %14
%57 = call i32 @gf_6vect_mad_avx2(i32 %51, i32 %52, i32 %53, i8* %54, i8* %55, i8** %56)
br label %100
58: ; preds = %48
%59 = load i32, i32* %8
%60 = load i32, i32* %9
%61 = load i32, i32* %11
%62 = load i8*, i8** %12
%63 = load i8*, i8** %13
%64 = load i8**, i8*** %14
%65 = call i32 @gf_5vect_mad_avx2(i32 %59, i32 %60, i32 %61, i8* %62, i8* %63, i8** %64)
br label %100
66: ; preds = %48
%67 = load i32, i32* %8
%68 = load i32, i32* %9
%69 = load i32, i32* %11
%70 = load i8*, i8** %12
%71 = load i8*, i8** %13
%72 = load i8**, i8*** %14
%73 = call i32 @gf_4vect_mad_avx2(i32 %67, i32 %68, i32 %69, i8* %70, i8* %71, i8** %72)
br label %100
74: ; preds = %48
%75 = load i32, i32* %8
%76 = load i32, i32* %9
%77 = load i32, i32* %11
%78 = load i8*, i8** %12
%79 = load i8*, i8** %13
%80 = load i8**, i8*** %14
%81 = call i32 @gf_3vect_mad_avx2(i32 %75, i32 %76, i32 %77, i8* %78, i8* %79, i8** %80)
br label %100
82: ; preds = %48
%83 = load i32, i32* %8
%84 = load i32, i32* %9
%85 = load i32, i32* %11
%86 = load i8*, i8** %12
%87 = load i8*, i8** %13
%88 = load i8**, i8*** %14
%89 = call i32 @gf_2vect_mad_avx2(i32 %83, i32 %84, i32 %85, i8* %86, i8* %87, i8** %88)
br label %100
90: ; preds = %48
%91 = load i32, i32* %8
%92 = load i32, i32* %9
%93 = load i32, i32* %11
%94 = load i8*, i8** %12
%95 = load i8*, i8** %13
%96 = load i8**, i8*** %14
%97 = load i8*, i8** %96
%98 = call i32 @gf_vect_mad_avx2(i32 %91, i32 %92, i32 %93, i8* %94, i8* %95, i8* %97)
br label %100
99: ; preds = %48
br label %100
100: ; preds = %17, %48, %99, %90, %82, %74, %66, %58, %50
ret void
}

LLVM IR (-O2):
define void @ec_encode_data_update_avx2(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i8** %6) {
%8 = icmp slt i32 %0, 32
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = icmp sgt i32 %2, 6
br i1 %10, label %11, label %25
11: ; preds = %9
%12 = mul i32 %1, 192
%13 = sext i32 %12 to i64
br label %16
14: ; preds = %7
%15 = tail call i32 @ec_encode_data_update_base(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i8** %6)
br label %42
16: ; preds = %11, %16
%17 = phi i8** [ %6, %11 ], [ %22, %16 ]
%18 = phi i32 [ %2, %11 ], [ %23, %16 ]
%19 = phi i8* [ %4, %11 ], [ %21, %16 ]
%20 = tail call i32 @gf_6vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %19, i8* %5, i8** %17)
%21 = getelementptr inbounds i8, i8* %19, i64 %13
%22 = getelementptr inbounds i8*, i8** %17, i64 6
%23 = add nsw i32 %18, -6
%24 = icmp ugt i32 %18, 12
br i1 %24, label %16, label %25
25: ; preds = %16, %9
%26 = phi i8* [ %4, %9 ], [ %21, %16 ]
%27 = phi i32 [ %2, %9 ], [ %23, %16 ]
%28 = phi i8** [ %6, %9 ], [ %22, %16 ]
switch i32 %27, label %42 [
i32 6, label %29
i32 5, label %31
i32 4, label %33
i32 3, label %35
i32 2, label %37
i32 1, label %39
]
29: ; preds = %25
%30 = tail call i32 @gf_6vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8** %28)
br label %42
31: ; preds = %25
%32 = tail call i32 @gf_5vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8** %28)
br label %42
33: ; preds = %25
%34 = tail call i32 @gf_4vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8** %28)
br label %42
35: ; preds = %25
%36 = tail call i32 @gf_3vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8** %28)
br label %42
37: ; preds = %25
%38 = tail call i32 @gf_2vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8** %28)
br label %42
39: ; preds = %25
%40 = load i8*, i8** %28
%41 = tail call i32 @gf_vect_mad_avx2(i32 %0, i32 %1, i32 %3, i8* %26, i8* %5, i8* %40)
br label %42
42: ; preds = %14, %25, %39, %37, %35, %33, %31, %29
ret void
}