#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*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, double);
int /*<<< orphan*/ remez(double *, int, int, double *, double *, double *, int);
int main() {
  double *weights, *desired, *bands;
  double *h;
  int i;
  bands = (double *)malloc(10 * sizeof(double));
  weights = (double *)malloc(5 * sizeof(double));
  desired = (double *)malloc(5 * sizeof(double));
  h = (double *)malloc(600 * sizeof(double));
  desired[0] = 0;
  desired[1] = 1;
  desired[2] = 0;
  weights[0] = 1;
  weights[1] = 1;
  weights[2] = 1;
  bands[0] = 0;
  bands[1] = 0.12;
  bands[2] = 0.17;
  bands[3] = 0.28;
  bands[4] = 0.33;
  bands[5] = 0.50;
  remez(h, 102, 2, bands, desired, weights, 1);
  for (i = 0; i < 102; i++) {
    printf("%3d, %23.20f\n", i, h[i]);
  }
  free(bands);
  free(weights);
  free(desired);
  free(h);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x12c0,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe6d(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe28(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe0f(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x20(%rbp),%rax
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x20(%rbp),%rax
movsd  0xddd(%rip),%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x20(%rbp),%rax
movsd  0xdc4(%rip),%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    $0x66,%esi
mov    $0x2,%edx
movl   $0x1,(%rsp)
call   1050 <remez@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x66,-0x2c(%rbp)
jge    12a2 <main+0x162>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126e <main+0x12e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x12c0,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movhps 0xe74(%rip),%xmm1
movups %xmm1,(%r15)
movq   $0x0,0x10(%r15)
movaps 0xe71(%rip),%xmm1
movups %xmm1,(%r14)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%r14)
movhps 0xe50(%rip),%xmm0
movups %xmm0,(%r12)
movaps 0xe5c(%rip),%xmm0
movups %xmm0,0x10(%r12)
movaps 0xe5f(%rip),%xmm0
movups %xmm0,0x20(%r12)
movl   $0x1,(%rsp)
mov    %r13,%rdi
mov    $0x66,%esi
mov    $0x2,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
call   1050 <remez@plt>
xor    %ebx,%ebx
lea    0xe3e(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x66,%rbx
jne    1210 <main+0xd0>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%3d, %23.20f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i64 @malloc(i32 80)
%8 = inttoptr i64 %7 to double*
store double* %8, double** %4
%9 = call i64 @malloc(i32 40)
%10 = inttoptr i64 %9 to double*
store double* %10, double** %2
%11 = call i64 @malloc(i32 40)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %3
%13 = call i64 @malloc(i32 4800)
%14 = inttoptr i64 %13 to double*
store double* %14, double** %5
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
store double 0.000000e+00, double* %16
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 1
store double 1.000000e+00, double* %18
%19 = load double*, double** %3
%20 = getelementptr inbounds double, double* %19, i64 2
store double 0.000000e+00, double* %20
%21 = load double*, double** %2
%22 = getelementptr inbounds double, double* %21, i64 0
store double 1.000000e+00, double* %22
%23 = load double*, double** %2
%24 = getelementptr inbounds double, double* %23, i64 1
store double 1.000000e+00, double* %24
%25 = load double*, double** %2
%26 = getelementptr inbounds double, double* %25, i64 2
store double 1.000000e+00, double* %26
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 0
store double 0.000000e+00, double* %28
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 1
store double 1.200000e-01, double* %30
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 2
store double 1.700000e-01, double* %32
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 3
store double 2.800000e-01, double* %34
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 4
store double 3.300000e-01, double* %36
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 5
store double 5.000000e-01, double* %38
%39 = load double*, double** %5
%40 = load double*, double** %4
%41 = load double*, double** %3
%42 = load double*, double** %2
%43 = call i32 @remez(double* %39, i32 102, i32 2, double* %40, double* %41, double* %42, i32 1)
store i32 0, i32* %6
br label %44
44: ; preds = %55, %0
%45 = load i32, i32* %6
%46 = icmp slt i32 %45, 102
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = load i32, i32* %6
%49 = load double*, double** %5
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %48, double %53)
br label %55
55: ; preds = %47
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %44
58: ; preds = %44
%59 = load double*, double** %4
%60 = call i32 @free(double* %59)
%61 = load double*, double** %2
%62 = call i32 @free(double* %61)
%63 = load double*, double** %3
%64 = call i32 @free(double* %63)
%65 = load double*, double** %5
%66 = call i32 @free(double* %65)
ret i32 1
}

LLVM IR (-O2):
@.str = [14 x i8] c"%3d, %23.20f\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 80)
%2 = inttoptr i64 %1 to double*
%3 = tail call i64 @malloc(i32 40)
%4 = inttoptr i64 %3 to double*
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to double*
%7 = tail call i64 @malloc(i32 4800)
%8 = inttoptr i64 %7 to double*
%9 = inttoptr i64 %5 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds double, double* %6, i64 2
store double 0.000000e+00, double* %10
%11 = inttoptr i64 %3 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds double, double* %4, i64 2
store double 1.000000e+00, double* %12
%13 = inttoptr i64 %1 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.200000e-01>, <2 x double>* %13
%14 = getelementptr inbounds double, double* %2, i64 2
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 1.700000e-01, double 2.800000e-01>, <2 x double>* %15
%16 = getelementptr inbounds double, double* %2, i64 4
%17 = bitcast double* %16 to <2 x double>*
store <2 x double> <double 3.300000e-01, double 5.000000e-01>, <2 x double>* %17
%18 = tail call i32 @remez(double* %8, i32 102, i32 2, double* %2, double* %6, double* %4, i32 1)
br label %19
19: ; preds = %0, %19
%20 = phi i64 [ 0, %0 ], [ %25, %19 ]
%21 = getelementptr inbounds double, double* %8, i64 %20
%22 = load double, double* %21
%23 = trunc i64 %20 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %23, double %22)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, 102
br i1 %26, label %27, label %19
27: ; preds = %19
%28 = tail call i32 @free(double* %2)
%29 = tail call i32 @free(double* %4)
%30 = tail call i32 @free(double* %6)
%31 = tail call i32 @free(double* %8)
ret i32 1
}