#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 */
typedef size_t ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double DBL_MAX;
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ filters_trapezoidal(size_t, float const *, float *, size_t,
                                       size_t, double);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ perror(char *);
double sqrt(double);
int sigproc_measure_pulse(size_t nSamples, const float *adcData, size_t nAdcCh,
                          size_t nFltParam, const double *fltParam,
                          size_t nMeasParam, double *measParam) {
  size_t nBl;
  ssize_t iCh, i, j;
  const float *adcChData;
  float *scrAry;
  double *measChParam, v, bl, bln;
  FILE *fpa;
  if ((fpa = fopen("flt.dat", "w")) == NULL) {
    perror("flt.dat");
    return -1;
  }
  nBl = (size_t)fltParam[0];
  scrAry = (float *)calloc(nSamples, sizeof(float));
  for (iCh = 0; iCh < nAdcCh; iCh++) {
    adcChData = adcData + nSamples * iCh;
    measChParam = measParam + nMeasParam * iCh;
    bl = 0.0;
    bln = 0.0;
    for (i = 0; i < nBl; i++) {
      bl += adcChData[i];
      bln += adcChData[i] * adcChData[i];
    }
    bl /= (double)nBl;
    bln = sqrt((bln - (double)nBl * bl * bl) / (nBl - 1.0));
    measChParam[0] = bl;
    measChParam[1] = bln;
    filters_trapezoidal(nSamples, adcChData, scrAry, (size_t)fltParam[1],
                        (size_t)fltParam[2], (double)fltParam[3]);
    v = -DBL_MAX;
    j = 0;
    for (i = 0; i < nSamples; i++) {
      if (scrAry[i] > v) {
        v = scrAry[i];
        j = i;
      }
      fprintf(fpa, "%g\n", scrAry[i] + bl);
    }
    measChParam[2] = j;
    measChParam[3] = v;
    fprintf(fpa, "\n\n");
  }
  free(scrAry);
  fclose(fpa);
  return 0;
}


