#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 */
unsigned char gf_mul(unsigned char, unsigned char);
void gf_vect_dot_prod_base(int len, int vlen, unsigned char *v,
                           unsigned char **src, unsigned char *dest) {
  int i, j;
  unsigned char s;
  for (i = 0; i < len; i++) {
    s = 0;
    for (j = 0; j < vlen; j++)
      s ^= gf_mul(src[j][i], v[j * 32 + 1]);
    dest[i] = s;
  }
}


x86 assembly (clang, -O0):
<gf_vect_dot_prod_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b9 <gf_vect_dot_prod_base+0xa9>
movb   $0x0,-0x29(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <gf_vect_dot_prod_base+0x8d>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x5,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl %dl,%edi
movzbl (%rax,%rcx,1),%esi
call   1030 <gf_mul@plt>
movzbl %al,%ecx
movzbl -0x29(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1148 <gf_vect_dot_prod_base+0x38>
mov    -0x29(%rbp),%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <gf_vect_dot_prod_base+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf_vect_dot_prod_base>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11a2 <gf_vect_dot_prod_base+0x92>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %edi,%eax
mov    %rax,0x8(%rsp)
mov    0x4(%rsp),%ebp
shl    $0x3,%rbp
xor    %r14d,%r14d
jmp    1167 <gf_vect_dot_prod_base+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %r12d,%r12d
mov    0x10(%rsp),%rax
mov    %r12b,(%rax,%r14,1)
add    $0x1,%r14
cmp    0x8(%rsp),%r14
je     11a2 <gf_vect_dot_prod_base+0x92>
cmpl   $0x0,0x4(%rsp)
jle    1150 <gf_vect_dot_prod_base+0x40>
xor    %r13d,%r13d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%r13,1),%rax
movzbl (%rax,%r14,1),%edi
movzbl 0x1(%rbx,%r13,4),%esi
call   1030 <gf_mul@plt>
xor    %al,%r12b
add    $0x8,%r13
cmp    %r13,%rbp
jne    1180 <gf_vect_dot_prod_base+0x70>
jmp    1153 <gf_vect_dot_prod_base+0x43>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gf_vect_dot_prod_base(i32 %0, i32 %1, i8* %2, i8** %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8** %3, i8*** %9
store i8* %4, i8** %10
store i32 0, i32* %11
br label %14
14: ; preds = %55, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %58
18: ; preds = %14
store i8 0, i8* %13
store i32 0, i32* %12
br label %19
19: ; preds = %46, %18
%20 = load i32, i32* %12
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %49
23: ; preds = %19
%24 = load i8**, i8*** %9
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %8
%34 = load i32, i32* %12
%35 = mul nsw i32 %34, 32
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = load i8, i8* %38
%40 = call zeroext i8 @gf_mul(i8 zeroext %32, i8 zeroext %39)
%41 = zext i8 %40 to i32
%42 = load i8, i8* %13
%43 = zext i8 %42 to i32
%44 = xor i32 %43, %41
%45 = trunc i32 %44 to i8
store i8 %45, i8* %13
br label %46
46: ; preds = %23
%47 = load i32, i32* %12
%48 = add nsw i32 %47, 1
store i32 %48, i32* %12
br label %19
49: ; preds = %19
%50 = load i8, i8* %13
%51 = load i8*, i8** %10
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 %50, i8* %54
br label %55
55: ; preds = %49
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %14
58: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @gf_vect_dot_prod_base(i32 %0, i32 %1, i8* nocapture %2, i8** nocapture %3, i8* nocapture writeonly %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %33
7: ; preds = %5
%8 = icmp sgt i32 %1, 0
%9 = zext i32 %0 to i64
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %7, %28
%12 = phi i64 [ 0, %7 ], [ %31, %28 ]
br i1 %8, label %13, label %28
13: ; preds = %11, %13
%14 = phi i64 [ %26, %13 ], [ 0, %11 ]
%15 = phi i8 [ %25, %13 ], [ 0, %11 ]
%16 = getelementptr inbounds i8*, i8** %3, i64 %14
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 %12
%19 = load i8, i8* %18
%20 = shl nsw i64 %14, 5
%21 = or i64 %20, 1
%22 = getelementptr inbounds i8, i8* %2, i64 %21
%23 = load i8, i8* %22
%24 = tail call zeroext i8 @gf_mul(i8 zeroext %19, i8 zeroext %23)
%25 = xor i8 %24, %15
%26 = add nuw nsw i64 %14, 1
%27 = icmp eq i64 %26, %10
br i1 %27, label %28, label %13
28: ; preds = %13, %11
%29 = phi i8 [ 0, %11 ], [ %25, %13 ]
%30 = getelementptr inbounds i8, i8* %4, i64 %12
store i8 %29, i8* %30
%31 = add nuw nsw i64 %12, 1
%32 = icmp eq i64 %31, %9
br i1 %32, label %33, label %11
33: ; preds = %28, %5
ret void
}