#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*/ fft(double *, double *, double *, double *);
void workload(double *real, double *img, double *real_twid, double *img_twid,
              int num_imgs) {
#pragma HLS INTERFACE m_axi port = real offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = img offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = real_twid offset = slave bundle = gmem
#pragma HLS INTERFACE m_axi port = img_twid offset = slave bundle = gmem
#pragma HLS INTERFACE s_axilite port = real bundle = control
#pragma HLS INTERFACE s_axilite port = img bundle = control
#pragma HLS INTERFACE s_axilite port = real_twid bundle = control
#pragma HLS INTERFACE s_axilite port = img_twid bundle = control
#pragma HLS INTERFACE s_axilite port = num_imgs bundle = control
#pragma HLS INTERFACE s_axilite port = return bundle = control
  for (int i = 0; i < num_imgs; i++) {
    fft(real + i * (1 << 16), img + i * (1 << 16),
        real_twid + i * (1 << 16) / 2, img_twid + i * (1 << 16) / 2);
  }
  return;
}


x86 assembly (clang, -O0):
<workload>:
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    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c3 <workload+0xb3>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
shl    $0x10,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%eax
shl    $0x10,%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x10,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%eax
shl    $0x10,%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%rdx
cltq
shl    $0x3,%rax
add    %rax,%rcx
call   1030 <fft@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1133 <workload+0x23>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<workload>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r8d,%r8d
jle    1163 <workload+0x53>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %r8d,%r13d
nopl   (%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <fft@plt>
add    $0x80000,%r12
add    $0x80000,%rbx
add    $0x40000,%r14
add    $0x40000,%r15
add    $0xffffffffffffffff,%r13
jne    1130 <workload+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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