#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*/ memset(unsigned char *, int /*<<< orphan*/, int);
unsigned char redupe_gf_mul(unsigned char const, unsigned char const);
void redupe_gf_poly_mul(const unsigned char *p, unsigned p_sz,
                        const unsigned char *q, unsigned q_sz, unsigned char *r,
                        unsigned *r_sz) {
  *r_sz = p_sz + q_sz - 1;
  memset(r, 0, sizeof(unsigned char) * *r_sz);
  for (unsigned i = 0; i < p_sz; ++i) {
    for (unsigned j = 0; j < q_sz; ++j) {
      r[i + j] ^= redupe_gf_mul(p[i], q[j]);
    }
  }
}


x86 assembly (clang, -O0):
<redupe_gf_poly_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11e0 <redupe_gf_poly_mul+0xc0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11cd <redupe_gf_poly_mul+0xad>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
movzbl %dl,%edi
movzbl (%rax,%rcx,1),%esi
call   1040 <redupe_gf_mul@plt>
movzbl %al,%esi
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
xor    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    117e <redupe_gf_poly_mul+0x5e>
jmp    11d2 <redupe_gf_poly_mul+0xb2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116b <redupe_gf_poly_mul+0x4b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redupe_gf_poly_mul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r15
mov    %rdx,%r13
mov    %esi,%r12d
mov    %rdi,%rbx
lea    -0x1(%r12),%edx
mov    %ecx,0xc(%rsp)
add    %ecx,%edx
mov    %edx,(%r9)
mov    %r8,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
cmp    $0x1,%r12d
jae    1167 <redupe_gf_poly_mul+0x47>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebp
xor    %r14d,%r14d
jmp    118b <redupe_gf_poly_mul+0x6b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     1158 <redupe_gf_poly_mul+0x38>
cmpl   $0x0,0xc(%rsp)
je     1180 <redupe_gf_poly_mul+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%r14,1),%edi
movzbl 0x0(%r13,%r12,1),%esi
call   1040 <redupe_gf_mul@plt>
lea    (%r14,%r12,1),%ecx
xor    %al,(%r15,%rcx,1)
add    $0x1,%r12
cmp    %r12,%rbp
jne    11a0 <redupe_gf_poly_mul+0x80>
jmp    1180 <redupe_gf_poly_mul+0x60>

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

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