#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 pow(float, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
void quadratic_formula() {
  float a, b, c, d, qf1, qf2;
  int dis;
  printf("A value: ");
  scanf("%f", &a);
  printf("B value: ");
  scanf("%f", &b);
  printf("C value: ");
  scanf("%f", &c);
  dis = pow(b, 2) - (4 * a * c);
  if (dis < 0) {
    printf("No real solutions\n");
  } else {
    d = (pow(b, 2)) - (4 * a * c);
    d = pow(d, .5);
    qf1 = (-b + d) / (2 * a);
    qf2 = (-b - d) / (2 * a);
    if (dis == 0) {
      printf("Solution: (%f", qf1);
      printf(",0)\n");
    } else {
      printf("Solution 1: (%f", qf1);
      printf(",0)\n");
      printf("Solution 2: (%f", qf2);
      printf(",0)\n");
      ;
    }
  }
}


x86 assembly (clang, -O0):
<quadratic_formula>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm1
movss  0xe50(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11f3 <quadratic_formula+0xc3>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132d <quadratic_formula+0x1fd>
movss  -0x8(%rbp),%xmm0
movsd  0xe08(%rip),%xmm1
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm1
movss  0xdef(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movsd  0xdce(%rip),%xmm1
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xd95(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x10(%rbp),%xmm0
movss  0xd68(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12de <quadratic_formula+0x1ae>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd85(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <quadratic_formula+0x1f8>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd59(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132d <quadratic_formula+0x1fd>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quadratic_formula>:
push   %rbx
sub    $0x20,%rsp
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0f(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
movsd  0xe55(%rip),%xmm1
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x8(%rsp),%xmm1
mulss  0xe4b(%rip),%xmm1
mulss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
cvttss2si %xmm1,%ebx
test   %ebx,%ebx
js     1280 <quadratic_formula+0x140>
movss  0x4(%rsp),%xmm0
movsd  0xe17(%rip),%xmm1
call   1060 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  0x8(%rsp),%xmm0
mulss  0xe0d(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
movsd  0xdf3(%rip),%xmm1
call   1060 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  0x4(%rsp),%xmm3
movaps %xmm1,%xmm0
subss  %xmm3,%xmm0
movss  0x8(%rsp),%xmm2
addss  %xmm2,%xmm2
divss  %xmm2,%xmm0
test   %ebx,%ebx
je     1289 <quadratic_formula+0x149>
xorps  0xdd9(%rip),%xmm3
subss  %xmm1,%xmm3
divss  %xmm2,%xmm3
movaps %xmm3,0x10(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf3(%rip),%rdi
movaps 0x10(%rsp),%xmm0
jmp    1290 <quadratic_formula+0x150>
lea    0xdf9(%rip),%rdi
jmp    12a2 <quadratic_formula+0x162>
lea    0xdbe(%rip),%rdi
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdda(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"A value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [10 x i8] c"B value: \00"
@.str.3 = [10 x i8] c"C value: \00"
@.str.4 = [19 x i8] c"No real solutions\0A\00"
@.str.5 = [14 x i8] c"Solution: (%f\00"
@.str.6 = [5 x i8] c",0)\0A\00"
@.str.7 = [16 x i8] c"Solution 1: (%f\00"
@.str.8 = [16 x i8] c"Solution 2: (%f\00"
define void @quadratic_formula() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%14 = load float, float* %2
%15 = call i32 @pow(float %14, double 2.000000e+00)
%16 = sitofp i32 %15 to float
%17 = load float, float* %1
%18 = fmul float 4.000000e+00, %17
%19 = load float, float* %3
%20 = fneg float %18
%21 = call float @llvm.fmuladd.f32(float %20, float %19, float %16)
%22 = fptosi float %21 to i32
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %70
27: ; preds = %0
%28 = load float, float* %2
%29 = call i32 @pow(float %28, double 2.000000e+00)
%30 = sitofp i32 %29 to float
%31 = load float, float* %1
%32 = fmul float 4.000000e+00, %31
%33 = load float, float* %3
%34 = fneg float %32
%35 = call float @llvm.fmuladd.f32(float %34, float %33, float %30)
store float %35, float* %4
%36 = load float, float* %4
%37 = call i32 @pow(float %36, double 5.000000e-01)
%38 = sitofp i32 %37 to float
store float %38, float* %4
%39 = load float, float* %2
%40 = fneg float %39
%41 = load float, float* %4
%42 = fadd float %40, %41
%43 = load float, float* %1
%44 = fmul float 2.000000e+00, %43
%45 = fdiv float %42, %44
store float %45, float* %5
%46 = load float, float* %2
%47 = fneg float %46
%48 = load float, float* %4
%49 = fsub float %47, %48
%50 = load float, float* %1
%51 = fmul float 2.000000e+00, %50
%52 = fdiv float %49, %51
store float %52, float* %6
%53 = load i32, i32* %7
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %27
%56 = load float, float* %5
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %69
60: ; preds = %27
%61 = load float, float* %5
%62 = fpext float %61 to double
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), double %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%65 = load float, float* %6
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %69
69: ; preds = %60, %55
br label %70
70: ; preds = %69, %25
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"A value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [10 x i8] c"B value: \00"
@.str.3 = [10 x i8] c"C value: \00"
@.str.5 = [14 x i8] c"Solution: (%f\00"
@.str.7 = [16 x i8] c"Solution 1: (%f\00"
@.str.8 = [16 x i8] c"Solution 2: (%f\00"
@str.10 = [4 x i8] c",0)\00"
@str.11 = [18 x i8] c"No real solutions\00"
define void @quadratic_formula() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = load float, float* %2
%14 = call i32 @pow(float %13, double 2.000000e+00)
%15 = sitofp i32 %14 to float
%16 = load float, float* %1
%17 = load float, float* %3
%18 = fmul float %16, -4.000000e+00
%19 = call float @llvm.fmuladd.f32(float %18, float %17, float %15)
%20 = fptosi float %19 to i32
%21 = icmp slt i32 %20, 0
br i1 %21, label %51, label %22
22: ; preds = %0
%23 = load float, float* %2
%24 = call i32 @pow(float %23, double 2.000000e+00)
%25 = sitofp i32 %24 to float
%26 = load float, float* %1
%27 = load float, float* %3
%28 = fmul float %26, -4.000000e+00
%29 = call float @llvm.fmuladd.f32(float %28, float %27, float %25)
%30 = call i32 @pow(float %29, double 5.000000e-01)
%31 = sitofp i32 %30 to float
%32 = load float, float* %2
%33 = fsub float %31, %32
%34 = load float, float* %1
%35 = fmul float %34, 2.000000e+00
%36 = fdiv float %33, %35
%37 = icmp eq i32 %20, 0
br i1 %37, label %45, label %38
38: ; preds = %22
%39 = fneg float %32
%40 = fsub float %39, %31
%41 = fdiv float %40, %35
%42 = fpext float %36 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), double %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
br label %45
45: ; preds = %22, %38
%46 = phi float [ %41, %38 ], [ %36, %22 ]
%47 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), %38 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %22 ]
%48 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0), %38 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0), %22 ]
%49 = fpext float %46 to double
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %47, double %49)
br label %51
51: ; preds = %45, %0
%52 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0), %0 ], [ %48, %45 ]
%53 = call i32 @puts(i8* dereferenceable(1) %52)
ret void
}