#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*/ sms_PolarToRect(int, double *, double *, double *);
int /*<<< orphan*/ sms_ifft(int, double *);
int sms_invSpectrum(int sizeWaveform, double *pWaveform, double *pWindow,
                    int sizeMag, double *pMag, double *pPhase,
                    double *pFftBuffer) {
  int i;
  int sizeFft = sizeMag << 1;
  sms_PolarToRect(sizeMag, pFftBuffer, pMag, pPhase);
  sms_ifft(sizeFft, pFftBuffer);
  for (i = 0; i < sizeWaveform; i++)
    pWaveform[i] = pFftBuffer[i];
  return sizeFft;
}


x86 assembly (clang, -O0):
<sms_invSpectrum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <sms_PolarToRect@plt>
mov    -0x38(%rbp),%edi
mov    0x10(%rbp),%rsi
call   1040 <sms_ifft@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a6 <sms_invSpectrum+0x86>
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1172 <sms_invSpectrum+0x52>
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sms_invSpectrum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%rdx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x30(%rsp),%r14
lea    (%rcx,%rcx,1),%r15d
mov    %ecx,%edi
mov    %r14,%rsi
mov    %r9,%rcx
call   1030 <sms_PolarToRect@plt>
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <sms_ifft@plt>
test   %ebp,%ebp
jle    12c4 <sms_invSpectrum+0x1a4>
mov    %ebp,%eax
cmp    $0x4,%ebp
jb     1179 <sms_invSpectrum+0x59>
lea    (%r14,%rax,8),%rcx
cmp    %rbx,%rcx
jbe    11f0 <sms_invSpectrum+0xd0>
lea    (%rbx,%rax,8),%rcx
cmp    %r14,%rcx
jbe    11f0 <sms_invSpectrum+0xd0>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
mov    %rax,%rsi
and    $0x3,%rsi
je     11a5 <sms_invSpectrum+0x85>
nopl   (%rax)
movsd  (%r14,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1190 <sms_invSpectrum+0x70>
cmp    $0x3,%rdx
jb     12c4 <sms_invSpectrum+0x1a4>
nop
movsd  (%r14,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
movsd  0x8(%r14,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rcx,8)
movsd  0x10(%r14,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rcx,8)
movsd  0x18(%r14,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    11b0 <sms_invSpectrum+0x90>
jmp    12c4 <sms_invSpectrum+0x1a4>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0xc,%rdi
jae    1213 <sms_invSpectrum+0xf3>
xor    %edi,%edi
jmp    1280 <sms_invSpectrum+0x160>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
nopl   0x0(%rax)
movups (%r14,%rdi,8),%xmm0
movups 0x10(%r14,%rdi,8),%xmm1
movups %xmm0,(%rbx,%rdi,8)
movups %xmm1,0x10(%rbx,%rdi,8)
movups 0x20(%r14,%rdi,8),%xmm0
movups 0x30(%r14,%rdi,8),%xmm1
movups %xmm0,0x20(%rbx,%rdi,8)
movups %xmm1,0x30(%rbx,%rdi,8)
movups 0x40(%r14,%rdi,8),%xmm0
movups 0x50(%r14,%rdi,8),%xmm1
movups %xmm0,0x40(%rbx,%rdi,8)
movups %xmm1,0x50(%rbx,%rdi,8)
movups 0x60(%r14,%rdi,8),%xmm0
movups 0x70(%r14,%rdi,8),%xmm1
movups %xmm0,0x60(%rbx,%rdi,8)
movups %xmm1,0x70(%rbx,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1220 <sms_invSpectrum+0x100>
test   %rdx,%rdx
je     12bb <sms_invSpectrum+0x19b>
lea    (%rbx,%rdi,8),%rsi
add    $0x10,%rsi
lea    (%r14,%rdi,8),%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movups -0x10(%rdi,%rbp,1),%xmm0
movups (%rdi,%rbp,1),%xmm1
movups %xmm0,-0x10(%rsi,%rbp,1)
movups %xmm1,(%rsi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%rdx
jne    12a0 <sms_invSpectrum+0x180>
cmp    %rax,%rcx
jne    117b <sms_invSpectrum+0x5b>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @sms_invSpectrum(i32 %0, double* nocapture writeonly %1, double* nocapture readnone %2, i32 %3, double* %4, double* %5, double* %6) {
%8 = shl i32 %3, 1
%9 = tail call i32 @sms_PolarToRect(i32 %3, double* %6, double* %4, double* %5)
%10 = tail call i32 @sms_ifft(i32 %8, double* %6)
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %137
12: ; preds = %7
%13 = zext i32 %0 to i64
%14 = icmp ult i32 %0, 4
br i1 %14, label %100, label %15
15: ; preds = %12
%16 = getelementptr double, double* %1, i64 %13
%17 = getelementptr double, double* %6, i64 %13
%18 = icmp ugt double* %17, %1
%19 = icmp ugt double* %16, %6
%20 = and i1 %18, %19
br i1 %20, label %100, label %21
21: ; preds = %15
%22 = and i64 %13, 4294967292
%23 = add nsw i64 %22, -4
%24 = lshr exact i64 %23, 2
%25 = add nuw nsw i64 %24, 1
%26 = and i64 %25, 3
%27 = icmp ult i64 %23, 12
br i1 %27, label %79, label %28
28: ; preds = %21
%29 = and i64 %25, 9223372036854775804
br label %30
30: ; preds = %30, %28
%31 = phi i64 [ 0, %28 ], [ %76, %30 ]
%32 = phi i64 [ 0, %28 ], [ %77, %30 ]
%33 = getelementptr inbounds double, double* %6, i64 %31
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = getelementptr inbounds double, double* %33, i64 2
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = getelementptr inbounds double, double* %1, i64 %31
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> %35, <2 x double>* %40
%41 = getelementptr inbounds double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> %38, <2 x double>* %42
%43 = or i64 %31, 4
%44 = getelementptr inbounds double, double* %6, i64 %43
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %1, i64 %43
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %46, <2 x double>* %51
%52 = getelementptr inbounds double, double* %50, i64 2
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %49, <2 x double>* %53
%54 = or i64 %31, 8
%55 = getelementptr inbounds double, double* %6, i64 %54
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %1, i64 %54
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %57, <2 x double>* %62
%63 = getelementptr inbounds double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %60, <2 x double>* %64
%65 = or i64 %31, 12
%66 = getelementptr inbounds double, double* %6, i64 %65
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %66, i64 2
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %1, i64 %65
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> %68, <2 x double>* %73
%74 = getelementptr inbounds double, double* %72, i64 2
%75 = bitcast double* %74 to <2 x double>*
store <2 x double> %71, <2 x double>* %75
%76 = add nuw i64 %31, 16
%77 = add nuw i64 %32, 4
%78 = icmp eq i64 %77, %29
br i1 %78, label %79, label %30
79: ; preds = %30, %21
%80 = phi i64 [ 0, %21 ], [ %76, %30 ]
%81 = icmp eq i64 %26, 0
br i1 %81, label %98, label %82
82: ; preds = %79, %82
%83 = phi i64 [ %95, %82 ], [ %80, %79 ]
%84 = phi i64 [ %96, %82 ], [ 0, %79 ]
%85 = getelementptr inbounds double, double* %6, i64 %83
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %85, i64 2
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %1, i64 %83
%92 = bitcast double* %91 to <2 x double>*
store <2 x double> %87, <2 x double>* %92
%93 = getelementptr inbounds double, double* %91, i64 2
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> %90, <2 x double>* %94
%95 = add nuw i64 %83, 4
%96 = add i64 %84, 1
%97 = icmp eq i64 %96, %26
br i1 %97, label %98, label %82
98: ; preds = %82, %79
%99 = icmp eq i64 %22, %13
br i1 %99, label %137, label %100
100: ; preds = %15, %12, %98
%101 = phi i64 [ 0, %15 ], [ 0, %12 ], [ %22, %98 ]
%102 = xor i64 %101, -1
%103 = add nsw i64 %102, %13
%104 = and i64 %13, 3
%105 = icmp eq i64 %104, 0
br i1 %105, label %115, label %106
106: ; preds = %100, %106
%107 = phi i64 [ %112, %106 ], [ %101, %100 ]
%108 = phi i64 [ %113, %106 ], [ 0, %100 ]
%109 = getelementptr inbounds double, double* %6, i64 %107
%110 = load double, double* %109
%111 = getelementptr inbounds double, double* %1, i64 %107
store double %110, double* %111
%112 = add nuw nsw i64 %107, 1
%113 = add i64 %108, 1
%114 = icmp eq i64 %113, %104
br i1 %114, label %115, label %106
115: ; preds = %106, %100
%116 = phi i64 [ %101, %100 ], [ %112, %106 ]
%117 = icmp ult i64 %103, 3
br i1 %117, label %137, label %118
118: ; preds = %115, %118
%119 = phi i64 [ %135, %118 ], [ %116, %115 ]
%120 = getelementptr inbounds double, double* %6, i64 %119
%121 = load double, double* %120
%122 = getelementptr inbounds double, double* %1, i64 %119
store double %121, double* %122
%123 = add nuw nsw i64 %119, 1
%124 = getelementptr inbounds double, double* %6, i64 %123
%125 = load double, double* %124
%126 = getelementptr inbounds double, double* %1, i64 %123
store double %125, double* %126
%127 = add nuw nsw i64 %119, 2
%128 = getelementptr inbounds double, double* %6, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %1, i64 %127
store double %129, double* %130
%131 = add nuw nsw i64 %119, 3
%132 = getelementptr inbounds double, double* %6, i64 %131
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %1, i64 %131
store double %133, double* %134
%135 = add nuw nsw i64 %119, 4
%136 = icmp eq i64 %135, %13
br i1 %136, label %137, label %118
137: ; preds = %115, %118, %98, %7
ret i32 %8
}