#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_madd(int /*<<< orphan*/ *,
                                int /*<<< orphan*/ const *,
                                int /*<<< orphan*/ const, unsigned int);
int /*<<< orphan*/ gf256v_set_zero(int /*<<< orphan*/ *, unsigned int);
void _gf256mat_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++) {
    _gf256v_madd(c, matA, b[i], n_A_vec_byte);
    matA += n_A_vec_byte;
  }
}


x86 assembly (clang, -O0):
<_gf256mat_prod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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   1040 <gf256v_set_zero@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1195 <_gf256mat_prod+0x75>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
mov    -0x14(%rbp),%ecx
call   1030 <_gf256v_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    114d <_gf256mat_prod+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_gf256mat_prod>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r13
mov    %edx,%esi
call   1040 <gf256v_set_zero@plt>
test   %r12d,%r12d
je     1182 <_gf256mat_prod+0x62>
mov    %r15d,%ebp
mov    %r12d,%r12d
shl    $0x2,%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp),%rax
mov    (%rax,%r14,4),%edx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15d,%ecx
call   1030 <_gf256v_madd@plt>
add    $0x1,%r14
add    %rbp,%rbx
cmp    %r14,%r12
jne    1160 <_gf256mat_prod+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_gf256mat_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 = %33, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %9
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %36
19: ; preds = %15
%20 = load i32*, i32** %6
%21 = load i32*, i32** %7
%22 = load i32*, i32** %10
%23 = load i32, i32* %11
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %8
%28 = call i32 @_gf256v_madd(i32* %20, i32* %21, i32 %26, i32 %27)
%29 = load i32, i32* %8
%30 = load i32*, i32** %7
%31 = zext i32 %29 to i64
%32 = getelementptr inbounds i32, i32* %30, i64 %31
store i32* %32, i32** %7
br label %33
33: ; preds = %19
%34 = load i32, i32* %11
%35 = add i32 %34, 1
store i32 %35, i32* %11
br label %15
36: ; preds = %15
ret void
}

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