#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 */
double fabs(float);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ qroot(float *, int, float *, float *, double);
float *vector(int, int);
int main(void) {
  int i, j, nflag, nroot = 0;
  static float p[6 + 1] = {10.0, -18.0, 25.0, -24.0, 16.0, -6.0, 1.0};
  float *b, *c;
  b = vector(1, 10);
  c = vector(1, 10);
  printf("\nP(x)=x^6-6x^5+16x^4-24x^3+25x^2-18x+10\n");
  printf("Quadratic factors x^2+bx+c\n\n");
  printf("%6s %10s %12s \n\n", "factor", "b", "c");
  for (i = 1; i <= 10; i++) {
    c[i] = 0.5 * i;
    b[i] = -0.5 * i;
    qroot(p, 6, &b[i], &c[i], 1.0e-6);
    if (nroot == 0) {
      printf("%4d %15.6f %12.6f\n", nroot, b[i], c[i]);
      nroot = 1;
    } else {
      nflag = 0;
      for (j = 1; j <= nroot; j++)
        if ((fabs(b[i] - b[j]) < 1.0e-5) && (fabs(c[i] - c[j]) < 1.0e-5))
          nflag = 1;
      if (nflag == 0) {
        printf("%4d %15.6f %12.6f\n", nroot, b[i], c[i]);
        ++nroot;
      }
    }
  }
  free_vector(c, 1, 10);
  free_vector(b, 1, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x1,%edi
mov    $0xa,%esi
call   1070 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0xa,%esi
call   1070 <vector@plt>
mov    %rax,-0x28(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xec1(%rip),%rsi
lea    0xec1(%rip),%rdx
lea    0xebc(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     139a <main+0x24a>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe27(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xdfd(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rdx
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rcx
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
lea    0x2e0b(%rip),%rdi
mov    $0x6,%esi
movsd  0xdae(%rip),%xmm0
call   1060 <qroot@plt>
cmpl   $0x0,-0x14(%rbp)
jne    12a0 <main+0x150>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdf5(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    1387 <main+0x237>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     133c <main+0x1ec>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xd34(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1329 <main+0x1d9>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xd00(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1329 <main+0x1d9>
movl   $0x1,-0x10(%rbp)
jmp    132e <main+0x1de>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12ae <main+0x15e>
cmpl   $0x0,-0x10(%rbp)
jne    1382 <main+0x232>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd10(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1387 <main+0x237>
jmp    138c <main+0x23c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <main+0x82>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1040 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1040 <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    $0xa,%esi
call   1080 <vector@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0xa,%esi
call   1080 <vector@plt>
mov    %rax,0x8(%rsp)
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
lea    0xe77(%rip),%rsi
lea    0xe77(%rip),%rdx
lea    0xe72(%rip),%rcx
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r15d
lea    0x2e81(%rip),%r14
jmp    1226 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x0(%r13),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x0(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe32(%rip),%rdi
mov    %r12d,%esi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x1,%r12d
add    $0x1,%r15
cmp    $0xb,%r15
je     135e <main+0x1fe>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movapd %xmm0,%xmm1
mulsd  0xdc6(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
mov    0x8(%rsp),%rax
lea    (%rax,%r15,4),%rbp
movss  %xmm1,(%rax,%r15,4)
mulsd  0xdb3(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    (%rbx,%r15,4),%r13
movss  %xmm0,(%rbx,%r15,4)
mov    %r14,%rdi
mov    $0x6,%esi
mov    %r13,%rdx
mov    %rbp,%rcx
movsd  0xd97(%rip),%xmm0
call   1070 <qroot@plt>
test   %r12d,%r12d
je     1330 <main+0x1d0>
jle    11f0 <main+0x90>
mov    %r12,0x10(%rsp)
add    $0x1,%r12d
movl   $0x0,0x4(%rsp)
mov    $0x1,%r14d
jmp    12b9 <main+0x159>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,%r12
je     1310 <main+0x1b0>
movss  0x0(%r13),%xmm0
subss  (%rbx,%r14,4),%xmm0
call   1060 <fabs@plt>
movsd  0xd46(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12b0 <main+0x150>
movss  0x0(%rbp),%xmm0
mov    0x8(%rsp),%rax
subss  (%rax,%r14,4),%xmm0
call   1060 <fabs@plt>
movsd  0xd23(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12b0 <main+0x150>
movl   $0x1,0x4(%rsp)
jmp    12b0 <main+0x150>
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x0,0x4(%rsp)
lea    0x2d44(%rip),%r14
mov    0x10(%rsp),%r12
jne    1218 <main+0xb8>
jmp    11f0 <main+0x90>
nopl   0x0(%rax)
movss  0x0(%r13),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x0(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xcf2(%rip),%rdi
xor    %esi,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x1,%r12d
jmp    1218 <main+0xb8>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1050 <free_vector@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1050 <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):
@main.p = internal global [7 x float] [float 1.000000e+01, float -1.800000e+01, float 2.500000e+01, float -2.400000e+01, float 1.600000e+01, float -6.000000e+00, float 1.000000e+00]
@.str = [41 x i8] c"\0AP(x)=x^6-6x^5+16x^4-24x^3+25x^2-18x+10\0A\00"
@.str.1 = [29 x i8] c"Quadratic factors x^2+bx+c\0A\0A\00"
@.str.2 = [17 x i8] c"%6s %10s %12s \0A\0A\00"
@.str.3 = [7 x i8] c"factor\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"c\00"
@.str.6 = [19 x i8] c"%4d %15.6f %12.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
%7 = alloca float*
store i32 0, i32* %1
store i32 0, i32* %5
%8 = call float* @vector(i32 1, i32 10)
store float* %8, float** %6
%9 = call float* @vector(i32 1, i32 10)
store float* %9, float** %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %13
13: ; preds = %119, %0
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 10
br i1 %15, label %16, label %122
16: ; preds = %13
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to double
%19 = fmul double 5.000000e-01, %18
%20 = fptrunc double %19 to float
%21 = load float*, float** %7
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to double
%27 = fmul double -5.000000e-01, %26
%28 = fptrunc double %27 to float
%29 = load float*, float** %6
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
store float %28, float* %32
%33 = load float*, float** %6
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float*, float** %7
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds float, float* %37, i64 %39
%41 = call i32 @qroot(float* getelementptr inbounds ([7 x float], [7 x float]* @main.p, i64 0, i64 0), i32 6, float* %36, float* %40, double 0x3EB0C6F7A0B5ED8D)
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %59
44: ; preds = %16
%45 = load i32, i32* %5
%46 = load float*, float** %6
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = load float*, float** %7
%53 = load i32, i32* %2
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds float, float* %52, i64 %54
%56 = load float, float* %55
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %45, double %51, double %57)
store i32 1, i32* %5
br label %118
59: ; preds = %16
store i32 0, i32* %4
store i32 1, i32* %3
br label %60
60: ; preds = %94, %59
%61 = load i32, i32* %3
%62 = load i32, i32* %5
%63 = icmp sle i32 %61, %62
br i1 %63, label %64, label %97
64: ; preds = %60
%65 = load float*, float** %6
%66 = load i32, i32* %2
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds float, float* %65, i64 %67
%69 = load float, float* %68
%70 = load float*, float** %6
%71 = load i32, i32* %3
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds float, float* %70, i64 %72
%74 = load float, float* %73
%75 = fsub float %69, %74
%76 = call double @fabs(float %75)
%77 = fcmp olt double %76, 1.000000e-05
br i1 %77, label %78, label %93
78: ; preds = %64
%79 = load float*, float** %7
%80 = load i32, i32* %2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
%83 = load float, float* %82
%84 = load float*, float** %7
%85 = load i32, i32* %3
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds float, float* %84, i64 %86
%88 = load float, float* %87
%89 = fsub float %83, %88
%90 = call double @fabs(float %89)
%91 = fcmp olt double %90, 1.000000e-05
br i1 %91, label %92, label %93
92: ; preds = %78
store i32 1, i32* %4
br label %93
93: ; preds = %92, %78, %64
br label %94
94: ; preds = %93
%95 = load i32, i32* %3
%96 = add nsw i32 %95, 1
store i32 %96, i32* %3
br label %60
97: ; preds = %60
%98 = load i32, i32* %4
%99 = icmp eq i32 %98, 0
br i1 %99, label %100, label %117
100: ; preds = %97
%101 = load i32, i32* %5
%102 = load float*, float** %6
%103 = load i32, i32* %2
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds float, float* %102, i64 %104
%106 = load float, float* %105
%107 = fpext float %106 to double
%108 = load float*, float** %7
%109 = load i32, i32* %2
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds float, float* %108, i64 %110
%112 = load float, float* %111
%113 = fpext float %112 to double
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %101, double %107, double %113)
%115 = load i32, i32* %5
%116 = add nsw i32 %115, 1
store i32 %116, i32* %5
br label %117
117: ; preds = %100, %97
br label %118
118: ; preds = %117, %44
br label %119
119: ; preds = %118
%120 = load i32, i32* %2
%121 = add nsw i32 %120, 1
store i32 %121, i32* %2
br label %13
122: ; preds = %13
%123 = load float*, float** %7
%124 = call i32 @free_vector(float* %123, i32 1, i32 10)
%125 = load float*, float** %6
%126 = call i32 @free_vector(float* %125, i32 1, i32 10)
ret i32 0
}

LLVM IR (-O2):
@main.p = internal global [7 x float] [float 1.000000e+01, float -1.800000e+01, float 2.500000e+01, float -2.400000e+01, float 1.600000e+01, float -6.000000e+00, float 1.000000e+00]
@.str.2 = [17 x i8] c"%6s %10s %12s \0A\0A\00"
@.str.3 = [7 x i8] c"factor\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [2 x i8] c"c\00"
@.str.6 = [19 x i8] c"%4d %15.6f %12.6f\0A\00"
@str = [40 x i8] c"\0AP(x)=x^6-6x^5+16x^4-24x^3+25x^2-18x+10\00"
@str.7 = [28 x i8] c"Quadratic factors x^2+bx+c\0A\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 10)
%2 = tail call float* @vector(i32 1, i32 10)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %6
6: ; preds = %0, %60
%7 = phi i64 [ 1, %0 ], [ %62, %60 ]
%8 = phi i32 [ 0, %0 ], [ %61, %60 ]
%9 = trunc i64 %7 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 5.000000e-01
%12 = fptrunc double %11 to float
%13 = getelementptr inbounds float, float* %2, i64 %7
store float %12, float* %13
%14 = fmul double %10, -5.000000e-01
%15 = fptrunc double %14 to float
%16 = getelementptr inbounds float, float* %1, i64 %7
store float %15, float* %16
%17 = tail call i32 @qroot(float* getelementptr inbounds ([7 x float], [7 x float]* @main.p, i64 0, i64 0), i32 6, float* %16, float* %13, double 0x3EB0C6F7A0B5ED8D)
%18 = icmp eq i32 %8, 0
br i1 %18, label %24, label %19
19: ; preds = %6
%20 = icmp slt i32 %8, 1
br i1 %20, label %53, label %21
21: ; preds = %19
%22 = add nuw i32 %8, 1
%23 = zext i32 %22 to i64
br label %30
24: ; preds = %6
%25 = load float, float* %16
%26 = fpext float %25 to double
%27 = load float, float* %13
%28 = fpext float %27 to double
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 0, double %26, double %28)
br label %60
30: ; preds = %21, %47
%31 = phi i64 [ 1, %21 ], [ %49, %47 ]
%32 = phi i32 [ 0, %21 ], [ %48, %47 ]
%33 = load float, float* %16
%34 = getelementptr inbounds float, float* %1, i64 %31
%35 = load float, float* %34
%36 = fsub float %33, %35
%37 = tail call double @fabs(float %36)
%38 = fcmp olt double %37, 1.000000e-05
br i1 %38, label %39, label %47
39: ; preds = %30
%40 = load float, float* %13
%41 = getelementptr inbounds float, float* %2, i64 %31
%42 = load float, float* %41
%43 = fsub float %40, %42
%44 = tail call double @fabs(float %43)
%45 = fcmp olt double %44, 1.000000e-05
br i1 %45, label %46, label %47
46: ; preds = %39
br label %47
47: ; preds = %30, %39, %46
%48 = phi i32 [ 1, %46 ], [ %32, %39 ], [ %32, %30 ]
%49 = add nuw nsw i64 %31, 1
%50 = icmp eq i64 %49, %23
br i1 %50, label %51, label %30
51: ; preds = %47
%52 = icmp eq i32 %48, 0
br i1 %52, label %53, label %60
53: ; preds = %19, %51
%54 = load float, float* %16
%55 = fpext float %54 to double
%56 = load float, float* %13
%57 = fpext float %56 to double
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %8, double %55, double %57)
%59 = add nsw i32 %8, 1
br label %60
60: ; preds = %24, %53, %51
%61 = phi i32 [ 1, %24 ], [ %59, %53 ], [ %8, %51 ]
%62 = add nuw nsw i64 %7, 1
%63 = icmp eq i64 %62, 11
br i1 %63, label %64, label %6
64: ; preds = %60
%65 = tail call i32 @free_vector(float* %2, i32 1, i32 10)
%66 = tail call i32 @free_vector(float* %1, i32 1, i32 10)
ret i32 0
}