#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 */
long double cosl(int);
long double sinl(int);
int sqrtl(long double);
float impulse_error(int N, int sign, float *data) {
  long double delta_sum = 0.0f;
  long double sum = 0.0f;
  int i;
  for (i = 0; i < N; i++) {
    long double re, im;
    if (sign < 0) {
      re = cosl(2 * 3.1415926535897932384626433832795028841971693993751058209 *
                (long double)i / (long double)N);
      im = -sinl(2 * 3.1415926535897932384626433832795028841971693993751058209 *
                 (long double)i / (long double)N);
    } else {
      re = cosl(2 * 3.1415926535897932384626433832795028841971693993751058209 *
                (long double)i / (long double)N);
      im = sinl(2 * 3.1415926535897932384626433832795028841971693993751058209 *
                (long double)i / (long double)N);
    }
    sum += re * re + im * im;
    re = re - data[2 * i];
    im = im - data[2 * i + 1];
    delta_sum += re * re + im * im;
  }
  return (float)(sqrtl(delta_sum) / sqrtl(sum));
}


x86 assembly (clang, -O0):
<impulse_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
fldz
fld    %st(0)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1344 <impulse_error+0x214>
cmpl   $0x0,-0x8(%rbp)
jge    1233 <impulse_error+0x103>
mov    -0x34(%rbp),%eax
mov    %eax,-0x90(%rbp)
fildl  -0x90(%rbp)
fldl   0xe7f(%rip)
fld    %st(0)
fstpt  -0xac(%rbp)
fmulp  %st,%st(1)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8c(%rbp)
fildl  -0x8c(%rbp)
fdivrp %st,%st(1)
fnstcw -0x92(%rbp)
movzwl -0x92(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x94(%rbp)
fldcw  -0x94(%rbp)
fistpl -0x88(%rbp)
fldcw  -0x92(%rbp)
mov    -0x88(%rbp),%edi
call   1040 <cosl@plt>
fldt   -0xac(%rbp)
fxch   %st(1)
fstpt  -0x50(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x80(%rbp)
fildl  -0x80(%rbp)
fmulp  %st,%st(1)
mov    -0x4(%rbp),%eax
mov    %eax,-0x84(%rbp)
fildl  -0x84(%rbp)
fdivrp %st,%st(1)
fnstcw -0x96(%rbp)
movzwl -0x96(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x98(%rbp)
fldcw  -0x98(%rbp)
fistpl -0x7c(%rbp)
fldcw  -0x96(%rbp)
mov    -0x7c(%rbp),%edi
call   1030 <sinl@plt>
fchs
fstpt  -0x60(%rbp)
jmp    12db <impulse_error+0x1ab>
mov    -0x34(%rbp),%eax
mov    %eax,-0x78(%rbp)
fildl  -0x78(%rbp)
fldl   0xdbe(%rip)
fld    %st(0)
fstpt  -0xb8(%rbp)
fmulp  %st,%st(1)
mov    -0x4(%rbp),%eax
mov    %eax,-0x74(%rbp)
fildl  -0x74(%rbp)
fdivrp %st,%st(1)
fnstcw -0x9a(%rbp)
movzwl -0x9a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x9c(%rbp)
fldcw  -0x9c(%rbp)
fistpl -0x70(%rbp)
fldcw  -0x9a(%rbp)
mov    -0x70(%rbp),%edi
call   1040 <cosl@plt>
fldt   -0xb8(%rbp)
fxch   %st(1)
fstpt  -0x50(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x68(%rbp)
fildl  -0x68(%rbp)
fmulp  %st,%st(1)
mov    -0x4(%rbp),%eax
mov    %eax,-0x6c(%rbp)
fildl  -0x6c(%rbp)
fdivrp %st,%st(1)
fnstcw -0x9e(%rbp)
movzwl -0x9e(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0xa0(%rbp)
fldcw  -0xa0(%rbp)
fistpl -0x64(%rbp)
fldcw  -0x9e(%rbp)
mov    -0x64(%rbp),%edi
call   1030 <sinl@plt>
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
fldt   -0x60(%rbp)
fmul   %st,%st(0)
fxch   %st(1)
fmul   %st,%st(0)
faddp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    %ecx,%ecx
movslq %ecx,%rcx
flds   (%rax,%rcx,4)
fsubrp %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    %ecx,%ecx
movslq %ecx,%rcx
flds   0x4(%rax,%rcx,4)
fsubrp %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
fldt   -0x60(%rbp)
fmul   %st,%st(0)
fxch   %st(1)
fmul   %st,%st(0)
faddp  %st,%st(1)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1156 <impulse_error+0x26>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <sqrtl@plt>
mov    %eax,-0xbc(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <sqrtl@plt>
mov    %eax,%ecx
mov    -0xbc(%rbp),%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<impulse_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
fldz
fld    %st(0)
test   %edi,%edi
jle    1219 <impulse_error+0xe9>
mov    %rdx,%r12
mov    %esi,%r14d
fstp   %st(0)
fstp   %st(0)
mov    %edi,0x24(%rsp)
fildl  0x24(%rsp)
fstpt  0x40(%rsp)
mov    %edi,%r15d
fldz
xor    %ebx,%ebx
fld    %st(0)
fxch   %st(1)
nopl   0x0(%rax,%rax,1)
fstpt  0x34(%rsp)
fstpt  0x28(%rsp)
test   %r14d,%r14d
sets   %r13b
mov    %ebx,0x1c(%rsp)
fildl  0x1c(%rsp)
fmull  0xe73(%rip)
fldt   0x40(%rsp)
fdivrp %st,%st(1)
fnstcw 0x18(%rsp)
movzwl 0x18(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1a(%rsp)
fldcw  0x1a(%rsp)
fistpl 0x20(%rsp)
fldcw  0x18(%rsp)
mov    0x20(%rsp),%ebp
mov    %ebp,%edi
call   1040 <cosl@plt>
fstpt  0x4c(%rsp)
mov    %ebp,%edi
call   1030 <sinl@plt>
fld    %st(0)
fchs
test   %r13b,%r13b
fxch   %st(1)
fcmovne %st(1),%st
fstp   %st(1)
fld    %st(0)
fmul   %st(1),%st
fldt   0x4c(%rsp)
fld    %st(0)
fmul   %st(1),%st
faddp  %st,%st(2)
fldt   0x28(%rsp)
faddp  %st,%st(2)
fsubs  (%r12,%rbx,8)
fxch   %st(2)
fsubs  0x4(%r12,%rbx,8)
fmul   %st,%st(0)
fxch   %st(2)
fmul   %st,%st(0)
faddp  %st,%st(2)
fldt   0x34(%rsp)
faddp  %st,%st(2)
fxch   %st(1)
fstpt  0x34(%rsp)
fldt   0x34(%rsp)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <impulse_error+0x40>
fxch   %st(1)
fstpt  0x28(%rsp)
fstpt  (%rsp)
call   1050 <sqrtl@plt>
mov    %eax,%ebx
fldt   0x28(%rsp)
fstpt  (%rsp)
call   1050 <sqrtl@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float @impulse_error(i32 %0, i32 %1, float* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca i32
%10 = alloca x86_fp80
%11 = alloca x86_fp80
store i32 %0, i32* %4
store i32 %1, i32* %5
store float* %2, float** %6
store x86_fp80 0xK00000000000000000000, x86_fp80* %7
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
store i32 0, i32* %9
br label %12
12: ; preds = %90, %3
%13 = load i32, i32* %9
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %93
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %37
19: ; preds = %16
%20 = load i32, i32* %9
%21 = sitofp i32 %20 to x86_fp80
%22 = fmul x86_fp80 0xK4001C90FDAA22168C000, %21
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to x86_fp80
%25 = fdiv x86_fp80 %22, %24
%26 = fptosi x86_fp80 %25 to i32
%27 = call x86_fp80 @cosl(i32 %26)
store x86_fp80 %27, x86_fp80* %10
%28 = load i32, i32* %9
%29 = sitofp i32 %28 to x86_fp80
%30 = fmul x86_fp80 0xK4001C90FDAA22168C000, %29
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to x86_fp80
%33 = fdiv x86_fp80 %30, %32
%34 = fptosi x86_fp80 %33 to i32
%35 = call x86_fp80 @sinl(i32 %34)
%36 = fneg x86_fp80 %35
store x86_fp80 %36, x86_fp80* %11
br label %54
37: ; preds = %16
%38 = load i32, i32* %9
%39 = sitofp i32 %38 to x86_fp80
%40 = fmul x86_fp80 0xK4001C90FDAA22168C000, %39
%41 = load i32, i32* %4
%42 = sitofp i32 %41 to x86_fp80
%43 = fdiv x86_fp80 %40, %42
%44 = fptosi x86_fp80 %43 to i32
%45 = call x86_fp80 @cosl(i32 %44)
store x86_fp80 %45, x86_fp80* %10
%46 = load i32, i32* %9
%47 = sitofp i32 %46 to x86_fp80
%48 = fmul x86_fp80 0xK4001C90FDAA22168C000, %47
%49 = load i32, i32* %4
%50 = sitofp i32 %49 to x86_fp80
%51 = fdiv x86_fp80 %48, %50
%52 = fptosi x86_fp80 %51 to i32
%53 = call x86_fp80 @sinl(i32 %52)
store x86_fp80 %53, x86_fp80* %11
br label %54
54: ; preds = %37, %19
%55 = load x86_fp80, x86_fp80* %10
%56 = load x86_fp80, x86_fp80* %10
%57 = load x86_fp80, x86_fp80* %11
%58 = load x86_fp80, x86_fp80* %11
%59 = fmul x86_fp80 %57, %58
%60 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %55, x86_fp80 %56, x86_fp80 %59)
%61 = load x86_fp80, x86_fp80* %8
%62 = fadd x86_fp80 %61, %60
store x86_fp80 %62, x86_fp80* %8
%63 = load x86_fp80, x86_fp80* %10
%64 = load float*, float** %6
%65 = load i32, i32* %9
%66 = mul nsw i32 2, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds float, float* %64, i64 %67
%69 = load float, float* %68
%70 = fpext float %69 to x86_fp80
%71 = fsub x86_fp80 %63, %70
store x86_fp80 %71, x86_fp80* %10
%72 = load x86_fp80, x86_fp80* %11
%73 = load float*, float** %6
%74 = load i32, i32* %9
%75 = mul nsw i32 2, %74
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %73, i64 %77
%79 = load float, float* %78
%80 = fpext float %79 to x86_fp80
%81 = fsub x86_fp80 %72, %80
store x86_fp80 %81, x86_fp80* %11
%82 = load x86_fp80, x86_fp80* %10
%83 = load x86_fp80, x86_fp80* %10
%84 = load x86_fp80, x86_fp80* %11
%85 = load x86_fp80, x86_fp80* %11
%86 = fmul x86_fp80 %84, %85
%87 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %82, x86_fp80 %83, x86_fp80 %86)
%88 = load x86_fp80, x86_fp80* %7
%89 = fadd x86_fp80 %88, %87
store x86_fp80 %89, x86_fp80* %7
br label %90
90: ; preds = %54
%91 = load i32, i32* %9
%92 = add nsw i32 %91, 1
store i32 %92, i32* %9
br label %12
93: ; preds = %12
%94 = load x86_fp80, x86_fp80* %7
%95 = call i32 @sqrtl(x86_fp80 %94)
%96 = load x86_fp80, x86_fp80* %8
%97 = call i32 @sqrtl(x86_fp80 %96)
%98 = sdiv i32 %95, %97
%99 = sitofp i32 %98 to float
ret float %99
}

LLVM IR (-O2):
define float @impulse_error(i32 %0, i32 %1, float* nocapture %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %40
5: ; preds = %3
%6 = icmp slt i32 %1, 0
%7 = sitofp i32 %0 to x86_fp80
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %38, %9 ]
%11 = phi x86_fp80 [ 0xK00000000000000000000, %5 ], [ %37, %9 ]
%12 = phi x86_fp80 [ 0xK00000000000000000000, %5 ], [ %24, %9 ]
%13 = trunc i64 %10 to i32
%14 = sitofp i32 %13 to x86_fp80
%15 = fmul x86_fp80 %14, 0xK4001C90FDAA22168C000
%16 = fdiv x86_fp80 %15, %7
%17 = fptosi x86_fp80 %16 to i32
%18 = tail call x86_fp80 @cosl(i32 %17)
%19 = tail call x86_fp80 @sinl(i32 %17)
%20 = fneg x86_fp80 %19
%21 = select i1 %6, x86_fp80 %20, x86_fp80 %19
%22 = fmul x86_fp80 %21, %21
%23 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 %18, x86_fp80 %22)
%24 = fadd x86_fp80 %12, %23
%25 = shl nuw nsw i64 %10, 1
%26 = getelementptr inbounds float, float* %2, i64 %25
%27 = load float, float* %26
%28 = fpext float %27 to x86_fp80
%29 = fsub x86_fp80 %18, %28
%30 = or i64 %25, 1
%31 = getelementptr inbounds float, float* %2, i64 %30
%32 = load float, float* %31
%33 = fpext float %32 to x86_fp80
%34 = fsub x86_fp80 %21, %33
%35 = fmul x86_fp80 %34, %34
%36 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %29, x86_fp80 %29, x86_fp80 %35)
%37 = fadd x86_fp80 %11, %36
%38 = add nuw nsw i64 %10, 1
%39 = icmp eq i64 %38, %8
br i1 %39, label %40, label %9
40: ; preds = %9, %3
%41 = phi x86_fp80 [ 0xK00000000000000000000, %3 ], [ %24, %9 ]
%42 = phi x86_fp80 [ 0xK00000000000000000000, %3 ], [ %37, %9 ]
%43 = tail call i32 @sqrtl(x86_fp80 %42)
%44 = tail call i32 @sqrtl(x86_fp80 %41)
%45 = sdiv i32 %43, %44
%46 = sitofp i32 %45 to float
ret float %46
}