#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ _gf256v_madd(scalar_t__ *, scalar_t__ const *,
                                scalar_t__ const, unsigned int);
void gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b,
                    unsigned _num) {
  for (unsigned i = 0; i < _num * 2 - 1; i++)
    c[i] = 0;
  for (unsigned i = 0; i < _num; i++)
    _gf256v_madd(c + i, a, b[i], _num);
}


x86 assembly (clang, -O0):
<gf256v_polymul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    115f <gf256v_polymul+0x4f>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <gf256v_polymul+0x1e>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11a5 <gf256v_polymul+0x95>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <_gf256v_madd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1166 <gf256v_polymul+0x56>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf256v_polymul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    -0x2(%r13,%r13,1),%eax
lea    0x8(,%rax,8),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
test   %r13d,%r13d
je     117c <gf256v_polymul+0x5c>
mov    %r13d,%ebx
shl    $0x3,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    (%r12,%rbp,1),%rdi
mov    (%r14,%rbp,1),%rdx
mov    %r15,%rsi
mov    %r13d,%ecx
call   1040 <_gf256v_madd@plt>
add    $0x8,%rbp
cmp    %rbp,%rbx
jne    1160 <gf256v_polymul+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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