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


x86 assembly (clang, -O0):
<gf_vect_mad_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119d <gf_vect_mad_base+0x8d>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x2d(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0xc(%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 -0x2d(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%dl
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1134 <gf_vect_mad_base+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf_vect_mad_base>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1165 <gf_vect_mad_base+0x55>
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r13
shl    $0x5,%edx
movslq %edx,%r12
or     $0x1,%r12
mov    %edi,%eax
mov    %rax,(%rsp)
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%rbx,%rbp,1),%r14d
movzbl (%r15,%rbp,1),%edi
movzbl 0x0(%r13,%r12,1),%esi
call   1030 <gf_mul@plt>
xor    %r14b,%al
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,(%rsp)
jne    1140 <gf_vect_mad_base+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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