#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int input_numbers(char *, double *);
int /*<<< orphan*/ printf(char *, ...);
int qsolver(double, double, double, double *, double *);
int /*<<< orphan*/ read_line(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int ret;
  char input[500];
  double inputs[3];
  double x1, x2;
  printf("Please type all 3 numbers on the same line. To exit the program, "
         "type 'exit'\n");
  printf("Example:\n");
  printf("   > 2.0 5 -3.0\n");
  printf("   Roots are: x1: 0.500000 and x2: -3.000000\n\n");
  while (1) {
    printf("> ");
    read_line(input, 500);
    if (strcmp(input, "exit\n") == 0)
      exit(1);
    ret = input_numbers(input, inputs);
    if (ret == -1) {
      fprintf(
          stderr,
          "Error: a, b and c must be real numbers. Example: 2.0 5 -3.0\n\n");
      continue;
    }
    ret = qsolver(inputs[0], inputs[1], inputs[2], &x1, &x2);
    switch (ret) {
    case -2:
      printf("No real roots\n\n");
      break;
    case -1:
      printf("Not a quadratic equation (a == 0)\n\n");
      break;
    case 0:
      printf("Roots are: x1: %f and x2: %f\n\n", x1, x2);
      break;
    case 1:
      printf("Double real root: %f\n\n", x1);
      break;
    default:
      fprintf(stderr, "System failure: qsolver error code=%d", ret);
      exit(1);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x1f4,%esi
call   1070 <read_line@plt>
lea    -0x210(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1207 <main+0x97>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x210(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1080 <input_numbers@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1243 <main+0xd3>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    11c1 <main+0x51>
movsd  -0x230(%rbp),%xmm0
ff
movsd  -0x228(%rbp),%xmm1
ff
movsd  -0x220(%rbp),%xmm2
ff
lea    -0x238(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1040 <qsolver@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,%ecx
mov    %rcx,-0x248(%rbp)
sub    $0x3,%eax
ja     1304 <main+0x194>
mov    -0x248(%rbp),%rax
lea    0xd69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <main+0x1b8>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <main+0x1b8>
movsd  -0x238(%rbp),%xmm0
ff
movsd  -0x240(%rbp),%xmm1
ff
lea    0xe46(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1328 <main+0x1b8>
movsd  -0x238(%rbp),%xmm0
ff
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1328 <main+0x1b8>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11c1 <main+0x51>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf59(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1f4,%esi
call   1080 <read_line@plt>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11ff <main+0x7f>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r14
lea    0xe00(%rip),%r12
lea    0xdfc(%rip),%r13
lea    0x8(%rsp),%r15
lea    0xddd(%rip),%rbp
jmp    126e <main+0xee>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1f4,%esi
call   1080 <read_line@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11f5 <main+0x75>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <input_numbers@plt>
cmp    $0xffffffff,%eax
je     1230 <main+0xb0>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mov    %rsp,%rdi
mov    %r15,%rsi
call   1050 <qsolver@plt>
lea    0x2(%rax),%ecx
cmp    $0x3,%ecx
ja     1302 <main+0x182>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
jmp    1247 <main+0xc7>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
jmp    1247 <main+0xc7>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xd79(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1247 <main+0xc7>
movsd  (%rsp),%xmm0
lea    0xd80(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1247 <main+0xc7>
mov    0x2cd7(%rip),%rcx
mov    (%rcx),%edi
lea    0xd7b(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [78 x i8] c"Please type all 3 numbers on the same line. To exit the program, type 'exit'\0A\00"
@.str.1 = [10 x i8] c"Example:\0A\00"
@.str.2 = [17 x i8] c" > 2.0 5 -3.0\0A\00"
@.str.3 = [47 x i8] c" Roots are: x1: 0.500000 and x2: -3.000000\0A\0A\00"
@.str.4 = [3 x i8] c"> \00"
@.str.5 = [6 x i8] c"exit\0A\00"
@stderr = global i32 0
@.str.6 = [62 x i8] c"Error: a, b and c must be real numbers. Example: 2.0 5 -3.0\0A\0A\00"
@.str.7 = [16 x i8] c"No real roots\0A\0A\00"
@.str.8 = [36 x i8] c"Not a quadratic equation (a == 0)\0A\0A\00"
@.str.9 = [31 x i8] c"Roots are: x1: %f and x2: %f\0A\0A\00"
@.str.10 = [23 x i8] c"Double real root: %f\0A\0A\00"
@.str.11 = [38 x i8] c"System failure: qsolver error code=%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [500 x i8]
%8 = alloca [3 x double]
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %2, %30, %58
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%18 = call i32 @read_line(i8* %17, i32 500)
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %15
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%26 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%27 = call i32 @input_numbers(i8* %25, double* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0))
br label %15
33: ; preds = %24
%34 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%35 = load double, double* %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%37 = load double, double* %36
%38 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%39 = load double, double* %38
%40 = call i32 @qsolver(double %35, double %37, double %39, double* %9, double* %10)
store i32 %40, i32* %6
%41 = load i32, i32* %6
switch i32 %41, label %53 [
i32 -2, label %42
i32 -1, label %44
i32 0, label %46
i32 1, label %50
]
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %58
44: ; preds = %33
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %58
46: ; preds = %33
%47 = load double, double* %9
%48 = load double, double* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), double %47, double %48)
br label %58
50: ; preds = %33
%51 = load double, double* %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %51)
br label %58
53: ; preds = %33
%54 = load i32, i32* @stderr
%55 = load i32, i32* %6
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %50, %46, %44, %42
br label %15
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"> \00"
@.str.5 = [6 x i8] c"exit\0A\00"
@stderr = global i32 0
@.str.6 = [62 x i8] c"Error: a, b and c must be real numbers. Example: 2.0 5 -3.0\0A\0A\00"
@.str.9 = [31 x i8] c"Roots are: x1: %f and x2: %f\0A\0A\00"
@.str.10 = [23 x i8] c"Double real root: %f\0A\0A\00"
@.str.11 = [38 x i8] c"System failure: qsolver error code=%d\00"
@str = [77 x i8] c"Please type all 3 numbers on the same line. To exit the program, type 'exit'\00"
@str.12 = [9 x i8] c"Example:\00"
@str.13 = [16 x i8] c" > 2.0 5 -3.0\00"
@str.14 = [46 x i8] c" Roots are: x1: 0.500000 and x2: -3.000000\0A\00"
@str.15 = [35 x i8] c"Not a quadratic equation (a == 0)\0A\00"
@str.16 = [15 x i8] c"No real roots\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [500 x i8]
%4 = alloca [3 x double]
%5 = alloca double
%6 = alloca double
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%8 = bitcast [3 x double]* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.14, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @read_line(i8* %7, i32 500)
%17 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %2
%20 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%21 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%22 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
br label %25
23: ; preds = %31, %2
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %19, %31
%26 = call i32 @input_numbers(i8* %7, double* %20)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %41, %43, %45, %49, %28
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @read_line(i8* %7, i32 500)
%34 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %23, label %25
36: ; preds = %25
%37 = load double, double* %20
%38 = load double, double* %21
%39 = load double, double* %22
%40 = call i32 @qsolver(double %37, double %38, double %39, double* %5, double* %6)
switch i32 %40, label %52 [
i32 -2, label %41
i32 -1, label %43
i32 0, label %45
i32 1, label %49
]
41: ; preds = %36
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
br label %31
43: ; preds = %36
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
br label %31
45: ; preds = %36
%46 = load double, double* %5
%47 = load double, double* %6
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), double %46, double %47)
br label %31
49: ; preds = %36
%50 = load double, double* %5
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %50)
br label %31
52: ; preds = %36
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32 %40)
%55 = call i32 @exit(i32 1)
unreachable
}