#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_vector(float *, int /*<<< orphan*/, int);
int /*<<< orphan*/ poldiv(float *, int, float *, int, float *, float *);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int /*<<< orphan*/, int);
int main(void) {
  int i;
  static float u[5 + 1] = {-1.0, 5.0, -10.0, 10.0, -5.0, 1.0};
  static float v[3 + 1] = {1.0, 3.0, 3.0, 1.0};
  float *q, *r;
  q = vector(0, 5);
  r = vector(0, 5);
  poldiv(u, 5, v, 3, q, r);
  printf("\n%10s %10s %10s %10s %10s %10s\n\n", "x^0", "x^1", "x^2", "x^3",
         "x^4", "x^5");
  printf("quotient polynomial coefficients:\n");
  for (i = 0; i <= 5; i++)
    printf("%10.2f ", q[i]);
  printf("\nexpected quotient coefficients:\n");
  printf("%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f\n\n", 31.0, -8.0, 1.0, 0.0,
         0.0, 0.0);
  printf("remainder polynomial coefficients:\n");
  for (i = 0; i <= 3; i++)
    printf("%10.2f ", r[i]);
  printf("\nexpected remainder coefficients:\n");
  printf("%10.2f %10.2f %10.2f %10.2f\n", -32.0, -80.0, -80.0, 0.0);
  free_vector(r, 0, 5);
  free_vector(q, 0, 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
mov    $0x5,%esi
call   1060 <vector@plt>
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
mov    $0x5,%esi
call   1060 <vector@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0x2ed2(%rip),%rdi
mov    $0x5,%esi
lea    0x2ee6(%rip),%rdx
mov    $0x3,%ecx
call   1030 <poldiv@plt>
lea    0xe8d(%rip),%rdi
lea    0xea7(%rip),%rsi
lea    0xea4(%rip),%rdx
lea    0xea1(%rip),%rcx
lea    0xe9e(%rip),%r8
lea    0xe9b(%rip),%r9
lea    0xe98(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     121c <main+0xdc>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e5 <main+0xa5>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
movsd  0xdc7(%rip),%xmm0
movsd  0xdc7(%rip),%xmm1
movsd  0xdc7(%rip),%xmm2
xorps  %xmm5,%xmm5
movaps %xmm5,%xmm3
movaps %xmm5,%xmm4
mov    $0x6,%al
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     12a5 <main+0x165>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126e <main+0x12e>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
movsd  0xd56(%rip),%xmm0
movsd  0xd56(%rip),%xmm2
xorps  %xmm3,%xmm3
movaps %xmm2,%xmm1
mov    $0x4,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <free_vector@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
mov    $0x5,%esi
call   1070 <vector@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    $0x5,%esi
call   1070 <vector@plt>
mov    %rax,%r14
lea    0x2ed2(%rip),%rdi
lea    0x2eeb(%rip),%rdx
mov    $0x5,%esi
mov    $0x3,%ecx
mov    %rbx,%r8
mov    %rax,%r9
call   1040 <poldiv@plt>
lea    0xebc(%rip),%rax
mov    %rax,(%rsp)
lea    0xe7c(%rip),%rdi
lea    0xe96(%rip),%rsi
lea    0xe93(%rip),%rdx
lea    0xe90(%rip),%rcx
lea    0xe8d(%rip),%r8
lea    0xe8a(%rip),%r9
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x14(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfc(%rip),%rdi
movsd  0xd8b(%rip),%xmm0
movsd  0xd8b(%rip),%xmm1
movsd  0xd8b(%rip),%xmm2
xorps  %xmm3,%xmm3
xorps  %xmm4,%xmm4
xorps  %xmm5,%xmm5
mov    $0x6,%al
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
movss  (%r14),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%r14),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%r14),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%r14),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
call   1030 <puts@plt>
lea    0xd92(%rip),%rdi
movsd  0xd0d(%rip),%xmm0
movsd  0xd0d(%rip),%xmm1
xorps  %xmm3,%xmm3
movaps %xmm1,%xmm2
mov    $0x4,%al
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <free_vector@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.u = internal global [6 x float] [float -1.000000e+00, float 5.000000e+00, float -1.000000e+01, float 1.000000e+01, float -5.000000e+00, float 1.000000e+00]
@main.v = internal global [4 x float] [float 1.000000e+00, float 3.000000e+00, float 3.000000e+00, float 1.000000e+00]
@.str = [33 x i8] c"\0A%10s %10s %10s %10s %10s %10s\0A\0A\00"
@.str.1 = [4 x i8] c"x^0\00"
@.str.2 = [4 x i8] c"x^1\00"
@.str.3 = [4 x i8] c"x^2\00"
@.str.4 = [4 x i8] c"x^3\00"
@.str.5 = [4 x i8] c"x^4\00"
@.str.6 = [4 x i8] c"x^5\00"
@.str.7 = [35 x i8] c"quotient polynomial coefficients:\0A\00"
@.str.8 = [8 x i8] c"%10.2f \00"
@.str.9 = [34 x i8] c"\0Aexpected quotient coefficients:\0A\00"
@.str.10 = [44 x i8] c"%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f\0A\0A\00"
@.str.11 = [36 x i8] c"remainder polynomial coefficients:\0A\00"
@.str.12 = [35 x i8] c"\0Aexpected remainder coefficients:\0A\00"
@.str.13 = [29 x i8] c"%10.2f %10.2f %10.2f %10.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float*
%4 = alloca float*
store i32 0, i32* %1
%5 = call float* @vector(i32 0, i32 5)
store float* %5, float** %3
%6 = call float* @vector(i32 0, i32 5)
store float* %6, float** %4
%7 = load float*, float** %3
%8 = load float*, float** %4
%9 = call i32 @poldiv(float* getelementptr inbounds ([6 x float], [6 x float]* @main.u, i64 0, i64 0), i32 5, float* getelementptr inbounds ([4 x float], [4 x float]* @main.v, i64 0, i64 0), i32 3, float* %7, float* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %2
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 5
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load float*, float** %3
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %16, i64 %18
%20 = load float, float* %19
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %12
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), double 3.100000e+01, double -8.000000e+00, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %2
br label %30
30: ; preds = %41, %26
%31 = load i32, i32* %2
%32 = icmp sle i32 %31, 3
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load float*, float** %4
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %39)
br label %41
41: ; preds = %33
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %30
44: ; preds = %30
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), double -3.200000e+01, double -8.000000e+01, double -8.000000e+01, double 0.000000e+00)
%47 = load float*, float** %4
%48 = call i32 @free_vector(float* %47, i32 0, i32 5)
%49 = load float*, float** %3
%50 = call i32 @free_vector(float* %49, i32 0, i32 5)
ret i32 0
}

