#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 EXIT_SUCCESS;
double M_PI_4;
double M_SQRT1_2;
double M_SQRT2;
double err_bound(int, double, double, double);
scalar_t__ f(double);
double fabs(scalar_t__);
int /*<<< orphan*/ printf(char *, int, double, double);
scalar_t__ sinc_approx(int, double, double, double);
int main() {
  int i, N;
  double K = 1.0;
  double d = 1.4;
  double mu = M_PI_4;
  double s, t;
  double err, maxerr;
  for (N = 2; N <= 50; N += 5) {
    s = 1;
    t = 1;
    maxerr = fabs(f(t) - sinc_approx(N, d, mu, t));
    for (i = 1; i <= 100; i++) {
      s *= M_SQRT1_2;
      t *= M_SQRT2;
      err = fabs(f(s) - sinc_approx(N, d, mu, s));
      if (maxerr < err)
        maxerr = err;
      err = fabs(f(t) - sinc_approx(N, d, mu, t));
      if (maxerr < err)
        maxerr = err;
    }
    printf("%d\t%e\t%e\n", N, maxerr, err_bound(N, K, d, mu));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8c(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e68(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0x32,-0xc(%rbp)
jg     132c <main+0x1dc>
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe59(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <f@plt>
mov    %rax,-0x50(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1070 <sinc_approx@plt>
mov    -0x50(%rbp),%rdi
sub    %rax,%rdi
call   1050 <fabs@plt>
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     12e0 <main+0x190>
mov    0x2dce(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2dc1(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <f@plt>
mov    %rax,-0x58(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1070 <sinc_approx@plt>
mov    -0x58(%rbp),%rdi
sub    %rax,%rdi
call   1050 <fabs@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1279 <main+0x129>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <f@plt>
mov    %rax,-0x60(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1070 <sinc_approx@plt>
mov    -0x60(%rbp),%rdi
sub    %rax,%rdi
call   1050 <fabs@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12cd <main+0x17d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12d2 <main+0x182>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f1 <main+0xa1>
mov    -0xc(%rbp),%eax
mov    %eax,-0x6c(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1060 <err_bound@plt>
mov    -0x6c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
lea    0xcf7(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1190 <main+0x40>
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e83(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%r12d
movsd  0xe83(%rip),%xmm0
mov    0x2e4c(%rip),%r13
mov    0x2e4d(%rip),%r14
nopl   0x0(%rax,%rax,1)
call   1030 <f@plt>
mov    %rax,%r15
mov    %r12d,%edi
movsd  0xe65(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0xe4f(%rip),%xmm2
call   1070 <sinc_approx@plt>
sub    %rax,%r15
mov    %r15,%rdi
call   1050 <fabs@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x64,%ebp
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
movsd  0x20(%rsp),%xmm1
mulsd  0x0(%r13),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  (%r14),%xmm0
movsd  %xmm0,0x18(%rsp)
movapd %xmm1,%xmm0
call   1030 <f@plt>
mov    %rax,%rbx
mov    %r12d,%edi
movsd  0xdee(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
call   1070 <sinc_approx@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1050 <fabs@plt>
maxsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <f@plt>
mov    %rax,%rbx
mov    %r12d,%edi
movsd  0xdad(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1070 <sinc_approx@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1050 <fabs@plt>
maxsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%ebp
jne    11e0 <main+0x90>
mov    %r12d,%edi
movsd  0xd69(%rip),%xmm0
movsd  0xd69(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
call   1060 <err_bound@plt>
movaps %xmm0,%xmm1
lea    0xd5c(%rip),%rdi
mov    %r12d,%esi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
movsd  0xd36(%rip),%xmm0
lea    0x5(%r12),%eax
cmp    $0x2e,%r12d
mov    %eax,%r12d
jb     1190 <main+0x40>
mov    0x2ce5(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI_4 = global double 0.000000e+00
@M_SQRT1_2 = global double 0.000000e+00
@M_SQRT2 = global double 0.000000e+00
@.str = [10 x i8] c"%d\09%e\09%e\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %4
store double 1.400000e+00, double* %5
%11 = load double, double* @M_PI_4
store double %11, double* %6
store i32 2, i32* %3
br label %12
12: ; preds = %77, %0
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 50
br i1 %14, label %15, label %80
15: ; preds = %12
store double 1.000000e+00, double* %7
store double 1.000000e+00, double* %8
%16 = load double, double* %8
%17 = call i64 @f(double %16)
%18 = load i32, i32* %3
%19 = load double, double* %5
%20 = load double, double* %6
%21 = load double, double* %8
%22 = call i64 @sinc_approx(i32 %18, double %19, double %20, double %21)
%23 = sub nsw i64 %17, %22
%24 = call double @fabs(i64 %23)
store double %24, double* %10
store i32 1, i32* %2
br label %25
25: ; preds = %65, %15
%26 = load i32, i32* %2
%27 = icmp sle i32 %26, 100
br i1 %27, label %28, label %68
28: ; preds = %25
%29 = load double, double* @M_SQRT1_2
%30 = load double, double* %7
%31 = fmul double %30, %29
store double %31, double* %7
%32 = load double, double* @M_SQRT2
%33 = load double, double* %8
%34 = fmul double %33, %32
store double %34, double* %8
%35 = load double, double* %7
%36 = call i64 @f(double %35)
%37 = load i32, i32* %3
%38 = load double, double* %5
%39 = load double, double* %6
%40 = load double, double* %7
%41 = call i64 @sinc_approx(i32 %37, double %38, double %39, double %40)
%42 = sub nsw i64 %36, %41
%43 = call double @fabs(i64 %42)
store double %43, double* %9
%44 = load double, double* %10
%45 = load double, double* %9
%46 = fcmp olt double %44, %45
br i1 %46, label %47, label %49
47: ; preds = %28
%48 = load double, double* %9
store double %48, double* %10
br label %49
49: ; preds = %47, %28
%50 = load double, double* %8
%51 = call i64 @f(double %50)
%52 = load i32, i32* %3
%53 = load double, double* %5
%54 = load double, double* %6
%55 = load double, double* %8
%56 = call i64 @sinc_approx(i32 %52, double %53, double %54, double %55)
%57 = sub nsw i64 %51, %56
%58 = call double @fabs(i64 %57)
store double %58, double* %9
%59 = load double, double* %10
%60 = load double, double* %9
%61 = fcmp olt double %59, %60
br i1 %61, label %62, label %64
62: ; preds = %49
%63 = load double, double* %9
store double %63, double* %10
br label %64
64: ; preds = %62, %49
br label %65
65: ; preds = %64
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 1
store i32 %67, i32* %2
br label %25
68: ; preds = %25
%69 = load i32, i32* %3
%70 = load double, double* %10
%71 = load i32, i32* %3
%72 = load double, double* %4
%73 = load double, double* %5
%74 = load double, double* %6
%75 = call double @err_bound(i32 %71, double %72, double %73, double %74)
%76 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %69, double %70, double %75)
br label %77
77: ; preds = %68
%78 = load i32, i32* %3
%79 = add nsw i32 %78, 5
store i32 %79, i32* %3
br label %12
80: ; preds = %12
%81 = load i32, i32* @EXIT_SUCCESS
ret i32 %81
}

LLVM IR (-O2):
@M_PI_4 = global double 0.000000e+00
@M_SQRT1_2 = global double 0.000000e+00
@M_SQRT2 = global double 0.000000e+00
@.str = [10 x i8] c"%d\09%e\09%e\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load double, double* @M_PI_4
br label %2
2: ; preds = %0, %31
%3 = phi i32 [ 2, %0 ], [ %34, %31 ]
%4 = tail call i64 @f(double 1.000000e+00)
%5 = tail call i64 @sinc_approx(i32 %3, double 1.400000e+00, double %1, double 1.000000e+00)
%6 = sub nsw i64 %4, %5
%7 = tail call double @fabs(i64 %6)
br label %8
8: ; preds = %2, %8
%9 = phi double [ %7, %2 ], [ %28, %8 ]
%10 = phi double [ 1.000000e+00, %2 ], [ %16, %8 ]
%11 = phi double [ 1.000000e+00, %2 ], [ %14, %8 ]
%12 = phi i32 [ 1, %2 ], [ %29, %8 ]
%13 = load double, double* @M_SQRT1_2
%14 = fmul double %11, %13
%15 = load double, double* @M_SQRT2
%16 = fmul double %10, %15
%17 = tail call i64 @f(double %14)
%18 = tail call i64 @sinc_approx(i32 %3, double 1.400000e+00, double %1, double %14)
%19 = sub nsw i64 %17, %18
%20 = tail call double @fabs(i64 %19)
%21 = fcmp olt double %9, %20
%22 = select i1 %21, double %20, double %9
%23 = tail call i64 @f(double %16)
%24 = tail call i64 @sinc_approx(i32 %3, double 1.400000e+00, double %1, double %16)
%25 = sub nsw i64 %23, %24
%26 = tail call double @fabs(i64 %25)
%27 = fcmp olt double %22, %26
%28 = select i1 %27, double %26, double %22
%29 = add nuw nsw i32 %12, 1
%30 = icmp eq i32 %29, 101
br i1 %30, label %31, label %8
31: ; preds = %8
%32 = tail call double @err_bound(i32 %3, double 1.000000e+00, double 1.400000e+00, double %1)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3, double %28, double %32)
%34 = add nuw nsw i32 %3, 5
%35 = icmp ult i32 %3, 46
br i1 %35, label %2, label %36
36: ; preds = %31
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}