#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 */
scalar_t__ cos(unsigned long);
float floor(scalar_t__);
int /*<<< orphan*/ four1(float *, int, int);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ prntft(float *, int);
scalar_t__ sin(unsigned long);
int /*<<< orphan*/ twofft(float *, float *, float *, float *, int);
float *vector(int, int);
int main(void) {
  unsigned long i;
  int isign;
  float *data1, *data2, *fft1, *fft2;
  data1 = vector(1, 32);
  data2 = vector(1, 32);
  fft1 = vector(1, (2 * 32));
  fft2 = vector(1, (2 * 32));
  for (i = 1; i <= 32; i++) {
    data1[i] = floor(0.5 + cos(i * 2.0 * 3.1415926 / 8));
    data2[i] = floor(0.5 + sin(i * 2.0 * 3.1415926 / 8));
  }
  twofft(data1, data2, fft1, fft2, 32);
  printf("Fourier transform of first function:\n");
  prntft(fft1, 32);
  printf("Fourier transform of second function:\n");
  prntft(fft2, 32);
  isign = -1;
  four1(fft1, 32, isign);
  printf("inverted transform  =  first function:\n");
  prntft(fft1, 32);
  four1(fft2, 32, isign);
  printf("inverted transform  =  second function:\n");
  prntft(fft2, 32);
  free_vector(fft2, 1, (2 * 32));
  free_vector(fft1, 1, (2 * 32));
  free_vector(data2, 1, 32);
  free_vector(data1, 1, 32);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x20,%esi
call   1070 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x20,%esi
call   1070 <vector@plt>
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
mov    $0x40,%esi
call   1070 <vector@plt>
mov    %rax,-0x30(%rbp)
mov    $0x1,%edi
mov    $0x40,%esi
call   1070 <vector@plt>
mov    %rax,-0x38(%rbp)
movq   $0x1,-0x10(%rbp)
cmpq   $0x20,-0x10(%rbp)
ja     1342 <main+0x1b2>
movq   -0x10(%rbp),%xmm0
movaps 0xe16(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xe16(%rip),%xmm1
movaps %xmm1,-0x60(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  0xdcf(%rip),%xmm1
movsd  %xmm1,-0x50(%rbp)
mulsd  %xmm1,%xmm0
movsd  0xdc6(%rip),%xmm1
movsd  %xmm1,-0x48(%rbp)
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
movsd  0xdae(%rip),%xmm1
movsd  %xmm1,-0x40(%rbp)
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1090 <cos@plt>
cvtsi2sd %rax,%xmm0
movsd  0xd70(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   10b0 <floor@plt>
movaps -0x70(%rbp),%xmm5
movaps -0x60(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movq   -0x10(%rbp),%xmm0
punpckldq %xmm5,%xmm0
subpd  %xmm4,%xmm0
movaps %xmm0,%xmm4
unpckhpd %xmm0,%xmm0
addsd  %xmm4,%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
movaps %xmm0,%xmm2
cvttsd2si %xmm2,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1060 <sin@plt>
cvtsi2sd %rax,%xmm1
movsd  0xcea(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   10b0 <floor@plt>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f3 <main+0x63>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x20,%r8d
call   1080 <twofft@plt>
lea    0xcdc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
lea    0xce8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x20,%esi
call   1050 <four1@plt>
lea    0xcdd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x20,%esi
call   1050 <four1@plt>
lea    0xcda(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x20,%edx
call   1040 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x20,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x20,%esi
call   1070 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x20,%esi
call   1070 <vector@plt>
mov    %rax,%r13
mov    $0x1,%edi
mov    $0x40,%esi
call   1070 <vector@plt>
mov    %rax,%r15
mov    $0x1,%edi
mov    $0x40,%esi
call   1070 <vector@plt>
mov    %rax,%r12
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
movq   %rbp,%xmm0
punpckldq 0xe03(%rip),%xmm0
subpd  0xe0b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
mulsd  0xe03(%rip),%xmm1
mulsd  0xe03(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xdf7(%rip),%xmm1
cvttsd2si %xmm1,%rbx
and    %rcx,%rbx
or     %rax,%rbx
mov    %rbx,%rdi
call   1090 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0xddc(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   10b0 <floor@plt>
movss  %xmm0,(%r14,%rbp,4)
mov    %rbx,%rdi
call   1060 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xdb0(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   10b0 <floor@plt>
movss  %xmm0,0x0(%r13,%rbp,4)
add    $0x1,%rbp
cmp    $0x21,%rbp
jne    11f0 <main+0x60>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0x20,%r8d
call   1080 <twofft@plt>
lea    0xd7b(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
lea    0xd87(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
mov    %r15,%rdi
mov    $0x20,%esi
mov    $0xffffffff,%edx
call   1050 <four1@plt>
lea    0xd82(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
mov    %r12,%rdi
mov    $0x20,%esi
mov    $0xffffffff,%edx
call   1050 <four1@plt>
lea    0xd7e(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    $0x20,%esi
call   10a0 <prntft@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <free_vector@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x20,%edx
call   1040 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x20,%edx
call   1040 <free_vector@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Fourier transform of first function:\0A\00"
@.str.1 = [39 x i8] c"Fourier transform of second function:\0A\00"
@.str.2 = [40 x i8] c"inverted transform = first function:\0A\00"
@.str.3 = [41 x i8] c"inverted transform = second function:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
store i32 0, i32* %1
%8 = call float* @vector(i32 1, i32 32)
store float* %8, float** %4
%9 = call float* @vector(i32 1, i32 32)
store float* %9, float** %5
%10 = call float* @vector(i32 1, i32 64)
store float* %10, float** %6
%11 = call float* @vector(i32 1, i32 64)
store float* %11, float** %7
store i64 1, i64* %2
br label %12
12: ; preds = %44, %0
%13 = load i64, i64* %2
%14 = icmp ule i64 %13, 32
br i1 %14, label %15, label %47
15: ; preds = %12
%16 = load i64, i64* %2
%17 = uitofp i64 %16 to double
%18 = fmul double %17, 2.000000e+00
%19 = fmul double %18, 0x400921FB4D12D84A
%20 = fdiv double %19, 8.000000e+00
%21 = fptoui double %20 to i64
%22 = call i64 @cos(i64 %21)
%23 = sitofp i64 %22 to double
%24 = fadd double 5.000000e-01, %23
%25 = fptosi double %24 to i64
%26 = call float @floor(i64 %25)
%27 = load float*, float** %4
%28 = load i64, i64* %2
%29 = getelementptr inbounds float, float* %27, i64 %28
store float %26, float* %29
%30 = load i64, i64* %2
%31 = uitofp i64 %30 to double
%32 = fmul double %31, 2.000000e+00
%33 = fmul double %32, 0x400921FB4D12D84A
%34 = fdiv double %33, 8.000000e+00
%35 = fptoui double %34 to i64
%36 = call i64 @sin(i64 %35)
%37 = sitofp i64 %36 to double
%38 = fadd double 5.000000e-01, %37
%39 = fptosi double %38 to i64
%40 = call float @floor(i64 %39)
%41 = load float*, float** %5
%42 = load i64, i64* %2
%43 = getelementptr inbounds float, float* %41, i64 %42
store float %40, float* %43
br label %44
44: ; preds = %15
%45 = load i64, i64* %2
%46 = add i64 %45, 1
store i64 %46, i64* %2
br label %12
47: ; preds = %12
%48 = load float*, float** %4
%49 = load float*, float** %5
%50 = load float*, float** %6
%51 = load float*, float** %7
%52 = call i32 @twofft(float* %48, float* %49, float* %50, float* %51, i32 32)
%53 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%54 = load float*, float** %6
%55 = call i32 @prntft(float* %54, i32 32)
%56 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%57 = load float*, float** %7
%58 = call i32 @prntft(float* %57, i32 32)
store i32 -1, i32* %3
%59 = load float*, float** %6
%60 = load i32, i32* %3
%61 = call i32 @four1(float* %59, i32 32, i32 %60)
%62 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%63 = load float*, float** %6
%64 = call i32 @prntft(float* %63, i32 32)
%65 = load float*, float** %7
%66 = load i32, i32* %3
%67 = call i32 @four1(float* %65, i32 32, i32 %66)
%68 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%69 = load float*, float** %7
%70 = call i32 @prntft(float* %69, i32 32)
%71 = load float*, float** %7
%72 = call i32 @free_vector(float* %71, i32 1, i32 64)
%73 = load float*, float** %6
%74 = call i32 @free_vector(float* %73, i32 1, i32 64)
%75 = load float*, float** %5
%76 = call i32 @free_vector(float* %75, i32 1, i32 32)
%77 = load float*, float** %4
%78 = call i32 @free_vector(float* %77, i32 1, i32 32)
ret i32 0
}

LLVM IR (-O2):
@str = [37 x i8] c"Fourier transform of first function:\00"
@str.4 = [38 x i8] c"Fourier transform of second function:\00"
@str.5 = [39 x i8] c"inverted transform = first function:\00"
@str.6 = [40 x i8] c"inverted transform = second function:\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 32)
%2 = tail call float* @vector(i32 1, i32 32)
%3 = tail call float* @vector(i32 1, i32 64)
%4 = tail call float* @vector(i32 1, i32 64)
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 1, %0 ], [ %24, %5 ]
%7 = uitofp i64 %6 to double
%8 = fmul double %7, 2.000000e+00
%9 = fmul double %8, 0x400921FB4D12D84A
%10 = fmul double %9, 1.250000e-01
%11 = fptoui double %10 to i64
%12 = tail call i64 @cos(i64 %11)
%13 = sitofp i64 %12 to double
%14 = fadd double %13, 5.000000e-01
%15 = fptosi double %14 to i64
%16 = tail call float @floor(i64 %15)
%17 = getelementptr inbounds float, float* %1, i64 %6
store float %16, float* %17
%18 = tail call i64 @sin(i64 %11)
%19 = sitofp i64 %18 to double
%20 = fadd double %19, 5.000000e-01
%21 = fptosi double %20 to i64
%22 = tail call float @floor(i64 %21)
%23 = getelementptr inbounds float, float* %2, i64 %6
store float %22, float* %23
%24 = add nuw nsw i64 %6, 1
%25 = icmp eq i64 %24, 33
br i1 %25, label %26, label %5
26: ; preds = %5
%27 = tail call i32 @twofft(float* %1, float* %2, float* %3, float* %4, i32 32)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @prntft(float* %3, i32 32)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.4, i64 0, i64 0))
%31 = tail call i32 @prntft(float* %4, i32 32)
%32 = tail call i32 @four1(float* %3, i32 32, i32 -1)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
%34 = tail call i32 @prntft(float* %3, i32 32)
%35 = tail call i32 @four1(float* %4, i32 32, i32 -1)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
%37 = tail call i32 @prntft(float* %4, i32 32)
%38 = tail call i32 @free_vector(float* %4, i32 1, i32 64)
%39 = tail call i32 @free_vector(float* %3, i32 1, i32 64)
%40 = tail call i32 @free_vector(float* %2, i32 1, i32 32)
%41 = tail call i32 @free_vector(float* %1, i32 1, i32 32)
ret i32 0
}