LLVM IR (-O2):
@main.u = internal global [6 x float] [float -1.000000e+00, float 5.000000e+00, float -1.000000e+01, float 1.000000e+01, float -5.000000e+00, float 1.000000e+00]
@main.v = internal global [4 x float] [float 1.000000e+00, float 3.000000e+00, float 3.000000e+00, float 1.000000e+00]
@.str = [33 x i8] c"\0A%10s %10s %10s %10s %10s %10s\0A\0A\00"
@.str.1 = [4 x i8] c"x^0\00"
@.str.2 = [4 x i8] c"x^1\00"
@.str.3 = [4 x i8] c"x^2\00"
@.str.4 = [4 x i8] c"x^3\00"
@.str.5 = [4 x i8] c"x^4\00"
@.str.6 = [4 x i8] c"x^5\00"
@.str.8 = [8 x i8] c"%10.2f \00"
@.str.10 = [44 x i8] c"%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f\0A\0A\00"
@.str.13 = [29 x i8] c"%10.2f %10.2f %10.2f %10.2f\0A\00"
@str = [34 x i8] c"quotient polynomial coefficients:\00"
@str.14 = [33 x i8] c"\0Aexpected quotient coefficients:\00"
@str.15 = [35 x i8] c"remainder polynomial coefficients:\00"
@str.16 = [34 x i8] c"\0Aexpected remainder coefficients:\00"
define i32 @main() {
%1 = tail call float* @vector(i32 0, i32 5)
%2 = tail call float* @vector(i32 0, i32 5)
%3 = tail call i32 @poldiv(float* getelementptr inbounds ([6 x float], [6 x float]* @main.u, i64 0, i64 0), i32 5, float* getelementptr inbounds ([4 x float], [4 x float]* @main.v, i64 0, i64 0), i32 3, float* %1, float* %2)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%6 = load float, float* %1
%7 = fpext float %6 to double
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %7)
%9 = getelementptr inbounds float, float* %1, i64 1
%10 = load float, float* %9
%11 = fpext float %10 to double
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %11)
%13 = getelementptr inbounds float, float* %1, i64 2
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %15)
%17 = getelementptr inbounds float, float* %1, i64 3
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %19)
%21 = getelementptr inbounds float, float* %1, i64 4
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %23)
%25 = getelementptr inbounds float, float* %1, i64 5
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %27)
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.14, i64 0, i64 0))
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), double 3.100000e+01, double -8.000000e+00, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
%32 = load float, float* %2
%33 = fpext float %32 to double
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %33)
%35 = getelementptr inbounds float, float* %2, i64 1
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %37)
%39 = getelementptr inbounds float, float* %2, i64 2
%40 = load float, float* %39
%41 = fpext float %40 to double
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %41)
%43 = getelementptr inbounds float, float* %2, i64 3
%44 = load float, float* %43
%45 = fpext float %44 to double
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), double %45)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.16, i64 0, i64 0))
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0), double -3.200000e+01, double -8.000000e+01, double -8.000000e+01, double 0.000000e+00)
%49 = tail call i32 @free_vector(float* %2, i32 0, i32 5)
%50 = tail call i32 @free_vector(float* %1, i32 0, i32 5)
ret i32 0
}