#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 */
float f(float, double);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ ratint(float *, float *, int, float, float *, float *);
float *vector(int, int);
int main(void) {
  int i;
  float dyy, xx, yexp, yy, *x, *y;
  x = vector(1, 6);
  y = vector(1, 6);
  for (i = 1; i <= 6; i++) {
    x[i] = i * 2.0 / 6;
    y[i] = f(x[i], 1.0);
  }
  printf("\nDiagonal rational function interpolation\n");
  printf("\n%5s %13s %14s %12s\n", "x", "interp.", "accuracy", "actual");
  for (i = 1; i <= 10; i++) {
    xx = 0.2 * i;
    ratint(x, y, 6, xx, &yy, &dyy);
    yexp = f(xx, 1.0);
    printf("%6.2f %12.6f    %11f %13.6f\n", xx, yy, dyy, yexp);
  }
  free_vector(y, 1, 6);
  free_vector(x, 1, 6);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x6,%esi
call   1060 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x6,%esi
call   1060 <vector@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jg     11f9 <main+0xa9>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe61(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movsd  0xe27(%rip),%xmm1
call   1030 <f@plt>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x3c>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3d(%rip),%rdi
lea    0xe4b(%rip),%rsi
lea    0xe46(%rip),%rdx
lea    0xe47(%rip),%rcx
lea    0xe49(%rip),%r8
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     12d2 <main+0x182>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xdb9(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movss  -0x10(%rbp),%xmm0
mov    $0x6,%edx
lea    -0x18(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1070 <ratint@plt>
movss  -0x10(%rbp),%xmm0
movsd  0xd78(%rip),%xmm1
call   1030 <f@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x14(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xdbd(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1238 <main+0xe8>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%edi
mov    $0x6,%esi
call   1070 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x6,%esi
call   1070 <vector@plt>
mov    %rax,%rbx
movl   $0x3eaaaaab,0x4(%r14)
3e
movss  0xe5e(%rip),%xmm0
movsd  0xe6e(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0x4(%rbx)
movl   $0x3f2aaaab,0x8(%r14)
3f
movss  0xe40(%rip),%xmm0
movsd  0xe4c(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0x8(%rbx)
movl   $0x3f800000,0xc(%r14)
3f
movss  0xe22(%rip),%xmm0
movsd  0xe2a(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0xc(%rbx)
movl   $0x3faaaaab,0x10(%r14)
3f
movss  0xe04(%rip),%xmm0
movsd  0xe08(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0x10(%rbx)
movl   $0x3fd55555,0x14(%r14)
3f
movss  0xde6(%rip),%xmm0
movsd  0xde6(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0x14(%rbx)
movl   $0x40000000,0x18(%r14)
40
movss  0xdc8(%rip),%xmm0
movsd  0xdc4(%rip),%xmm1
call   1040 <f@plt>
movss  %xmm0,0x18(%rbx)
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb7(%rip),%rdi
lea    0xdc5(%rip),%rsi
lea    0xdc0(%rip),%rdx
lea    0xdc1(%rip),%rcx
lea    0xdc3(%rip),%r8
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%ebp
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xdad(%rip),%r13
movsd  0xd66(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xd4c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1080 <ratint@plt>
movss  0x4(%rsp),%xmm0
movsd  0xd16(%rip),%xmm1
call   1040 <f@plt>
movss  0x4(%rsp),%xmm1
xorps  %xmm4,%xmm4
cvtss2sd %xmm1,%xmm4
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
mov    %r13,%rdi
movaps %xmm4,%xmm0
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
addsd  0xcce(%rip),%xmm0
add    $0xffffffff,%ebp
jne    12c0 <main+0x160>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"\0ADiagonal rational function interpolation\0A\00"
@.str.1 = [21 x i8] c"\0A%5s %13s %14s %12s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [8 x i8] c"interp.\00"
@.str.4 = [9 x i8] c"accuracy\00"
@.str.5 = [7 x i8] c"actual\00"
@.str.6 = [29 x i8] c"%6.2f %12.6f %11f %13.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
store i32 0, i32* %1
%9 = call float* @vector(i32 1, i32 6)
store float* %9, float** %7
%10 = call float* @vector(i32 1, i32 6)
store float* %10, float** %8
store i32 1, i32* %2
br label %11
11: ; preds = %34, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 6
br i1 %13, label %14, label %37
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fmul double %16, 2.000000e+00
%18 = fdiv double %17, 6.000000e+00
%19 = fptrunc double %18 to float
%20 = load float*, float** %7
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
store float %19, float* %23
%24 = load float*, float** %7
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = load float, float* %27
%29 = call float @f(float %28, double 1.000000e+00)
%30 = load float*, float** %8
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
store float %29, float* %33
br label %34
34: ; preds = %14
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %11
37: ; preds = %11
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %40
40: ; preds = %63, %37
%41 = load i32, i32* %2
%42 = icmp sle i32 %41, 10
br i1 %42, label %43, label %66
43: ; preds = %40
%44 = load i32, i32* %2
%45 = sitofp i32 %44 to double
%46 = fmul double 2.000000e-01, %45
%47 = fptrunc double %46 to float
store float %47, float* %4
%48 = load float*, float** %7
%49 = load float*, float** %8
%50 = load float, float* %4
%51 = call i32 @ratint(float* %48, float* %49, i32 6, float %50, float* %6, float* %3)
%52 = load float, float* %4
%53 = call float @f(float %52, double 1.000000e+00)
store float %53, float* %5
%54 = load float, float* %4
%55 = fpext float %54 to double
%56 = load float, float* %6
%57 = fpext float %56 to double
%58 = load float, float* %3
%59 = fpext float %58 to double
%60 = load float, float* %5
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %55, double %57, double %59, double %61)
br label %63
63: ; preds = %43
%64 = load i32, i32* %2
%65 = add nsw i32 %64, 1
store i32 %65, i32* %2
br label %40
66: ; preds = %40
%67 = load float*, float** %8
%68 = call i32 @free_vector(float* %67, i32 1, i32 6)
%69 = load float*, float** %7
%70 = call i32 @free_vector(float* %69, i32 1, i32 6)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"\0A%5s %13s %14s %12s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [8 x i8] c"interp.\00"
@.str.4 = [9 x i8] c"accuracy\00"
@.str.5 = [7 x i8] c"actual\00"
@.str.6 = [29 x i8] c"%6.2f %12.6f %11f %13.6f\0A\00"
@str = [42 x i8] c"\0ADiagonal rational function interpolation\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call float* @vector(i32 1, i32 6)
%6 = tail call float* @vector(i32 1, i32 6)
%7 = getelementptr inbounds float, float* %5, i64 1
store float 0x3FD5555560000000, float* %7
%8 = tail call float @f(float 0x3FD5555560000000, double 1.000000e+00)
%9 = getelementptr inbounds float, float* %6, i64 1
store float %8, float* %9
%10 = getelementptr inbounds float, float* %5, i64 2
store float 0x3FE5555560000000, float* %10
%11 = tail call float @f(float 0x3FE5555560000000, double 1.000000e+00)
%12 = getelementptr inbounds float, float* %6, i64 2
store float %11, float* %12
%13 = getelementptr inbounds float, float* %5, i64 3
store float 1.000000e+00, float* %13
%14 = tail call float @f(float 1.000000e+00, double 1.000000e+00)
%15 = getelementptr inbounds float, float* %6, i64 3
store float %14, float* %15
%16 = getelementptr inbounds float, float* %5, i64 4
store float 0x3FF5555560000000, float* %16
%17 = tail call float @f(float 0x3FF5555560000000, double 1.000000e+00)
%18 = getelementptr inbounds float, float* %6, i64 4
store float %17, float* %18
%19 = getelementptr inbounds float, float* %5, i64 5
store float 0x3FFAAAAAA0000000, float* %19
%20 = tail call float @f(float 0x3FFAAAAAA0000000, double 1.000000e+00)
%21 = getelementptr inbounds float, float* %6, i64 5
store float %20, float* %21
%22 = getelementptr inbounds float, float* %5, i64 6
store float 2.000000e+00, float* %22
%23 = tail call float @f(float 2.000000e+00, double 1.000000e+00)
%24 = getelementptr inbounds float, float* %6, i64 6
store float %23, float* %24
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %0, %27
%28 = phi i32 [ 1, %0 ], [ %41, %27 ]
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 2.000000e-01
%31 = fptrunc double %30 to float
%32 = call i32 @ratint(float* %5, float* %6, i32 6, float %31, float* %2, float* %1)
%33 = call float @f(float %31, double 1.000000e+00)
%34 = fpext float %31 to double
%35 = load float, float* %2
%36 = fpext float %35 to double
%37 = load float, float* %1
%38 = fpext float %37 to double
%39 = fpext float %33 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %34, double %36, double %38, double %39)
%41 = add nuw nsw i32 %28, 1
%42 = icmp eq i32 %41, 11
br i1 %42, label %43, label %27
43: ; preds = %27
%44 = call i32 @free_vector(float* %6, i32 1, i32 6)
%45 = call i32 @free_vector(float* %5, i32 1, i32 6)
ret i32 0
}