#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ gf256v_set_zero(int /*<<< orphan*/ *, unsigned int);
int /*<<< orphan*/ gf2v_get_ele(int /*<<< orphan*/ const *, unsigned int);
int /*<<< orphan*/ gf2v_madd(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                             int /*<<< orphan*/, unsigned int);
void gf2mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte,
                 unsigned n_A_width, const uint8_t *b) {
  gf256v_set_zero(c, n_A_vec_byte);
  for (unsigned i = 0; i < n_A_width; i++) {
    gf2v_madd(c, matA, gf2v_get_ele(b, i), n_A_vec_byte);
    matA += n_A_vec_byte;
  }
}


x86 assembly (clang, -O0):
<gf2mat_prod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <gf256v_set_zero@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    11b9 <gf2mat_prod+0x89>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <gf2v_get_ele@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
call   1040 <gf2v_madd@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <gf2mat_prod+0x2d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf2mat_prod>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r13
mov    %edx,%esi
call   1030 <gf256v_set_zero@plt>
test   %r15d,%r15d
je     1186 <gf2mat_prod+0x56>
mov    %r12d,%r14d
shl    $0x2,%r14
xor    %ebx,%ebx
mov    (%rsp),%rdi
mov    %ebx,%esi
call   1050 <gf2v_get_ele@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
mov    %r12d,%ecx
call   1040 <gf2v_madd@plt>
add    $0x1,%ebx
add    %r14,%rbp
cmp    %ebx,%r15d
jne    1160 <gf2mat_prod+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gf2mat_prod(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%12 = load i32*, i32** %6
%13 = load i32, i32* %8
%14 = call i32 @gf256v_set_zero(i32* %12, i32 %13)
store i32 0, i32* %11
br label %15
15: ; preds = %31, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %9
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32*, i32** %6
%21 = load i32*, i32** %7
%22 = load i32*, i32** %10
%23 = load i32, i32* %11
%24 = call i32 @gf2v_get_ele(i32* %22, i32 %23)
%25 = load i32, i32* %8
%26 = call i32 @gf2v_madd(i32* %20, i32* %21, i32 %24, i32 %25)
%27 = load i32, i32* %8
%28 = load i32*, i32** %7
%29 = zext i32 %27 to i64
%30 = getelementptr inbounds i32, i32* %28, i64 %29
store i32* %30, i32** %7
br label %31
31: ; preds = %19
%32 = load i32, i32* %11
%33 = add i32 %32, 1
store i32 %33, i32* %11
br label %15
34: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @gf2mat_prod(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4) {
%6 = tail call i32 @gf256v_set_zero(i32* %0, i32 %2)
%7 = icmp eq i32 %3, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = zext i32 %2 to i64
br label %11
10: ; preds = %11, %5
ret void
11: ; preds = %8, %11
%12 = phi i32 [ 0, %8 ], [ %17, %11 ]
%13 = phi i32* [ %1, %8 ], [ %16, %11 ]
%14 = tail call i32 @gf2v_get_ele(i32* %4, i32 %12)
%15 = tail call i32 @gf2v_madd(i32* %0, i32* %13, i32 %14, i32 %2)
%16 = getelementptr inbounds i32, i32* %13, i64 %9
%17 = add nuw i32 %12, 1
%18 = icmp eq i32 %17, %3
br i1 %18, label %10, label %11
}