x86 assembly (clang, -O0):
<sigproc_measure_pulse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
lea    0xe82(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x90(%rbp)
cmp    $0x0,%rax
jne    11e3 <sigproc_measure_pulse+0x63>
lea    0xe5e(%rip),%rdi
call   1090 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    153b <sigproc_measure_pulse+0x3bb>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe0d(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    151f <sigproc_measure_pulse+0x39f>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   -0x48(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
imul   -0x48(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    12f0 <sigproc_measure_pulse+0x170>
mov    -0x60(%rbp),%rax
mov    -0x50(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x50(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x50(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1288 <sigproc_measure_pulse+0x108>
movq   -0x40(%rbp),%xmm1
movaps 0xd14(%rip),%xmm3
punpckldq %xmm3,%xmm1
movapd 0xd18(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movq   -0x40(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x80(%rbp),%xmm3
movaps %xmm1,%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  0xca7(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   10a0 <sqrt@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
mov    -0x70(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x70(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0x10(%rax),%xmm0
movsd  0xc4a(%rip),%xmm2
movaps %xmm1,%xmm3
subsd  %xmm2,%xmm3
cvttsd2si %xmm3,%rax
cvttsd2si %xmm1,%rcx
mov    %rcx,%r8
sar    $0x3f,%r8
and    %r8,%rax
or     %rax,%rcx
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%r8
mov    %r8,%r9
sar    $0x3f,%r9
and    %r9,%rax
or     %rax,%r8
mov    -0x30(%rbp),%rax
movsd  0x18(%rax),%xmm0
call   1040 <filters_trapezoidal@plt>
mov    0x2bd9(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    14bb <sigproc_measure_pulse+0x33b>
mov    -0x68(%rbp),%rax
mov    -0x50(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    147f <sigproc_measure_pulse+0x2ff>
mov    -0x68(%rbp),%rax
mov    -0x50(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    -0x50(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  -0x80(%rbp),%xmm0
lea    0xb97(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1437 <sigproc_measure_pulse+0x2b7>
movaps 0xb4e(%rip),%xmm1
movq   -0x58(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xb4d(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x70(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x78(%rbp),%xmm0
mov    -0x70(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x90(%rbp),%rdi
lea    0xb37(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    122f <sigproc_measure_pulse+0xaf>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigproc_measure_pulse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9,0x68(%rsp)
mov    %r8,%r12
mov    %rdx,%r13
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
lea    0xe95(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1555 <sigproc_measure_pulse+0x3c5>
mov    %rax,%r14
movsd  (%r12),%xmm0
movapd %xmm0,0x20(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%rbp
test   %r13,%r13
je     1531 <sigproc_measure_pulse+0x3a1>
movapd 0x20(%rsp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
subsd  0xdf2(%rip),%xmm0
cvttsd2si %xmm0,%r8
sar    $0x3f,%rcx
and    %rcx,%r8
or     %rax,%r8
movq   %r8,%xmm0
punpckldq 0xdf6(%rip),%xmm0
subpd  0xdfe(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdc2(%rip),%xmm0
movapd %xmm1,0x90(%rsp)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x48(%rsp)
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
mov    0x10(%rsp),%rax
lea    0x4(%rax),%rdx
lea    0x0(,%rbx,4),%rax
mov    %rax,0x38(%rsp)
xor    %edi,%edi
mov    %r8,0x50(%rsp)
mov    %rsi,0x40(%rsp)
mov    %r12,0x60(%rsp)
mov    %r13,0x58(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbp,(%rsp)
jmp    1338 <sigproc_measure_pulse+0x1a8>
nopw   0x0(%rax,%rax,1)
xor    %r13d,%r13d
mov    0x8(%rsp),%rbp
mov    (%rsp),%rbx
movq   %r13,%xmm0
punpckldq 0xd67(%rip),%xmm0
subpd  0xd6f(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mov    0xe0(%rsp),%rax
mov    0x18(%rsp),%rcx
movsd  %xmm1,0x10(%rax,%rcx,8)
movsd  %xmm2,0x18(%rax,%rcx,8)
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xd67(%rip),%rdi
mov    %rbp,%rcx
call   10b0 <fwrite@plt>
mov    0x78(%rsp),%rdi
add    $0x1,%rdi
mov    0x70(%rsp),%rdx
add    0x38(%rsp),%rdx
mov    0x58(%rsp),%r13
cmp    %r13,%rdi
mov    0x60(%rsp),%r12
mov    0x50(%rsp),%r8
mov    0x40(%rsp),%rsi
mov    %rbp,%r14
mov    %rbx,%rbp
mov    %r15,%rbx
je     1531 <sigproc_measure_pulse+0x3a1>
mov    %rdi,%rax
imul   %rbx,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,4),%r15
xorpd  %xmm0,%xmm0
test   %r8,%r8
je     13c3 <sigproc_measure_pulse+0x233>
cmp    $0x1,%r8
jne    1360 <sigproc_measure_pulse+0x1d0>
xor    %eax,%eax
jmp    13a6 <sigproc_measure_pulse+0x216>
nopl   0x0(%rax,%rax,1)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movss  -0x4(%rdx,%rax,4),%xmm1
movss  (%rdx,%rax,4),%xmm2
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
unpcklps %xmm3,%xmm1
cvtps2pd %xmm1,%xmm1
addpd  %xmm0,%xmm1
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
unpcklps %xmm0,%xmm2
cvtps2pd %xmm2,%xmm0
addpd  %xmm1,%xmm0
add    $0x2,%rax
cmp    %rax,%rsi
jne    1370 <sigproc_measure_pulse+0x1e0>
test   $0x1,%r8b
je     13c3 <sigproc_measure_pulse+0x233>
movss  (%r15,%rax,4),%xmm1
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm2
unpcklps %xmm2,%xmm1
cvtps2pd %xmm1,%xmm1
addpd  %xmm1,%xmm0
mov    %rdi,%rax
imul   0x68(%rsp),%rax
mov    %rax,0x18(%rsp)
movapd %xmm0,%xmm2
movapd 0x90(%rsp),%xmm1
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm1
unpckhpd %xmm0,%xmm0
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
divsd  0x48(%rsp),%xmm0
ucomisd 0xc10(%rip),%xmm0
mov    %rdi,0x78(%rsp)
mov    %rdx,0x70(%rsp)
movapd %xmm2,0x80(%rsp)
jb     1420 <sigproc_measure_pulse+0x290>
sqrtsd %xmm0,%xmm0
jmp    142e <sigproc_measure_pulse+0x29e>
nopl   0x0(%rax,%rax,1)
call   10a0 <sqrt@plt>
movapd 0x80(%rsp),%xmm2
mov    0xe0(%rsp),%rax
mov    0x18(%rsp),%rcx
movsd  %xmm2,(%rax,%rcx,8)
movsd  %xmm0,0x8(%rax,%rcx,8)
movsd  0x8(%r12),%xmm0
cvttsd2si %xmm0,%rax
movsd  0x10(%r12),%xmm1
movsd  0xb9f(%rip),%xmm2
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rdx
mov    %rax,%rcx
sar    $0x3f,%rcx
and    %rdx,%rcx
cvttsd2si %xmm1,%rdx
or     %rax,%rcx
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
mov    %rdx,%r8
sar    $0x3f,%r8
and    %rax,%r8
or     %rdx,%r8
movsd  0x18(%r12),%xmm0
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <filters_trapezoidal@plt>
mov    0x2b32(%rip),%rax
movsd  (%rax),%xmm2
xorpd  0xb86(%rip),%xmm2
mov    %rbx,%r15
test   %rbx,%rbx
je     12a0 <sigproc_measure_pulse+0x110>
movapd %xmm2,%xmm1
xor    %r12d,%r12d
xor    %r13d,%r13d
lea    0xb83(%rip),%r14
mov    0x8(%rsp),%rbp
mov    (%rsp),%rbx
movss  (%rbx,%r12,4),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
ucomisd %xmm1,%xmm2
cmova  %r12,%r13
movapd 0x80(%rsp),%xmm0
addsd  %xmm2,%xmm0
maxsd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
movapd 0x20(%rsp),%xmm2
add    $0x1,%r12
movapd %xmm2,%xmm1
cmp    %r12,%r15
jne    14e0 <sigproc_measure_pulse+0x350>
jmp    12ac <sigproc_measure_pulse+0x11c>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaf4(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%eax
jmp    1543 <sigproc_measure_pulse+0x3b3>

LLVM IR (-O0):
@.str = [8 x i8] c"flt.dat\00"
@.str.1 = [2 x i8] c"w\00"
@DBL_MAX = global double 0.000000e+00
@.str.2 = [4 x i8] c"%g\0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define i32 @sigproc_measure_pulse(i64 %0, float* %1, i64 %2, i64 %3, double* %4, i64 %5, double* %6) {
%8 = alloca i32
%9 = alloca i64
%10 = alloca float*
%11 = alloca i64
%12 = alloca i64
%13 = alloca double*
%14 = alloca i64
%15 = alloca double*
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca float*
%21 = alloca float*
%22 = alloca double*
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32*
store i64 %0, i64* %9
store float* %1, float** %10
store i64 %2, i64* %11
store i64 %3, i64* %12
store double* %4, double** %13
store i64 %5, i64* %14
store double* %6, double** %15
%27 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %26
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %7
%30 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %8
br label %172
31: ; preds = %7
%32 = load double*, double** %13
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fptoui double %34 to i64
store i64 %35, i64* %16
%36 = load i64, i64* %9
%37 = call i64 @calloc(i64 %36, i32 4)
%38 = inttoptr i64 %37 to float*
store float* %38, float** %21
store i64 0, i64* %17
br label %39
39: ; preds = %164, %31
%40 = load i64, i64* %17
%41 = load i64, i64* %11
%42 = icmp ult i64 %40, %41
br i1 %42, label %43, label %167
43: ; preds = %39
%44 = load float*, float** %10
%45 = load i64, i64* %9
%46 = load i64, i64* %17
%47 = mul i64 %45, %46
%48 = getelementptr inbounds float, float* %44, i64 %47
store float* %48, float** %20
%49 = load double*, double** %15
%50 = load i64, i64* %14
%51 = load i64, i64* %17
%52 = mul i64 %50, %51
%53 = getelementptr inbounds double, double* %49, i64 %52
store double* %53, double** %22
store double 0.000000e+00, double* %24
store double 0.000000e+00, double* %25
store i64 0, i64* %18
br label %54
54: ; preds = %78, %43
%55 = load i64, i64* %18
%56 = load i64, i64* %16
%57 = icmp ult i64 %55, %56
br i1 %57, label %58, label %81
58: ; preds = %54
%59 = load float*, float** %20
%60 = load i64, i64* %18
%61 = getelementptr inbounds float, float* %59, i64 %60
%62 = load float, float* %61
%63 = fpext float %62 to double
%64 = load double, double* %24
%65 = fadd double %64, %63
store double %65, double* %24
%66 = load float*, float** %20
%67 = load i64, i64* %18
%68 = getelementptr inbounds float, float* %66, i64 %67
%69 = load float, float* %68
%70 = load float*, float** %20
%71 = load i64, i64* %18
%72 = getelementptr inbounds float, float* %70, i64 %71
%73 = load float, float* %72
%74 = fmul float %69, %73
%75 = fpext float %74 to double
%76 = load double, double* %25
%77 = fadd double %76, %75
store double %77, double* %25
br label %78
78: ; preds = %58
%79 = load i64, i64* %18
%80 = add i64 %79, 1
store i64 %80, i64* %18
br label %54
81: ; preds = %54
%82 = load i64, i64* %16
%83 = uitofp i64 %82 to double
%84 = load double, double* %24
%85 = fdiv double %84, %83
store double %85, double* %24
%86 = load double, double* %25
%87 = load i64, i64* %16
%88 = uitofp i64 %87 to double
%89 = load double, double* %24
%90 = fmul double %88, %89
%91 = load double, double* %24
%92 = fneg double %90
%93 = call double @llvm.fmuladd.f64(double %92, double %91, double %86)
%94 = load i64, i64* %16
%95 = uitofp i64 %94 to double
%96 = fsub double %95, 1.000000e+00
%97 = fdiv double %93, %96
%98 = call double @sqrt(double %97)
store double %98, double* %25
%99 = load double, double* %24
%100 = load double*, double** %22
%101 = getelementptr inbounds double, double* %100, i64 0
store double %99, double* %101
%102 = load double, double* %25
%103 = load double*, double** %22
%104 = getelementptr inbounds double, double* %103, i64 1
store double %102, double* %104
%105 = load i64, i64* %9
%106 = load float*, float** %20
%107 = load float*, float** %21
%108 = load double*, double** %13
%109 = getelementptr inbounds double, double* %108, i64 1
%110 = load double, double* %109
%111 = fptoui double %110 to i64
%112 = load double*, double** %13
%113 = getelementptr inbounds double, double* %112, i64 2
%114 = load double, double* %113
%115 = fptoui double %114 to i64
%116 = load double*, double** %13
%117 = getelementptr inbounds double, double* %116, i64 3
%118 = load double, double* %117
%119 = call i32 @filters_trapezoidal(i64 %105, float* %106, float* %107, i64 %111, i64 %115, double %118)
%120 = load double, double* @DBL_MAX
%121 = fneg double %120
store double %121, double* %23
store i64 0, i64* %19
store i64 0, i64* %18
br label %122
122: ; preds = %151, %81
%123 = load i64, i64* %18
%124 = load i64, i64* %9
%125 = icmp ult i64 %123, %124
br i1 %125, label %126, label %154
126: ; preds = %122
%127 = load float*, float** %21
%128 = load i64, i64* %18
%129 = getelementptr inbounds float, float* %127, i64 %128
%130 = load float, float* %129
%131 = fpext float %130 to double
%132 = load double, double* %23
%133 = fcmp ogt double %131, %132
br i1 %133, label %134, label %141
134: ; preds = %126
%135 = load float*, float** %21
%136 = load i64, i64* %18
%137 = getelementptr inbounds float, float* %135, i64 %136
%138 = load float, float* %137
%139 = fpext float %138 to double
store double %139, double* %23
%140 = load i64, i64* %18
store i64 %140, i64* %19
br label %141
141: ; preds = %134, %126
%142 = load i32*, i32** %26
%143 = load float*, float** %21
%144 = load i64, i64* %18
%145 = getelementptr inbounds float, float* %143, i64 %144
%146 = load float, float* %145
%147 = fpext float %146 to double
%148 = load double, double* %24
%149 = fadd double %147, %148
%150 = call i32 (i32*, i8*, ...) @fprintf(i32* %142, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %149)
br label %151
151: ; preds = %141
%152 = load i64, i64* %18
%153 = add i64 %152, 1
store i64 %153, i64* %18
br label %122
154: ; preds = %122
%155 = load i64, i64* %19
%156 = uitofp i64 %155 to double
%157 = load double*, double** %22
%158 = getelementptr inbounds double, double* %157, i64 2
store double %156, double* %158
%159 = load double, double* %23
%160 = load double*, double** %22
%161 = getelementptr inbounds double, double* %160, i64 3
store double %159, double* %161
%162 = load i32*, i32** %26
%163 = call i32 (i32*, i8*, ...) @fprintf(i32* %162, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %164
164: ; preds = %154
%165 = load i64, i64* %17
%166 = add i64 %165, 1
store i64 %166, i64* %17
br label %39
167: ; preds = %39
%168 = load float*, float** %21
%169 = call i32 @free(float* %168)
%170 = load i32*, i32** %26
%171 = call i32 @fclose(i32* %170)
store i32 0, i32* %8
br label %172
172: ; preds = %167, %29
%173 = load i32, i32* %8
ret i32 %173
}

LLVM IR (-O2):
@.str = [8 x i8] c"flt.dat\00"
@.str.1 = [2 x i8] c"w\00"
@DBL_MAX = global double 0.000000e+00
@.str.2 = [4 x i8] c"%g\0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define i32 @sigproc_measure_pulse(i64 %0, float* %1, i64 %2, i64 %3, double* nocapture %4, i64 %5, double* nocapture writeonly %6) {
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %114
12: ; preds = %7
%13 = load double, double* %4
%14 = fptoui double %13 to i64
%15 = tail call i64 @calloc(i64 %0, i32 4)
%16 = inttoptr i64 %15 to float*
%17 = icmp eq i64 %2, 0
br i1 %17, label %111, label %18
18: ; preds = %12
%19 = uitofp i64 %14 to double
%20 = fadd double %19, -1.000000e+00
%21 = getelementptr inbounds double, double* %4, i64 1
%22 = getelementptr inbounds double, double* %4, i64 2
%23 = getelementptr inbounds double, double* %4, i64 3
%24 = icmp eq i64 %0, 0
%25 = and i64 %14, 1
%26 = icmp eq i64 %14, 1
%27 = and i64 %14, -2
%28 = icmp eq i64 %25, 0
br label %29
29: ; preds = %18, %102
%30 = phi i64 [ 0, %18 ], [ %109, %102 ]
%31 = mul i64 %30, %0
%32 = getelementptr inbounds float, float* %1, i64 %31
%33 = mul i64 %30, %5
%34 = getelementptr inbounds double, double* %6, i64 %33
switch i64 %14, label %35 [
i64 0, label %69
i64 1, label %57
]
35: ; preds = %29, %35
%36 = phi i64 [ %54, %35 ], [ 0, %29 ]
%37 = phi <2 x double> [ %53, %35 ], [ zeroinitializer, %29 ]
%38 = phi i64 [ %55, %35 ], [ 0, %29 ]
%39 = getelementptr inbounds float, float* %32, i64 %36
%40 = load float, float* %39
%41 = fmul float %40, %40
%42 = insertelement <2 x float> poison, float %40, i64 0
%43 = insertelement <2 x float> %42, float %41, i64 1
%44 = fpext <2 x float> %43 to <2 x double>
%45 = fadd <2 x double> %37, %44
%46 = or i64 %36, 1
%47 = getelementptr inbounds float, float* %32, i64 %46
%48 = load float, float* %47
%49 = fmul float %48, %48
%50 = insertelement <2 x float> poison, float %48, i64 0
%51 = insertelement <2 x float> %50, float %49, i64 1
%52 = fpext <2 x float> %51 to <2 x double>
%53 = fadd <2 x double> %45, %52
%54 = add nuw i64 %36, 2
%55 = add i64 %38, 2
%56 = icmp eq i64 %55, %27
br i1 %56, label %57, label %35
57: ; preds = %35, %29
%58 = phi <2 x double> [ undef, %29 ], [ %53, %35 ]
%59 = phi i64 [ 0, %29 ], [ %54, %35 ]
%60 = phi <2 x double> [ zeroinitializer, %29 ], [ %53, %35 ]
br i1 %28, label %69, label %61
61: ; preds = %57
%62 = getelementptr inbounds float, float* %32, i64 %59
%63 = load float, float* %62
%64 = fmul float %63, %63
%65 = insertelement <2 x float> poison, float %63, i64 0
%66 = insertelement <2 x float> %65, float %64, i64 1
%67 = fpext <2 x float> %66 to <2 x double>
%68 = fadd <2 x double> %60, %67
br label %69
69: ; preds = %61, %57, %29
%70 = phi <2 x double> [ zeroinitializer, %29 ], [ %58, %57 ], [ %68, %61 ]
%71 = extractelement <2 x double> %70, i64 0
%72 = fdiv double %71, %19
%73 = fneg double %72
%74 = fmul double %19, %73
%75 = extractelement <2 x double> %70, i64 1
%76 = tail call double @llvm.fmuladd.f64(double %74, double %72, double %75)
%77 = fdiv double %76, %20
%78 = tail call double @sqrt(double %77)
store double %72, double* %34
%79 = getelementptr inbounds double, double* %34, i64 1
store double %78, double* %79
%80 = load double, double* %21
%81 = fptoui double %80 to i64
%82 = load double, double* %22
%83 = fptoui double %82 to i64
%84 = load double, double* %23
%85 = tail call i32 @filters_trapezoidal(i64 %0, float* %32, float* %16, i64 %81, i64 %83, double %84)
%86 = load double, double* @DBL_MAX
%87 = fneg double %86
br i1 %24, label %102, label %88
88: ; preds = %69, %88
%89 = phi double [ %97, %88 ], [ %87, %69 ]
%90 = phi i64 [ %100, %88 ], [ 0, %69 ]
%91 = phi i64 [ %96, %88 ], [ 0, %69 ]
%92 = getelementptr inbounds float, float* %16, i64 %90
%93 = load float, float* %92
%94 = fpext float %93 to double
%95 = fcmp olt double %89, %94
%96 = select i1 %95, i64 %90, i64 %91
%97 = select i1 %95, double %94, double %89
%98 = fadd double %72, %94
%99 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %98)
%100 = add nuw i64 %90, 1
%101 = icmp eq i64 %100, %0
br i1 %101, label %102, label %88
102: ; preds = %88, %69
%103 = phi i64 [ 0, %69 ], [ %96, %88 ]
%104 = phi double [ %87, %69 ], [ %97, %88 ]
%105 = uitofp i64 %103 to double
%106 = getelementptr inbounds double, double* %34, i64 2
store double %105, double* %106
%107 = getelementptr inbounds double, double* %34, i64 3
store double %104, double* %107
%108 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %8)
%109 = add nuw i64 %30, 1
%110 = icmp eq i64 %109, %2
br i1 %110, label %111, label %29
111: ; preds = %102, %12
%112 = tail call i32 @free(float* %16)
%113 = tail call i32 @fclose(i32* %8)
br label %114
114: ; preds = %111, %10
%115 = phi i32 [ -1, %10 ], [ 0, %111 ]
ret i32 %115
}