#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 ceil(int /*<<< orphan*/);
int /*<<< orphan*/ remlpord(double const, double const, double const,
                            double const);
int remez_lp_order(const double *fcuts, const double *mag, const double *dev,
                   double *weight) {
  int N = ceil(remlpord(fcuts[1], fcuts[2], dev[0], dev[1]));
  double maxdev = (dev[0] > dev[1] ? dev[0] : dev[1]);
  weight[0] = maxdev / dev[0];
  weight[1] = maxdev / dev[1];
  return N;
}


x86 assembly (clang, -O0):
<remez_lp_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm3
call   1040 <remlpord@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jbe    1193 <remez_lp_order+0x73>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11a1 <remez_lp_order+0x81>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
divsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remez_lp_order>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
movsd  0x8(%rdi),%xmm0
movsd  0x10(%rdi),%xmm1
movsd  (%rdx),%xmm2
movsd  0x8(%rdx),%xmm3
call   1040 <remlpord@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
movsd  (%rbx),%xmm0
movapd %xmm0,%xmm1
maxsd  0x8(%rbx),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%r14)
divsd  0x8(%rbx),%xmm1
movsd  %xmm1,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @remez_lp_order(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 2
%16 = load double, double* %15
%17 = load double*, double** %7
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = load double*, double** %7
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = call i32 @remlpord(double %13, double %16, double %19, double %22)
%24 = call i32 @ceil(i32 %23)
store i32 %24, i32* %9
%25 = load double*, double** %7
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = fcmp ogt double %27, %30
br i1 %31, label %32, label %36
32: ; preds = %4
%33 = load double*, double** %7
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
br label %40
36: ; preds = %4
%37 = load double*, double** %7
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
br label %40
40: ; preds = %36, %32
%41 = phi double [ %35, %32 ], [ %39, %36 ]
store double %41, double* %10
%42 = load double, double* %10
%43 = load double*, double** %7
%44 = getelementptr inbounds double, double* %43, i64 0
%45 = load double, double* %44
%46 = fdiv double %42, %45
%47 = load double*, double** %8
%48 = getelementptr inbounds double, double* %47, i64 0
store double %46, double* %48
%49 = load double, double* %10
%50 = load double*, double** %7
%51 = getelementptr inbounds double, double* %50, i64 1
%52 = load double, double* %51
%53 = fdiv double %49, %52
%54 = load double*, double** %8
%55 = getelementptr inbounds double, double* %54, i64 1
store double %53, double* %55
%56 = load i32, i32* %9
ret i32 %56
}

LLVM IR (-O2):
define i32 @remez_lp_order(double* nocapture %0, double* nocapture readnone %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = load double, double* %2
%10 = getelementptr inbounds double, double* %2, i64 1
%11 = load double, double* %10
%12 = tail call i32 @remlpord(double %6, double %8, double %9, double %11)
%13 = tail call i32 @ceil(i32 %12)
%14 = load double, double* %2
%15 = load double, double* %10
%16 = fcmp ogt double %14, %15
%17 = select i1 %16, double %14, double %15
%18 = fdiv double %17, %14
store double %18, double* %3
%19 = load double, double* %10
%20 = fdiv double %17, %19
%21 = getelementptr inbounds double, double* %3, i64 1
store double %20, double* %21
ret i32 %13
}