#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ needwun(char *, char *, char *, char *);
void workload(char *SEQA, char *SEQB, char *alignedA, char *alignedB,
              int num_jobs) {
#pragma HLS INTERFACE m_axi port = SEQA offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = SEQB offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = alignedA offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = alignedB offset = slave bundle = gmem
#pragma HLS INTERFACE s_axilite port = SEQA bundle = control
#pragma HLS INTERFACE s_axilite port = SEQB bundle = control
#pragma HLS INTERFACE s_axilite port = alignedA bundle = control
#pragma HLS INTERFACE s_axilite port = alignedB bundle = control
#pragma HLS INTERFACE s_axilite port = num_jobs bundle = control
#pragma HLS INTERFACE s_axilite port = return bundle = control
  char seqA_buf[128 * 256];
  char seqB_buf[128 * 256];
  char alignedA_buf[(128 + 128) * 256];
  char alignedB_buf[(128 + 128) * 256];
  int num_batches = num_jobs / 256;
  int i, j, k;
  for (i = 0; i < num_batches; i++) {
    memcpy(seqA_buf, SEQA + i * (128 * 256), 128 * 256);
    memcpy(seqB_buf, SEQB + i * (128 * 256), 128 * 256);
    for (j = 0; j < 256; j++) {
      needwun(seqA_buf + j * 128, seqB_buf + j * 128,
              alignedA_buf + j * (128 + 128), alignedB_buf + j * (128 + 128));
    }
    memcpy(alignedA + i * ((128 + 128) * 256), alignedA_buf, (128 + 128) * 256);
    memcpy(alignedB + i * ((128 + 128) * 256), alignedB_buf, (128 + 128) * 256);
  }
  return;
}


