#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 int /*<<< orphan*/ complex;

/* Variables and functions */
int M_PI;
double cabs(int /*<<< orphan*/);
double *double_alloc(int);
float *float_alloc(int);
scalar_t__ log10(double);
int /*<<< orphan*/ pz2res(double, int, int /*<<< orphan*/ *, int,
                          int /*<<< orphan*/ *, double);
void compresp(int nf, double *f, int nz, complex *zr, int np, complex *pl,
              double sg, double **y, float **yl) {
  int i;
  double w;
  (*y) = double_alloc(nf);
  (*yl) = float_alloc(nf);
  for (i = 0; i < nf; i++) {
    w = 2 * M_PI * f[i];
    (*y)[i] = cabs(pz2res(w, nz, zr, np, pl, sg));
    (*yl)[i] = (float)log10((*y)[i]);
  }
}


x86 assembly (clang, -O0):
<compresp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <double_alloc@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4(%rbp),%edi
call   1030 <float_alloc@plt>
mov    %rax,%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1240 <compresp+0xf0>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
movsd  -0x38(%rbp),%xmm1
call   1060 <pz2res@plt>
mov    %eax,%edi
call   1040 <cabs@plt>
mov    0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <log10@plt>
cvtsi2ss %rax,%xmm0
mov    0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a6 <compresp+0x56>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compresp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %r9,0x8(%rsp)
mov    %r8d,%ebp
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rsi,%r12
mov    %edi,%r14d
mov    0x50(%rsp),%r13
call   1050 <double_alloc@plt>
mov    %rax,0x0(%r13)
mov    %r14d,%edi
call   1030 <float_alloc@plt>
mov    0x58(%rsp),%r13
mov    %rax,0x0(%r13)
test   %r14d,%r14d
jle    1216 <compresp+0xc6>
mov    %r14d,%eax
mov    %rax,(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%r12,%r14,8),%xmm0
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    0x8(%rsp),%rcx
movsd  0x10(%rsp),%xmm1
call   1060 <pz2res@plt>
mov    %eax,%edi
call   1040 <cabs@plt>
mov    0x50(%rsp),%rax
mov    (%rax),%rax
movsd  %xmm0,(%rax,%r14,8)
call   1070 <log10@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x0(%r13),%rax
movss  %xmm0,(%rax,%r14,4)
add    $0x1,%r14
cmp    %r14,(%rsp)
jne    11b0 <compresp+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @compresp(i32 %0, double* %1, i32 %2, i32* %3, i32 %4, i32* %5, double %6, double** %7, float** %8) {
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32*
%16 = alloca double
%17 = alloca double**
%18 = alloca float**
%19 = alloca i32
%20 = alloca double
store i32 %0, i32* %10
store double* %1, double** %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store i32 %4, i32* %14
store i32* %5, i32** %15
store double %6, double* %16
store double** %7, double*** %17
store float** %8, float*** %18
%21 = load i32, i32* %10
%22 = call double* @double_alloc(i32 %21)
%23 = load double**, double*** %17
store double* %22, double** %23
%24 = load i32, i32* %10
%25 = call float* @float_alloc(i32 %24)
%26 = load float**, float*** %18
store float* %25, float** %26
store i32 0, i32* %19
br label %27
27: ; preds = %67, %9
%28 = load i32, i32* %19
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %70
31: ; preds = %27
%32 = load i32, i32* @M_PI
%33 = mul nsw i32 2, %32
%34 = sitofp i32 %33 to double
%35 = load double*, double** %11
%36 = load i32, i32* %19
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double %34, %39
store double %40, double* %20
%41 = load double, double* %20
%42 = load i32, i32* %12
%43 = load i32*, i32** %13
%44 = load i32, i32* %14
%45 = load i32*, i32** %15
%46 = load double, double* %16
%47 = call i32 @pz2res(double %41, i32 %42, i32* %43, i32 %44, i32* %45, double %46)
%48 = call double @cabs(i32 %47)
%49 = load double**, double*** %17
%50 = load double*, double** %49
%51 = load i32, i32* %19
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %48, double* %53
%54 = load double**, double*** %17
%55 = load double*, double** %54
%56 = load i32, i32* %19
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = call i64 @log10(double %59)
%61 = sitofp i64 %60 to float
%62 = load float**, float*** %18
%63 = load float*, float** %62
%64 = load i32, i32* %19
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
store float %61, float* %66
br label %67
67: ; preds = %31
%68 = load i32, i32* %19
%69 = add nsw i32 %68, 1
store i32 %69, i32* %19
br label %27
70: ; preds = %27
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @compresp(i32 %0, double* nocapture %1, i32 %2, i32* %3, i32 %4, i32* %5, double %6, double** nocapture %7, float** nocapture %8) {
%10 = tail call double* @double_alloc(i32 %0)
store double* %10, double** %7
%11 = tail call float* @float_alloc(i32 %0)
store float* %11, float** %8
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %31, %15 ]
%17 = load i32, i32* @M_PI
%18 = shl nsw i32 %17, 1
%19 = sitofp i32 %18 to double
%20 = getelementptr inbounds double, double* %1, i64 %16
%21 = load double, double* %20
%22 = fmul double %21, %19
%23 = tail call i32 @pz2res(double %22, i32 %2, i32* %3, i32 %4, i32* %5, double %6)
%24 = tail call double @cabs(i32 %23)
%25 = load double*, double** %7
%26 = getelementptr inbounds double, double* %25, i64 %16
store double %24, double* %26
%27 = tail call i64 @log10(double %24)
%28 = sitofp i64 %27 to float
%29 = load float*, float** %8
%30 = getelementptr inbounds float, float* %29, i64 %16
store float %28, float* %30
%31 = add nuw nsw i64 %16, 1
%32 = icmp eq i64 %31, %14
br i1 %32, label %33, label %15
33: ; preds = %15, %9
ret void
}