#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*/ printf(char *, ...);
int rownanieKwadratowe(double, double, double, double *, double *);
int /*<<< orphan*/ scanf(char *, double *);
void kwadratowe(void) {
  double a, b, c, x1, x2;
  int n;
  printf("Równanie kwadratowe a*x^2 + b*x + c\n");
  printf("Podaj a: ");
  scanf("%lf", &a);
  printf("Podaj b: ");
  scanf("%lf", &b);
  printf("Podaj c: ");
  scanf("%lf", &c);
  n = rownanieKwadratowe(a, b, c, &x1, &x2);
  printf("\n%.2f * x^2 + %.2f * x + %.2f = ", a, b, c);
  if (n == 0) {
    printf("Brak rozwiązań\n");
  } else if (n == 1) {
    printf("%.2f\n", x1);
  } else {
    printf("%.2f i %.2f\n", x1, x2);
  }
}


x86 assembly (clang, -O0):
<kwadratowe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <rownanieKwadratowe@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe73(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    11f9 <kwadratowe+0xc9>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <kwadratowe+0x108>
cmpl   $0x1,-0x2c(%rbp)
jne    121b <kwadratowe+0xeb>
movsd  -0x20(%rbp),%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1233 <kwadratowe+0x103>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe4f(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1238 <kwadratowe+0x108>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kwadratowe>:
push   %rbx
sub    $0x30,%rsp
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea4(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0x8(%rsp),%rdi
lea    0x28(%rsp),%rsi
call   1050 <rownanieKwadratowe@plt>
mov    %eax,%ebx
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe3d(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     1203 <kwadratowe+0xc3>
test   %ebx,%ebx
jne    1219 <kwadratowe+0xd9>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
jmp    1233 <kwadratowe+0xf3>
movsd  0x8(%rsp),%xmm0
lea    0xe3a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1233 <kwadratowe+0xf3>
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
lea    0xe17(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"R\C3\B3wnanie kwadratowe a*x^2 + b*x + c\0A\00"
@.str.1 = [10 x i8] c"Podaj a: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [10 x i8] c"Podaj b: \00"
@.str.4 = [10 x i8] c"Podaj c: \00"
@.str.5 = [33 x i8] c"\0A%.2f * x^2 + %.2f * x + %.2f = \00"
@.str.6 = [18 x i8] c"Brak rozwi\C4\85za\C5\84\0A\00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [13 x i8] c"%.2f i %.2f\0A\00"
define void @kwadratowe() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%14 = load double, double* %1
%15 = load double, double* %2
%16 = load double, double* %3
%17 = call i32 @rownanieKwadratowe(double %14, double %15, double %16, double* %4, double* %5)
store i32 %17, i32* %6
%18 = load double, double* %1
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %18, double %19, double %20)
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %37
26: ; preds = %0
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %30)
br label %36
32: ; preds = %26
%33 = load double, double* %4
%34 = load double, double* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %33, double %34)
br label %36
36: ; preds = %32, %29
br label %37
37: ; preds = %36, %24
ret void
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"Podaj a: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [10 x i8] c"Podaj b: \00"
@.str.4 = [10 x i8] c"Podaj c: \00"
@.str.5 = [33 x i8] c"\0A%.2f * x^2 + %.2f * x + %.2f = \00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [13 x i8] c"%.2f i %.2f\0A\00"
@str = [37 x i8] c"R\C3\B3wnanie kwadratowe a*x^2 + b*x + c\00"
@str.9 = [17 x i8] c"Brak rozwi\C4\85za\C5\84\00"
define void @kwadratowe() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%18 = load double, double* %1
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call i32 @rownanieKwadratowe(double %18, double %19, double %20, double* %4, double* %5)
%22 = load double, double* %1
%23 = load double, double* %2
%24 = load double, double* %3
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %22, double %23, double %24)
switch i32 %21, label %31 [
i32 0, label %26
i32 1, label %28
]
26: ; preds = %0
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %35
28: ; preds = %0
%29 = load double, double* %4
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %29)
br label %35
31: ; preds = %0
%32 = load double, double* %4
%33 = load double, double* %5
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %32, double %33)
br label %35
35: ; preds = %28, %31, %26
ret void
}