#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 */
unsigned int atoi(char *);
float cos(float);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fft_float(unsigned int, int, float *, float *, float *,
                             float *);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
float sin(float);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  unsigned MAXSIZE;
  unsigned MAXWAVES;
  unsigned i, j;
  float *RealIn;
  float *ImagIn;
  float *RealOut;
  float *ImagOut;
  float *coeff;
  float *amp;
  int invfft = 0;
  if (argc < 3) {
    printf("Usage: fft <waves> <length> -i\n");
    printf("-i performs an inverse fft\n");
    printf("make <waves> random sinusoids");
    printf("<length> is the number of samples\n");
    exit(-1);
  } else if (argc == 4)
    invfft = !strncmp(argv[3], "-i", 2);
  MAXSIZE = atoi(argv[2]);
  MAXWAVES = atoi(argv[1]);
  srand(1);
  RealIn = (float *)malloc(sizeof(float) * MAXSIZE);
  ImagIn = (float *)malloc(sizeof(float) * MAXSIZE);
  RealOut = (float *)malloc(sizeof(float) * MAXSIZE);
  ImagOut = (float *)malloc(sizeof(float) * MAXSIZE);
  coeff = (float *)malloc(sizeof(float) * MAXWAVES);
  amp = (float *)malloc(sizeof(float) * MAXWAVES);
  for (i = 0; i < MAXWAVES; i++) {
    coeff[i] = rand() % 1000;
    amp[i] = rand() % 1000;
  }
  for (i = 0; i < MAXSIZE; i++) {
    RealIn[i] = 0;
    for (j = 0; j < MAXWAVES; j++) {
      if (rand() % 2) {
        RealIn[i] += coeff[j] * cos(amp[j] * i);
      } else {
        RealIn[i] += coeff[j] * sin(amp[j] * i);
      }
      ImagIn[i] = 0;
    }
  }
  fft_float(MAXSIZE, invfft, RealIn, ImagIn, RealOut, ImagOut);
  printf("RealOut:\n");
  for (i = 0; i < MAXSIZE; i++)
    printf("%f \t", RealOut[i]);
  printf("\n");
  printf("ImagOut:\n");
  for (i = 0; i < MAXSIZE; i++)
    printf("%f \t", ImagOut[i]);
  printf("\n");
  free(RealIn);
  free(ImagIn);
  free(RealOut);
  free(ImagOut);
  free(coeff);
  free(amp);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1219 <main+0x69>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    124c <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x54(%rbp)