x86 assembly (clang, -O0):
<workload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30034(%rbp)
movl   $0x0,-0x30038(%rbp)
mov    -0x30038(%rbp),%eax
cmp    -0x30034(%rbp),%eax
jge    1293 <workload+0x173>
lea    -0x8030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x30038(%rbp),%eax
shl    $0xf,%eax
cltq
add    %rax,%rsi
mov    $0x8000,%edx
call   1040 <memcpy@plt>
lea    -0x10030(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30038(%rbp),%eax
shl    $0xf,%eax
cltq
add    %rax,%rsi
mov    $0x8000,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x3003c(%rbp)
cmpl   $0x100,-0x3003c(%rbp)
jge    1239 <workload+0x119>
lea    -0x8030(%rbp),%rdi
mov    -0x3003c(%rbp),%eax
shl    $0x7,%eax
cltq
add    %rax,%rdi
lea    -0x10030(%rbp),%rsi
mov    -0x3003c(%rbp),%eax
shl    $0x7,%eax
cltq
add    %rax,%rsi
lea    -0x20030(%rbp),%rdx
mov    -0x3003c(%rbp),%eax
shl    $0x8,%eax
cltq
add    %rax,%rdx
lea    -0x30030(%rbp),%rcx
mov    -0x3003c(%rbp),%eax
shl    $0x8,%eax
cltq
add    %rax,%rcx
call   1030 <needwun@plt>
mov    -0x3003c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3003c(%rbp)
jmp    11bc <workload+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x30038(%rbp),%eax
shl    $0x10,%eax
cltq
add    %rax,%rdi
lea    -0x20030(%rbp),%rsi
mov    $0x10000,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30038(%rbp),%eax
shl    $0x10,%eax
cltq
add    %rax,%rdi
lea    -0x30030(%rbp),%rsi
mov    $0x10000,%edx
call   1040 <memcpy@plt>
mov    -0x30038(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30038(%rbp)
jmp    115a <workload+0x3a>
add    $0x30040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<workload>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
sub    $0x30030,%rsp
mov    %rcx,0x28(%rsp)
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
mov    %r8,0x8(%rsp)
cmp    $0x100,%r8d
jl     1254 <workload+0x134>
mov    0x8(%rsp),%rax
shr    $0x8,%eax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
lea    0x20030(%rsp),%r12
lea    0x10030(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rbp
shl    $0xf,%rbp
mov    0x10(%rsp),%rax
lea    (%rax,%rbp,1),%rsi
lea    0x8030(%rsp),%rdi
mov    $0x8000,%edx
call   1040 <memcpy@plt>
add    0x18(%rsp),%rbp
lea    0x30(%rsp),%rdi
mov    %rbp,%rsi
mov    $0x8000,%edx
call   1040 <memcpy@plt>
mov    %r12,%r15
mov    %r12,%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rsp,%r12,1),%rdi
add    $0x8030,%rdi
lea    (%rsp,%r12,1),%rsi
add    $0x30,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   1030 <needwun@plt>
sub    $0xffffffffffffff80,%r12
add    $0x100,%rbp
add    $0x100,%r14
cmp    $0x8000,%r12
jne    11d0 <workload+0xb0>
mov    %r13d,%ebp
shl    $0x10,%ebp
mov    0x20(%rsp),%rax
lea    (%rax,%rbp,1),%rdi
mov    %r15,%r12
mov    %r15,%rsi
mov    $0x10000,%edx
call   1040 <memcpy@plt>
add    0x28(%rsp),%rbp
mov    %rbp,%rdi
lea    0x10030(%rsp),%r14
mov    %r14,%rsi
mov    $0x10000,%edx
call   1040 <memcpy@plt>
add    $0x1,%r13
cmp    0x8(%rsp),%r13
jne    1180 <workload+0x60>
add    $0x30030,%rsp
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @workload(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [32768 x i8]
%12 = alloca [32768 x i8]
%13 = alloca [65536 x i8]
%14 = alloca [65536 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%19 = load i32, i32* %10
%20 = sdiv i32 %19, 256
store i32 %20, i32* %15
store i32 0, i32* %16
br label %21
21: ; preds = %83, %5
%22 = load i32, i32* %16
%23 = load i32, i32* %15
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %86
25: ; preds = %21
%26 = getelementptr inbounds [32768 x i8], [32768 x i8]* %11, i64 0, i64 0
%27 = load i8*, i8** %6
%28 = load i32, i32* %16
%29 = mul nsw i32 %28, 32768
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = call i32 @memcpy(i8* %26, i8* %31, i32 32768)
%33 = getelementptr inbounds [32768 x i8], [32768 x i8]* %12, i64 0, i64 0
%34 = load i8*, i8** %7
%35 = load i32, i32* %16
%36 = mul nsw i32 %35, 32768
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
%39 = call i32 @memcpy(i8* %33, i8* %38, i32 32768)
store i32 0, i32* %17
br label %40
40: ; preds = %65, %25
%41 = load i32, i32* %17
%42 = icmp slt i32 %41, 256
br i1 %42, label %43, label %68
43: ; preds = %40
%44 = getelementptr inbounds [32768 x i8], [32768 x i8]* %11, i64 0, i64 0
%45 = load i32, i32* %17
%46 = mul nsw i32 %45, 128
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
%49 = getelementptr inbounds [32768 x i8], [32768 x i8]* %12, i64 0, i64 0
%50 = load i32, i32* %17
%51 = mul nsw i32 %50, 128
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
%54 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
%55 = load i32, i32* %17
%56 = mul nsw i32 %55, 256
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %54, i64 %57
%59 = getelementptr inbounds [65536 x i8], [65536 x i8]* %14, i64 0, i64 0
%60 = load i32, i32* %17
%61 = mul nsw i32 %60, 256
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %59, i64 %62
%64 = call i32 @needwun(i8* %48, i8* %53, i8* %58, i8* %63)
br label %65
65: ; preds = %43
%66 = load i32, i32* %17
%67 = add nsw i32 %66, 1
store i32 %67, i32* %17
br label %40
68: ; preds = %40
%69 = load i8*, i8** %8
%70 = load i32, i32* %16
%71 = mul nsw i32 %70, 65536
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %69, i64 %72
%74 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
%75 = call i32 @memcpy(i8* %73, i8* %74, i32 65536)
%76 = load i8*, i8** %9
%77 = load i32, i32* %16
%78 = mul nsw i32 %77, 65536
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %76, i64 %79
%81 = getelementptr inbounds [65536 x i8], [65536 x i8]* %14, i64 0, i64 0
%82 = call i32 @memcpy(i8* %80, i8* %81, i32 65536)
br label %83
83: ; preds = %68
%84 = load i32, i32* %16
%85 = add nsw i32 %84, 1
store i32 %85, i32* %16
br label %21
86: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @workload(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [32768 x i8]
%7 = alloca [32768 x i8]
%8 = alloca [65536 x i8]
%9 = alloca [65536 x i8]
%10 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%14 = icmp sgt i32 %4, 255
br i1 %14, label %15, label %45
15: ; preds = %5
%16 = lshr i32 %4, 8
%17 = zext i32 %16 to i64
br label %18
18: ; preds = %15, %36
%19 = phi i64 [ 0, %15 ], [ %43, %36 ]
%20 = shl nsw i64 %19, 15
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = call i32 @memcpy(i8* %10, i8* %21, i32 32768)
%23 = getelementptr inbounds i8, i8* %1, i64 %20
%24 = call i32 @memcpy(i8* %11, i8* %23, i32 32768)
br label %25
25: ; preds = %18, %25
%26 = phi i64 [ 0, %18 ], [ %34, %25 ]
%27 = shl nuw nsw i64 %26, 7
%28 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 %27
%29 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 %27
%30 = shl nuw nsw i64 %26, 8
%31 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 %30
%32 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 %30
%33 = call i32 @needwun(i8* %28, i8* %29, i8* %31, i8* %32)
%34 = add nuw nsw i64 %26, 1
%35 = icmp eq i64 %34, 256
br i1 %35, label %36, label %25
36: ; preds = %25
%37 = shl i64 %19, 16
%38 = and i64 %37, 4294901760
%39 = getelementptr inbounds i8, i8* %2, i64 %38
%40 = call i32 @memcpy(i8* %39, i8* %12, i32 65536)
%41 = getelementptr inbounds i8, i8* %3, i64 %38
%42 = call i32 @memcpy(i8* %41, i8* %13, i32 65536)
%43 = add nuw nsw i64 %19, 1
%44 = icmp eq i64 %43, %17
br i1 %44, label %45, label %18
45: ; preds = %36, %5
ret void
}