#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 gen_crc(int);
void crc(volatile int *cmd, volatile int *resp, int a[4096], int b[4096],
         int result[4096]) {
#pragma HLS INTERFACE ap_ctrl_none port = return
#pragma HLS INTERFACE axis port = cmd
#pragma HLS INTERFACE axis port = resp
#pragma HLS INTERFACE bram depth = 1024 port = a
#pragma HLS INTERFACE bram depth = 1024 port = b
#pragma HLS INTERFACE bram depth = 1024 port = result
#pragma HLS RESOURCE variable = a core = RAM_1P_BRAM
#pragma HLS RESOURCE variable = b core = RAM_1P_BRAM
#pragma HLS RESOURCE variable = result core = RAM_1P_BRAM
  int i, op, start, end;
For_Loop:
  while (1) {
    end = *cmd;
    start = *cmd;
  for_Loop:
    for (i = start; i < end; i++) {
      result[i] = gen_crc(result[i]);
      if (i == end - 1)
        *resp = 1;
    }
  }
}


x86 assembly (clang, -O0):
<crc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
jmp    1131 <crc+0x21>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    11a0 <crc+0x90>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <gen_crc@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    118d <crc+0x7d>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1192 <crc+0x82>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1149 <crc+0x39>
jmp    1131 <crc+0x21>

x86 assembly (clang, -O2):
<crc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %rsi,%r12
mov    %rdi,%r15
cs nopw 0x0(%rax,%rax,1)
nop
movslq (%r15),%r13
movslq (%r15),%rax
cmp    %r13d,%eax
jge    1130 <crc+0x20>
mov    (%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
mov    %rax,%rbp
not    %rbp
add    %r13,%rbp
sub    %eax,%r13d
xor    %r14d,%r14d
jmp    1169 <crc+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    %r14d,%r13d
je     1130 <crc+0x20>
mov    (%rbx,%r14,4),%edi
call   1030 <gen_crc@plt>
mov    %eax,(%rbx,%r14,4)
cmp    %r14,%rbp
jne    1160 <crc+0x50>
movl   $0x1,(%r12)
jmp    1160 <crc+0x50>

LLVM IR (-O0):
define void @crc(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
%12 = alloca i32
%13 = alloca i32
%14 = 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
br label %15
15: ; preds = %5
br label %16
16: ; preds = %15, %48
%17 = load i32*, i32** %6
%18 = load volatile i32, i32* %17
store i32 %18, i32* %14
%19 = load i32*, i32** %6
%20 = load volatile i32, i32* %19
store i32 %20, i32* %13
br label %21
21: ; preds = %16
%22 = load i32, i32* %13
store i32 %22, i32* %11
br label %23
23: ; preds = %45, %21
%24 = load i32, i32* %11
%25 = load i32, i32* %14
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %48
27: ; preds = %23
%28 = load i32*, i32** %10
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @gen_crc(i32 %32)
%34 = load i32*, i32** %10
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
%38 = load i32, i32* %11
%39 = load i32, i32* %14
%40 = sub nsw i32 %39, 1
%41 = icmp eq i32 %38, %40
br i1 %41, label %42, label %44
42: ; preds = %27
%43 = load i32*, i32** %7
store volatile i32 1, i32* %43
br label %44
44: ; preds = %42, %27
br label %45
45: ; preds = %44
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %23
48: ; preds = %23
br label %16
}

LLVM IR (-O2):
define void @crc(i32* %0, i32* %1, i32* nocapture readnone %2, i32* nocapture readnone %3, i32* nocapture %4) {
br label %6
6: ; preds = %10, %5
%7 = load volatile i32, i32* %0
%8 = load volatile i32, i32* %0
%9 = icmp slt i32 %8, %7
br i1 %9, label %11, label %10
10: ; preds = %22, %6
br label %6
11: ; preds = %6
%12 = add nsw i32 %7, -1
%13 = sext i32 %8 to i64
%14 = sext i32 %12 to i64
br label %15
15: ; preds = %11, %22
%16 = phi i64 [ %13, %11 ], [ %23, %22 ]
%17 = getelementptr inbounds i32, i32* %4, i64 %16
%18 = load i32, i32* %17
%19 = tail call i32 @gen_crc(i32 %18)
store i32 %19, i32* %17
%20 = icmp eq i64 %16, %14
br i1 %20, label %21, label %22
21: ; preds = %15
store volatile i32 1, i32* %1
br label %22
22: ; preds = %15, %21
%23 = add nsw i64 %16, 1
%24 = trunc i64 %23 to i32
%25 = icmp eq i32 %7, %24
br i1 %25, label %10, label %15
}