jmp    1251 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    $0x1,%edi
call   1060 <srand@plt>
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1346 <main+0x196>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
mov    -0x48(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
mov    -0x50(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12ee <main+0x13e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1460 <main+0x2b0>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    144d <main+0x29d>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     13e4 <main+0x234>
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
mov    -0x1c(%rbp),%eax
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
call   10a0 <cos@plt>
movaps %xmm0,%xmm2
movss  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    1430 <main+0x280>
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
mov    -0x1c(%rbp),%eax
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm2
movss  -0x5c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    136f <main+0x1bf>
jmp    1452 <main+0x2a2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    134d <main+0x19d>
mov    -0x14(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
call   1080 <fft_float@plt>
lea    0xbfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    14c8 <main+0x318>
mov    -0x38(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd7(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1490 <main+0x2e0>
lea    0xbc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1523 <main+0x373>
mov    -0x40(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb7c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14eb <main+0x33b>
lea    0xb6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jg     121f <main+0x4f>
lea    0xe4b(%rip),%rdi
call   1060 <puts@plt>
lea    0xe5e(%rip),%rdi
call   1060 <puts@plt>
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe5f(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    %rsi,%rbx
xor    %ecx,%ecx
cmp    $0x4,%edi
jne    1245 <main+0x75>
mov    0x18(%rbx),%rdi
lea    0xe1d(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,0x10(%rsp)
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r15d
mov    $0x1,%edi
call   1080 <srand@plt>
mov    %rbp,0x20(%rsp)
lea    0x0(,%rbp,4),%ebp
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0x0(,%r15,4),%ebp
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %r15d,%r12d
mov    %r15,0x40(%rsp)
test   %r15d,%r15d
je     1341 <main+0x171>
xor    %ebp,%ebp
nop
xor    %eax,%eax
call   10f0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%r14,%rbp,4)
xor    %eax,%eax
call   10f0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    0x28(%rsp),%rax
movss  %xmm0,(%rax,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    12d0 <main+0x100>
mov    0x20(%rsp),%rdi
test   %edi,%edi
mov    %r13,0x38(%rsp)
jne    1379 <main+0x1a9>
mov    0x10(%rsp),%esi
mov    %rbx,%rdx
mov    0x18(%rsp),%rcx
mov    %r13,%r8
mov    0x8(%rsp),%r9
call   10a0 <fft_float@plt>
lea    0xcb4(%rip),%rdi
call   1060 <puts@plt>
jmp    14ad <main+0x2dd>
mov    %edi,%ecx
xor    %r15d,%r15d
mov    0x8(%rsp),%r9
mov    %rcx,%r13
jmp    139d <main+0x1cd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %rcx,%r15
je     143a <main+0x26a>
movl   $0x0,(%rbx,%r15,4)
cmpl   $0x0,0x40(%rsp)
je     1390 <main+0x1c0>
mov    %r15d,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x34(%rsp)
xor    %ebp,%ebp
jmp    1409 <main+0x239>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1090 <sin@plt>
movss  0x14(%rsp),%xmm1
mov    0x8(%rsp),%r9
mov    %r13,%rcx
mulss  %xmm0,%xmm1
addss  (%rbx,%r15,4),%xmm1
movss  %xmm1,(%rbx,%r15,4)
mov    0x18(%rsp),%rax
movl   $0x0,(%rax,%r15,4)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1390 <main+0x1c0>
xor    %eax,%eax
call   10f0 <rand@plt>
mov    %r14,%rcx
movss  (%r14,%rbp,4),%xmm1
mov    0x28(%rsp),%rcx
movss  (%rcx,%rbp,4),%xmm0
mulss  0x34(%rsp),%xmm0
test   $0x1,%al
movss  %xmm1,0x14(%rsp)
je     13d0 <main+0x200>
call   10c0 <cos@plt>
jmp    13d5 <main+0x205>
mov    0x20(%rsp),%rbp
mov    %ebp,%edi
mov    0x10(%rsp),%esi
mov    %rbx,%rdx
mov    0x18(%rsp),%rcx
mov    0x38(%rsp),%r15
mov    %r15,%r8
call   10a0 <fft_float@plt>
lea    0xbc2(%rip),%rdi
call   1060 <puts@plt>
test   %ebp,%ebp
jne    1487 <main+0x2b7>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xbb1(%rip),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%r13
jmp    14fe <main+0x32e>
xor    %ebp,%ebp
lea    0xb8e(%rip),%r12
movss  (%r15,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1490 <main+0x2c0>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xb6e(%rip),%rdi
call   1060 <puts@plt>
mov    0x20(%rsp),%rax
test   %eax,%eax
mov    0x8(%rsp),%r13
je     14fe <main+0x32e>
mov    %eax,%r12d
xor    %ebp,%ebp
lea    0xb41(%rip),%r15
nopl   (%rax)
movss  0x0(%r13,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    14e0 <main+0x310>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: fft <waves> <length> -i\0A\00"
@.str.1 = [28 x i8] c"-i performs an inverse fft\0A\00"
@.str.2 = [30 x i8] c"make <waves> random sinusoids\00"
@.str.3 = [35 x i8] c"<length> is the number of samples\0A\00"
@.str.4 = [3 x i8] c"-i\00"
@.str.5 = [10 x i8] c"RealOut:\0A\00"
@.str.6 = [5 x i8] c"%f \09\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [10 x i8] c"ImagOut:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %16
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %2
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
%35 = zext i1 %34 to i32
store i32 %35, i32* %16
br label %36
36: ; preds = %28, %25
br label %37
37: ; preds = %36
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %6
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %7
%46 = call i32 @srand(i32 1)
%47 = load i32, i32* %6
%48 = zext i32 %47 to i64
%49 = mul i64 4, %48
%50 = trunc i64 %49 to i32
%51 = call i64 @malloc(i32 %50)
%52 = inttoptr i64 %51 to float*
store float* %52, float** %10
%53 = load i32, i32* %6
%54 = zext i32 %53 to i64
%55 = mul i64 4, %54
%56 = trunc i64 %55 to i32
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to float*
store float* %58, float** %11
%59 = load i32, i32* %6
%60 = zext i32 %59 to i64
%61 = mul i64 4, %60
%62 = trunc i64 %61 to i32
%63 = call i64 @malloc(i32 %62)
%64 = inttoptr i64 %63 to float*
store float* %64, float** %12
%65 = load i32, i32* %6
%66 = zext i32 %65 to i64
%67 = mul i64 4, %66
%68 = trunc i64 %67 to i32
%69 = call i64 @malloc(i32 %68)
%70 = inttoptr i64 %69 to float*
store float* %70, float** %13
%71 = load i32, i32* %7
%72 = zext i32 %71 to i64
%73 = mul i64 4, %72
%74 = trunc i64 %73 to i32
%75 = call i64 @malloc(i32 %74)
%76 = inttoptr i64 %75 to float*
store float* %76, float** %14
%77 = load i32, i32* %7
%78 = zext i32 %77 to i64
%79 = mul i64 4, %78
%80 = trunc i64 %79 to i32
%81 = call i64 @malloc(i32 %80)
%82 = inttoptr i64 %81 to float*
store float* %82, float** %15
store i32 0, i32* %8
br label %83
83: ; preds = %102, %37
%84 = load i32, i32* %8
%85 = load i32, i32* %7
%86 = icmp ult i32 %84, %85
br i1 %86, label %87, label %105
87: ; preds = %83
%88 = call i32 (...) @rand()
%89 = srem i32 %88, 1000
%90 = sitofp i32 %89 to float
%91 = load float*, float** %14
%92 = load i32, i32* %8
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds float, float* %91, i64 %93
store float %90, float* %94
%95 = call i32 (...) @rand()
%96 = srem i32 %95, 1000
%97 = sitofp i32 %96 to float
%98 = load float*, float** %15
%99 = load i32, i32* %8
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds float, float* %98, i64 %100
store float %97, float* %101
br label %102
102: ; preds = %87
%103 = load i32, i32* %8
%104 = add i32 %103, 1
store i32 %104, i32* %8
br label %83
105: ; preds = %83
store i32 0, i32* %8
br label %106
106: ; preds = %174, %105
%107 = load i32, i32* %8
%108 = load i32, i32* %6
%109 = icmp ult i32 %107, %108
br i1 %109, label %110, label %177
110: ; preds = %106
%111 = load float*, float** %10
%112 = load i32, i32* %8
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds float, float* %111, i64 %113
store float 0.000000e+00, float* %114
store i32 0, i32* %9
br label %115
115: ; preds = %170, %110
%116 = load i32, i32* %9
%117 = load i32, i32* %7
%118 = icmp ult i32 %116, %117
br i1 %118, label %119, label %173
119: ; preds = %115
%120 = call i32 (...) @rand()
%121 = srem i32 %120, 2
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %144
123: ; preds = %119
%124 = load float*, float** %14
%125 = load i32, i32* %9
%126 = zext i32 %125 to i64
%127 = getelementptr inbounds float, float* %124, i64 %126
%128 = load float, float* %127
%129 = load float*, float** %15
%130 = load i32, i32* %9
%131 = zext i32 %130 to i64
%132 = getelementptr inbounds float, float* %129, i64 %131
%133 = load float, float* %132
%134 = load i32, i32* %8
%135 = uitofp i32 %134 to float
%136 = fmul float %133, %135
%137 = call float @cos(float %136)
%138 = load float*, float** %10
%139 = load i32, i32* %8
%140 = zext i32 %139 to i64
%141 = getelementptr inbounds float, float* %138, i64 %140
%142 = load float, float* %141
%143 = call float @llvm.fmuladd.f32(float %128, float %137, float %142)
store float %143, float* %141
br label %165
144: ; preds = %119
%145 = load float*, float** %14
%146 = load i32, i32* %9
%147 = zext i32 %146 to i64
%148 = getelementptr inbounds float, float* %145, i64 %147
%149 = load float, float* %148
%150 = load float*, float** %15
%151 = load i32, i32* %9
%152 = zext i32 %151 to i64
%153 = getelementptr inbounds float, float* %150, i64 %152
%154 = load float, float* %153
%155 = load i32, i32* %8
%156 = uitofp i32 %155 to float
%157 = fmul float %154, %156
%158 = call float @sin(float %157)
%159 = load float*, float** %10
%160 = load i32, i32* %8
%161 = zext i32 %160 to i64
%162 = getelementptr inbounds float, float* %159, i64 %161
%163 = load float, float* %162
%164 = call float @llvm.fmuladd.f32(float %149, float %158, float %163)
store float %164, float* %162
br label %165
165: ; preds = %144, %123
%166 = load float*, float** %11
%167 = load i32, i32* %8
%168 = zext i32 %167 to i64
%169 = getelementptr inbounds float, float* %166, i64 %168
store float 0.000000e+00, float* %169
br label %170
170: ; preds = %165
%171 = load i32, i32* %9
%172 = add i32 %171, 1
store i32 %172, i32* %9
br label %115
173: ; preds = %115
br label %174
174: ; preds = %173
%175 = load i32, i32* %8
%176 = add i32 %175, 1
store i32 %176, i32* %8
br label %106
177: ; preds = %106
%178 = load i32, i32* %6
%179 = load i32, i32* %16
%180 = load float*, float** %10
%181 = load float*, float** %11
%182 = load float*, float** %12
%183 = load float*, float** %13
%184 = call i32 @fft_float(i32 %178, i32 %179, float* %180, float* %181, float* %182, float* %183)
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %8
br label %186
186: ; preds = %198, %177
%187 = load i32, i32* %8
%188 = load i32, i32* %6
%189 = icmp ult i32 %187, %188
br i1 %189, label %190, label %201
190: ; preds = %186
%191 = load float*, float** %12
%192 = load i32, i32* %8
%193 = zext i32 %192 to i64
%194 = getelementptr inbounds float, float* %191, i64 %193
%195 = load float, float* %194
%196 = fpext float %195 to double
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %196)
br label %198
198: ; preds = %190
%199 = load i32, i32* %8
%200 = add i32 %199, 1
store i32 %200, i32* %8
br label %186
201: ; preds = %186
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %8
br label %204
204: ; preds = %216, %201
%205 = load i32, i32* %8
%206 = load i32, i32* %6
%207 = icmp ult i32 %205, %206
br i1 %207, label %208, label %219
208: ; preds = %204
%209 = load float*, float** %13
%210 = load i32, i32* %8
%211 = zext i32 %210 to i64
%212 = getelementptr inbounds float, float* %209, i64 %211
%213 = load float, float* %212
%214 = fpext float %213 to double
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %214)
br label %216
216: ; preds = %208
%217 = load i32, i32* %8
%218 = add i32 %217, 1
store i32 %218, i32* %8
br label %204
219: ; preds = %204
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%221 = load float*, float** %10
%222 = call i32 @free(float* %221)
%223 = load float*, float** %11
%224 = call i32 @free(float* %223)
%225 = load float*, float** %12
%226 = call i32 @free(float* %225)
%227 = load float*, float** %13
%228 = call i32 @free(float* %227)
%229 = load float*, float** %14
%230 = call i32 @free(float* %229)
%231 = load float*, float** %15
%232 = call i32 @free(float* %231)
%233 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.2 = [30 x i8] c"make <waves> random sinusoids\00"
@.str.4 = [3 x i8] c"-i\00"
@.str.6 = [5 x i8] c"%f \09\00"
@str = [9 x i8] c"RealOut:\00"
@str.9 = [9 x i8] c"ImagOut:\00"
@str.10 = [31 x i8] c"Usage: fft <waves> <length> -i\00"
@str.11 = [27 x i8] c"-i performs an inverse fft\00"
@str.12 = [34 x i8] c"<length> is the number of samples\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = icmp eq i32 %0, 4
br i1 %11, label %12, label %18
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i32 @strncmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %10, %12
%19 = phi i32 [ %17, %12 ], [ 0, %10 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = tail call i32 @srand(i32 1)
%27 = shl i32 %22, 2
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to float*
%30 = tail call i64 @malloc(i32 %27)
%31 = inttoptr i64 %30 to float*
%32 = tail call i64 @malloc(i32 %27)
%33 = inttoptr i64 %32 to float*
%34 = tail call i64 @malloc(i32 %27)
%35 = inttoptr i64 %34 to float*
%36 = shl i32 %25, 2
%37 = tail call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to float*
%39 = tail call i64 @malloc(i32 %36)
%40 = inttoptr i64 %39 to float*
%41 = icmp eq i32 %25, 0
br i1 %41, label %44, label %42
42: ; preds = %18
%43 = zext i32 %25 to i64
br label %49
44: ; preds = %49, %18
%45 = icmp eq i32 %22, 0
br i1 %45, label %104, label %46
46: ; preds = %44
%47 = zext i32 %22 to i64
%48 = zext i32 %25 to i64
br label %61
49: ; preds = %42, %49
%50 = phi i64 [ 0, %42 ], [ %59, %49 ]
%51 = tail call i32 (...) @rand()
%52 = srem i32 %51, 1000
%53 = sitofp i32 %52 to float
%54 = getelementptr inbounds float, float* %38, i64 %50
store float %53, float* %54
%55 = tail call i32 (...) @rand()
%56 = srem i32 %55, 1000
%57 = sitofp i32 %56 to float
%58 = getelementptr inbounds float, float* %40, i64 %50
store float %57, float* %58
%59 = add nuw nsw i64 %50, 1
%60 = icmp eq i64 %59, %43
br i1 %60, label %44, label %49
61: ; preds = %46, %88
%62 = phi i64 [ 0, %46 ], [ %89, %88 ]
%63 = getelementptr inbounds float, float* %29, i64 %62
store float 0.000000e+00, float* %63
br i1 %41, label %88, label %64
64: ; preds = %61
%65 = trunc i64 %62 to i32
%66 = uitofp i32 %65 to float
%67 = getelementptr inbounds float, float* %31, i64 %62
br label %68
68: ; preds = %64, %82
%69 = phi i64 [ 0, %64 ], [ %86, %82 ]
%70 = tail call i32 (...) @rand()
%71 = and i32 %70, 1
%72 = icmp eq i32 %71, 0
%73 = getelementptr inbounds float, float* %38, i64 %69
%74 = load float, float* %73
%75 = getelementptr inbounds float, float* %40, i64 %69
%76 = load float, float* %75
%77 = fmul float %76, %66
br i1 %72, label %80, label %78
78: ; preds = %68
%79 = tail call float @cos(float %77)
br label %82
80: ; preds = %68
%81 = tail call float @sin(float %77)
br label %82
82: ; preds = %80, %78
%83 = phi float [ %81, %80 ], [ %79, %78 ]
%84 = load float, float* %63
%85 = tail call float @llvm.fmuladd.f32(float %74, float %83, float %84)
store float %85, float* %63
store float 0.000000e+00, float* %67
%86 = add nuw nsw i64 %69, 1
%87 = icmp eq i64 %86, %48
br i1 %87, label %88, label %68
88: ; preds = %82, %61
%89 = add nuw nsw i64 %62, 1
%90 = icmp eq i64 %89, %47
br i1 %90, label %91, label %61
91: ; preds = %88
%92 = tail call i32 @fft_float(i32 %22, i32 %19, float* %29, float* %31, float* %33, float* %35)
%93 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br i1 %45, label %120, label %94
94: ; preds = %91
%95 = zext i32 %22 to i64
br label %96
96: ; preds = %94, %96
%97 = phi i64 [ 0, %94 ], [ %102, %96 ]
%98 = getelementptr inbounds float, float* %33, i64 %97
%99 = load float, float* %98
%100 = fpext float %99 to double
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %100)
%102 = add nuw nsw i64 %97, 1
%103 = icmp eq i64 %102, %95
br i1 %103, label %107, label %96
104: ; preds = %44
%105 = tail call i32 @fft_float(i32 %22, i32 %19, float* %29, float* %31, float* %33, float* %35)
%106 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %107
107: ; preds = %96, %104
%108 = tail call i32 @putchar(i32 10)
%109 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br i1 %45, label %123, label %110
110: ; preds = %107
%111 = zext i32 %22 to i64
br label %112
112: ; preds = %110, %112
%113 = phi i64 [ 0, %110 ], [ %118, %112 ]
%114 = getelementptr inbounds float, float* %35, i64 %113
%115 = load float, float* %114
%116 = fpext float %115 to double
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), double %116)
%118 = add nuw nsw i64 %113, 1
%119 = icmp eq i64 %118, %111
br i1 %119, label %123, label %112
120: ; preds = %91
%121 = tail call i32 @putchar(i32 10)
%122 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br label %123
123: ; preds = %112, %120, %107
%124 = tail call i32 @putchar(i32 10)
%125 = tail call i32 @free(float* %29)
%126 = tail call i32 @free(float* %31)
%127 = tail call i32 @free(float* %33)
%128 = tail call i32 @free(float* %35)
%129 = tail call i32 @free(float* %38)
%130 = tail call i32 @free(float* %40)
%131 = tail call i32 @exit(i32 0)
unreachable
}