#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 */
float delta(float, float, float);
int ileRozwZdelt(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int /*<<< orphan*/ sqrt(float);
int main(void) {
  float a = 0.0f;
  float b = 0.0f;
  float c = 0.0f;
  float del = 0.0f;
  int ile = 0;
  float x1 = 0.0f;
  float x2 = 0.0f;
  printf("Kalkulator Równań kwadratowych:\n");
  printf("\na=");
  scanf("%f", &a);
  printf("\nb=");
  scanf("%f", &b);
  printf("\nc=");
  scanf("%f", &c);
  printf("\nRównanie:\n");
  printf("%fx^2+%fx+%f\n", a, b, c);
  del = delta(a, b, c);
  ile = ileRozwZdelt(del);
  printf("ma %d rozwiazan\n", ile);
  switch (ile) {
  case 0:
    return 0;
    break;
  case 2:
  case 1:
    x2 = (-b + sqrt(del)) / (2.0f * a);
    x1 = (-b - sqrt(del)) / (2.0f * a);
    break;
  }
  printf("x1=%f x2=%f\n", x1, x2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x25(%rbp)
call   1040 <printf@plt>
mov    -0x25(%rbp),%al
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x25(%rbp),%al
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x25(%rbp),%al
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x25(%rbp),%al
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe16(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1030 <delta@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <ileRozwZdelt@plt>
mov    %eax,%ecx
mov    -0x25(%rbp),%al
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1295 <main+0x145>
jmp    1281 <main+0x131>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     12a1 <main+0x151>
jmp    1329 <main+0x1d9>
movl   $0x0,-0x4(%rbp)
jmp    1350 <main+0x200>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
call   1070 <sqrt@plt>
movss  -0x38(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  0xd29(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x14(%rbp),%xmm0
call   1070 <sqrt@plt>
movss  -0x34(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  0xce5(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd20(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe77(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x8(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe11(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
movss  0x8(%rsp),%xmm2
call   1040 <delta@plt>
movss  %xmm0,0xc(%rsp)
call   1060 <ileRozwZdelt@plt>
mov    %eax,%ebx
lea    0xdee(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x2,%eax
jae    12c0 <main+0x160>
movss  (%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
call   1080 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  (%rsp),%xmm1
xorps  0xd88(%rip),%xmm1
unpcklps %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movss  0x4(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movss  0xc(%rsp),%xmm0
call   1080 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
unpcklps 0x30(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
subps  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
unpcklps 0x20(%rsp),%xmm0
addps  %xmm0,%xmm0
divps  %xmm0,%xmm1
cvtps2pd %xmm1,%xmm0
jmp    12c7 <main+0x167>
xorps  %xmm0,%xmm0
test   %ebx,%ebx
je     12dc <main+0x17c>
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
lea    0xd69(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Kalkulator R\C3\B3wna\C5\84 kwadratowych:\0A\00"
@.str.1 = [4 x i8] c"\0Aa=\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"\0Ab=\00"
@.str.4 = [4 x i8] c"\0Ac=\00"
@.str.5 = [13 x i8] c"\0AR\C3\B3wnanie:\0A\00"
@.str.6 = [14 x i8] c"%fx^2+%fx+%f\0A\00"
@.str.7 = [17 x i8] c"ma %d rozwiazan\0A\00"
@.str.8 = [13 x i8] c"x1=%f x2=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store i32 0, i32* %6
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%17 = load float, float* %2
%18 = fpext float %17 to double
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %18, double %20, double %22)
%24 = load float, float* %2
%25 = load float, float* %3
%26 = load float, float* %4
%27 = call float @delta(float %24, float %25, float %26)
store float %27, float* %5
%28 = load float, float* %5
%29 = call i32 @ileRozwZdelt(float %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %6
switch i32 %32, label %53 [
i32 0, label %33
i32 2, label %34
i32 1, label %34
]
33: ; preds = %0
store i32 0, i32* %1
br label %59
34: ; preds = %0, %0
%35 = load float, float* %3
%36 = fneg float %35
%37 = load float, float* %5
%38 = call i32 @sqrt(float %37)
%39 = sitofp i32 %38 to float
%40 = fadd float %36, %39
%41 = load float, float* %2
%42 = fmul float 2.000000e+00, %41
%43 = fdiv float %40, %42
store float %43, float* %8
%44 = load float, float* %3
%45 = fneg float %44
%46 = load float, float* %5
%47 = call i32 @sqrt(float %46)
%48 = sitofp i32 %47 to float
%49 = fsub float %45, %48
%50 = load float, float* %2
%51 = fmul float 2.000000e+00, %50
%52 = fdiv float %49, %51
store float %52, float* %7
br label %53
53: ; preds = %0, %34
%54 = load float, float* %7
%55 = fpext float %54 to double
%56 = load float, float* %8
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %55, double %57)
store i32 0, i32* %1
br label %59
59: ; preds = %53, %33
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"\0Aa=\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"\0Ab=\00"
@.str.4 = [4 x i8] c"\0Ac=\00"
@.str.6 = [14 x i8] c"%fx^2+%fx+%f\0A\00"
@.str.7 = [17 x i8] c"ma %d rozwiazan\0A\00"
@.str.8 = [13 x i8] c"x1=%f x2=%f\0A\00"
@str = [34 x i8] c"Kalkulator R\C3\B3wna\C5\84 kwadratowych:\00"
@str.9 = [12 x i8] c"\0AR\C3\B3wnanie:\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%15 = load float, float* %1
%16 = fpext float %15 to double
%17 = load float, float* %2
%18 = fpext float %17 to double
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %16, double %18, double %20)
%22 = load float, float* %1
%23 = load float, float* %2
%24 = load float, float* %3
%25 = call float @delta(float %22, float %23, float %24)
%26 = call i32 @ileRozwZdelt(float %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %26)
switch i32 %26, label %48 [
i32 0, label %53
i32 2, label %28
i32 1, label %28
]
28: ; preds = %0, %0
%29 = load float, float* %2
%30 = call i32 @sqrt(float %25)
%31 = sitofp i32 %30 to float
%32 = load float, float* %1
%33 = load float, float* %2
%34 = fneg float %33
%35 = call i32 @sqrt(float %25)
%36 = sitofp i32 %35 to float
%37 = insertelement <2 x float> poison, float %34, i64 0
%38 = insertelement <2 x float> %37, float %31, i64 1
%39 = insertelement <2 x float> poison, float %36, i64 0
%40 = insertelement <2 x float> %39, float %29, i64 1
%41 = fsub <2 x float> %38, %40
%42 = load float, float* %1
%43 = insertelement <2 x float> poison, float %42, i64 0
%44 = insertelement <2 x float> %43, float %32, i64 1
%45 = fmul <2 x float> %44, <float 2.000000e+00, float 2.000000e+00>
%46 = fdiv <2 x float> %41, %45
%47 = fpext <2 x float> %46 to <2 x double>
br label %48
48: ; preds = %0, %28
%49 = phi <2 x double> [ zeroinitializer, %0 ], [ %47, %28 ]
%50 = extractelement <2 x double> %49, i64 0
%51 = extractelement <2 x double> %49, i64 1
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %50, double %51)
br label %53
53: ; preds = %0, %48
ret i32 0
}