#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, float, ...);
int /*<<< orphan*/ stderr;
int fit_parab(float x1, float y1, float x2, float y2, float x3, float y3,
              float *a, float *b, float *c, int doprint) {
  if (x1 == x2 || x1 == x3 || x2 == x3) {
    fprintf(stderr, "ERROR: fit_parab.  Repeated x values.\n");
    return 1;
  }
  *a = ((y1 - y3) * (x2 - x3) - (y2 - y3) * (x1 - x3)) /
       ((x1 - x2) * (x2 - x3) * (x1 - x3));
  *b = (y2 - y3) / (x2 - x3) - *a * (x2 + x3);
  *c = y3 - *a * x3 * x3 - *b * x3;
  if (doprint) {
    printf("For the 3 points (%f,%f) (%f,%f) (%f,%f)\n", x1, y1, x2, y2, x3,
           y3);
    printf(" the parabola has parameters a=%g, b=%f, c=%f\n\n", *a, *b, *c);
    printf("The minimum value occurs at x = %f\n\n", -(*b) / (2 * *a));
  }
  return 0;
}


x86 assembly (clang, -O0):
<fit_parab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  %xmm4,-0x18(%rbp)
movss  %xmm5,-0x1c(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %ecx,-0x3c(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jne    116f <fit_parab+0x4f>
jp     116f <fit_parab+0x4f>
jmp    119e <fit_parab+0x7e>
movss  -0x8(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    1189 <fit_parab+0x69>
jp     1189 <fit_parab+0x69>
jmp    119e <fit_parab+0x7e>
movss  -0x10(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    11bf <fit_parab+0x9f>
jp     11bf <fit_parab+0x9f>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1385 <fit_parab+0x265>
movss  -0xc(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
subss  -0x18(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
movss  -0x8(%rbp),%xmm3
subss  -0x18(%rbp),%xmm3
mulss  %xmm3,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
subss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  -0x8(%rbp),%xmm2
subss  -0x18(%rbp),%xmm2
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
divss  %xmm0,%xmm1
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x10(%rbp),%xmm2
addss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
mulss  -0x18(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movss  %xmm0,(%rax)
cmpl   $0x0,-0x3c(%rbp)
je     137e <fit_parab+0x25e>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x14(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x18(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x1c(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    0xd19(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd15(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x28(%rbp),%rax
movss  0xc98(%rip),%xmm1
mulss  (%rax),%xmm1
divss  %xmm1,%xmm0
lea    0xd0e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fit_parab>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
ucomiss %xmm4,%xmm2
jne    1132 <fit_parab+0x12>
jnp    124e <fit_parab+0x12e>
ucomiss %xmm2,%xmm0
jne    113d <fit_parab+0x1d>
jnp    124e <fit_parab+0x12e>
ucomiss %xmm4,%xmm0
jne    1148 <fit_parab+0x28>
jnp    124e <fit_parab+0x12e>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movaps %xmm1,%xmm7
subss  %xmm5,%xmm7
movaps %xmm2,%xmm8
subss  %xmm4,%xmm8
movaps %xmm3,%xmm10
subss  %xmm5,%xmm10
movaps %xmm0,%xmm9
subss  %xmm4,%xmm9
movaps %xmm0,%xmm6
subss  %xmm2,%xmm6
mulss  %xmm8,%xmm6
mulss  %xmm9,%xmm6
mulss  %xmm10,%xmm9
mulss  %xmm8,%xmm7
subss  %xmm9,%xmm7
divss  %xmm6,%xmm7
movss  %xmm7,(%rdi)
divss  %xmm8,%xmm10
movaps %xmm2,%xmm6
addss  %xmm4,%xmm6
mulss  %xmm7,%xmm6
subss  %xmm6,%xmm10
movss  %xmm10,(%rsi)
movss  (%rdi),%xmm6
mulss  %xmm4,%xmm6
mulss  %xmm4,%xmm6
movaps %xmm5,%xmm7
subss  %xmm6,%xmm7
mulss  %xmm4,%xmm10
subss  %xmm10,%xmm7
movss  %xmm7,(%rdx)
xor    %ebp,%ebp
test   %ecx,%ecx
je     1268 <fit_parab+0x148>
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
cvtss2sd %xmm3,%xmm3
cvtss2sd %xmm4,%xmm4
cvtss2sd %xmm5,%xmm5
lea    0xe3c(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
movss  (%rbx),%xmm0
movss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
movss  (%r15),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe42(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  (%r14),%xmm0
xorps  0xdce(%rip),%xmm0
movss  (%rbx),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1268 <fit_parab+0x148>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"ERROR: fit_parab. Repeated x values.\0A\00"
@.str.1 = [42 x i8] c"For the 3 points (%f,%f) (%f,%f) (%f,%f)\0A\00"
@.str.2 = [48 x i8] c" the parabola has parameters a=%g, b=%f, c=%f\0A\0A\00"
@.str.3 = [37 x i8] c"The minimum value occurs at x = %f\0A\0A\00"
define i32 @fit_parab(float %0, float %1, float %2, float %3, float %4, float %5, float* %6, float* %7, float* %8, i32 %9) {
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float*
%19 = alloca float*
%20 = alloca float*
%21 = alloca i32
store float %0, float* %12
store float %1, float* %13
store float %2, float* %14
store float %3, float* %15
store float %4, float* %16
store float %5, float* %17
store float* %6, float** %18
store float* %7, float** %19
store float* %8, float** %20
store i32 %9, i32* %21
%22 = load float, float* %12
%23 = load float, float* %14
%24 = fcmp oeq float %22, %23
br i1 %24, label %33, label %25
25: ; preds = %10
%26 = load float, float* %12
%27 = load float, float* %16
%28 = fcmp oeq float %26, %27
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load float, float* %14
%31 = load float, float* %16
%32 = fcmp oeq float %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29, %25, %10
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %11
br label %127
36: ; preds = %29
%37 = load float, float* %13
%38 = load float, float* %17
%39 = fsub float %37, %38
%40 = load float, float* %14
%41 = load float, float* %16
%42 = fsub float %40, %41
%43 = load float, float* %15
%44 = load float, float* %17
%45 = fsub float %43, %44
%46 = load float, float* %12
%47 = load float, float* %16
%48 = fsub float %46, %47
%49 = fmul float %45, %48
%50 = fneg float %49
%51 = call float @llvm.fmuladd.f32(float %39, float %42, float %50)
%52 = load float, float* %12
%53 = load float, float* %14
%54 = fsub float %52, %53
%55 = load float, float* %14
%56 = load float, float* %16
%57 = fsub float %55, %56
%58 = fmul float %54, %57
%59 = load float, float* %12
%60 = load float, float* %16
%61 = fsub float %59, %60
%62 = fmul float %58, %61
%63 = fdiv float %51, %62
%64 = load float*, float** %18
store float %63, float* %64
%65 = load float, float* %15
%66 = load float, float* %17
%67 = fsub float %65, %66
%68 = load float, float* %14
%69 = load float, float* %16
%70 = fsub float %68, %69
%71 = fdiv float %67, %70
%72 = load float*, float** %18
%73 = load float, float* %72
%74 = load float, float* %14
%75 = load float, float* %16
%76 = fadd float %74, %75
%77 = fneg float %73
%78 = call float @llvm.fmuladd.f32(float %77, float %76, float %71)
%79 = load float*, float** %19
store float %78, float* %79
%80 = load float, float* %17
%81 = load float*, float** %18
%82 = load float, float* %81
%83 = load float, float* %16
%84 = fmul float %82, %83
%85 = load float, float* %16
%86 = fneg float %84
%87 = call float @llvm.fmuladd.f32(float %86, float %85, float %80)
%88 = load float*, float** %19
%89 = load float, float* %88
%90 = load float, float* %16
%91 = fneg float %89
%92 = call float @llvm.fmuladd.f32(float %91, float %90, float %87)
%93 = load float*, float** %20
store float %92, float* %93
%94 = load i32, i32* %21
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %126
96: ; preds = %36
%97 = load float, float* %12
%98 = load float, float* %13
%99 = fpext float %98 to double
%100 = load float, float* %14
%101 = fpext float %100 to double
%102 = load float, float* %15
%103 = fpext float %102 to double
%104 = load float, float* %16
%105 = fpext float %104 to double
%106 = load float, float* %17
%107 = fpext float %106 to double
%108 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), float %97, double %99, double %101, double %103, double %105, double %107)
%109 = load float*, float** %18
%110 = load float, float* %109
%111 = load float*, float** %19
%112 = load float, float* %111
%113 = fpext float %112 to double
%114 = load float*, float** %20
%115 = load float, float* %114
%116 = fpext float %115 to double
%117 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), float %110, double %113, double %116)
%118 = load float*, float** %19
%119 = load float, float* %118
%120 = fneg float %119
%121 = load float*, float** %18
%122 = load float, float* %121
%123 = fmul float 2.000000e+00, %122
%124 = fdiv float %120, %123
%125 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), float %124)
br label %126
126: ; preds = %96, %36
store i32 0, i32* %11
br label %127
127: ; preds = %126, %33
%128 = load i32, i32* %11
ret i32 %128
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"ERROR: fit_parab. Repeated x values.\0A\00"
@.str.1 = [42 x i8] c"For the 3 points (%f,%f) (%f,%f) (%f,%f)\0A\00"
@.str.2 = [48 x i8] c" the parabola has parameters a=%g, b=%f, c=%f\0A\0A\00"
@.str.3 = [37 x i8] c"The minimum value occurs at x = %f\0A\0A\00"
define i32 @fit_parab(float %0, float %1, float %2, float %3, float %4, float %5, float* nocapture %6, float* nocapture %7, float* nocapture %8, i32 %9) {
%11 = fcmp oeq float %0, %2
%12 = fcmp oeq float %0, %4
%13 = or i1 %11, %12
%14 = fcmp oeq float %2, %4
%15 = or i1 %14, %13
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %61
19: ; preds = %10
%20 = fsub float %1, %5
%21 = fsub float %2, %4
%22 = fsub float %3, %5
%23 = fsub float %0, %4
%24 = fneg float %22
%25 = fmul float %23, %24
%26 = tail call float @llvm.fmuladd.f32(float %20, float %21, float %25)
%27 = fsub float %0, %2
%28 = fmul float %27, %21
%29 = fmul float %23, %28
%30 = fdiv float %26, %29
store float %30, float* %6
%31 = fdiv float %22, %21
%32 = fadd float %2, %4
%33 = fneg float %30
%34 = tail call float @llvm.fmuladd.f32(float %33, float %32, float %31)
store float %34, float* %7
%35 = load float, float* %6
%36 = fneg float %35
%37 = fmul float %36, %4
%38 = tail call float @llvm.fmuladd.f32(float %37, float %4, float %5)
%39 = fneg float %34
%40 = tail call float @llvm.fmuladd.f32(float %39, float %4, float %38)
store float %40, float* %8
%41 = icmp eq i32 %9, 0
br i1 %41, label %61, label %42
42: ; preds = %19
%43 = fpext float %1 to double
%44 = fpext float %2 to double
%45 = fpext float %3 to double
%46 = fpext float %4 to double
%47 = fpext float %5 to double
%48 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), float %0, double %43, double %44, double %45, double %46, double %47)
%49 = load float, float* %6
%50 = load float, float* %7
%51 = fpext float %50 to double
%52 = load float, float* %8
%53 = fpext float %52 to double
%54 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), float %49, double %51, double %53)
%55 = load float, float* %7
%56 = fneg float %55
%57 = load float, float* %6
%58 = fmul float %57, 2.000000e+00
%59 = fdiv float %56, %58
%60 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), float %59)
br label %61
61: ; preds = %19, %42, %16
%62 = phi i32 [ 1, %16 ], [ 0, %42 ], [ 0, %19 ]
ret i32 %62
}