#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 */
typedef int /*<<< orphan*/ q;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ getch();
int /*<<< orphan*/ polydiv(double *, int, double *, int, double *, int,
                           double *, int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  double p[6] = {4.0, -3.4, 7.0, -4.3, 5.2};
  double q[4] = {3.5, 5.0, -6.4, 7.0};
  double s[3], r[3];
  int i, m, n, k, l;
  m = sizeof(p) / sizeof(double);
  n = sizeof(q) / sizeof(double);
  k = m - n + 1;
  l = n - 1;
  polydiv(p, m, q, n, s, k, r, l);
  printf("\ns[%d]={", k);
  for (i = 0; i < k; i++)
    printf("%5.2lf", s[i]);
  printf("}");
  printf("\nr[%d]={", l);
  for (i = 0; i < l; i++)
    printf(" %5.2lf", r[i]);
  printf("}");
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8c(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0xe86(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe83(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe80(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x6,-0xa8(%rbp)
movl   $0x4,-0xac(%rbp)
mov    -0xa8(%rbp),%eax
sub    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xb4(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0xa8(%rbp),%esi
lea    -0x60(%rbp),%rdx
mov    -0xac(%rbp),%ecx
lea    -0x80(%rbp),%r8
mov    -0xb0(%rbp),%r9d
lea    -0xa0(%rbp),%r10
mov    -0xb4(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <polydiv@plt>
mov    -0xb0(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0xb0(%rbp),%eax
jge    129f <main+0x15f>
movslq -0xa4(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
lea    0xde1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    125e <main+0x11e>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb4(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    130f <main+0x1cf>
movslq -0xa4(%rbp),%rax
movsd  -0xa0(%rbp,%rax,8),%xmm0
ff ff
lea    0xd70(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    12cb <main+0x18b>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movabs $0x4014cccccccccccd,%rax
cc 14 40
mov    %rax,0x60(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
mov    %rsp,%rax
lea    0x40(%rsp),%rdi
lea    0x70(%rsp),%rdx
lea    0x20(%rsp),%r8
mov    $0x6,%esi
mov    $0x4,%ecx
mov    $0x3,%r9d
push   $0x3
push   %rax
call   1040 <polydiv@plt>
add    $0x10,%rsp
lea    0xe79(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
lea    0xe73(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x28(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x7d,%edi
call   1030 <putchar@plt>
lea    0xe2e(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
lea    0xe1f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x7d,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.q = [4 x double] [double 3.500000e+00, double 5.000000e+00, double -6.400000e+00, double 7.000000e+00]
@.str = [9 x i8] c"\0As[%d]={\00"
@.str.1 = [7 x i8] c"%5.2lf\00"
@.str.2 = [2 x i8] c"}\00"
@.str.3 = [9 x i8] c"\0Ar[%d]={\00"
@.str.4 = [8 x i8] c" %5.2lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x double]
%3 = alloca [4 x double]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [6 x double]* %2 to i8*
%12 = bitcast i8* %11 to [6 x double]*
%13 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 0
store double 4.000000e+00, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 1
store double -3.400000e+00, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 2
store double 7.000000e+00, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 3
store double -4.300000e+00, double* %16
%17 = getelementptr inbounds [6 x double], [6 x double]* %12, i32 0, i32 4
store double 5.200000e+00, double* %17
%18 = bitcast [4 x double]* %3 to i8*
store i32 6, i32* %7
store i32 4, i32* %8
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = sub nsw i32 %19, %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %10
%25 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%26 = load i32, i32* %7
%27 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%28 = load i32, i32* %8
%29 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%30 = load i32, i32* %9
%31 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%32 = load i32, i32* %10
%33 = call i32 @polydiv(double* %25, i32 %26, double* %27, i32 %28, double* %29, i32 %30, double* %31, i32 %32)
%34 = load i32, i32* %9
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 0, i32* %6
br label %36
36: ; preds = %46, %0
%37 = load i32, i32* %6
%38 = load i32, i32* %9
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %42
%44 = load double, double* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %44)
br label %46
46: ; preds = %40
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %36
49: ; preds = %36
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = load i32, i32* %10
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %51)
store i32 0, i32* %6
br label %53
53: ; preds = %63, %49
%54 = load i32, i32* %6
%55 = load i32, i32* %10
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %66
57: ; preds = %53
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %59
%61 = load double, double* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %61)
br label %63
63: ; preds = %57
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %53
66: ; preds = %53
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 (...) @getch()
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@__const.main.q = [4 x double] [double 3.500000e+00, double 5.000000e+00, double -6.400000e+00, double 7.000000e+00]
@.str = [9 x i8] c"\0As[%d]={\00"
@.str.1 = [7 x i8] c"%5.2lf\00"
@.str.3 = [9 x i8] c"\0Ar[%d]={\00"
@.str.4 = [8 x i8] c" %5.2lf\00"
define i32 @main() {
%1 = alloca [6 x double]
%2 = alloca [4 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = bitcast [6 x double]* %1 to i8*
%6 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
%7 = bitcast double* %6 to i8*
%8 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 0
%9 = bitcast [6 x double]* %1 to <2 x double>*
store <2 x double> <double 4.000000e+00, double -3.400000e+00>, <2 x double>* %9
%10 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 2
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 7.000000e+00, double -4.300000e+00>, <2 x double>* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
store double 5.200000e+00, double* %12
%13 = bitcast [4 x double]* %2 to i8*
%14 = bitcast [3 x double]* %3 to i8*
%15 = bitcast [3 x double]* %4 to i8*
%16 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%17 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%18 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%19 = call i32 @polydiv(double* %8, i32 6, double* %16, i32 4, double* %17, i32 3, double* %18, i32 3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
%21 = load double, double* %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%27 = load double, double* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 @putchar(i32 125)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 3)
%31 = load double, double* %18
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %31)
%33 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%34 = load double, double* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %34)
%36 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%37 = load double, double* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %37)
%39 = call i32 @putchar(i32 125)
%40 = call i32 (...) @getch()
ret i32 0
}