#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(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int sqrt(float);
main() {
  float x1;
  float x2;
  int a, b, c;
  float shoresh;
  printf("please enter values for a,b,c\n");
  scanf("%d %d %d", &a, &b, &c);
  shoresh = pow(b, 2) - 4 * a * c;
  if (shoresh < 0) {
    printf("Oops! These numbers give a negative root. Please try again\n");
  } else {
    x1 = (-b + sqrt(shoresh)) / (2 * a);
    x2 = (-b - sqrt(shoresh)) / (2 * a);
    printf("The quadratic equation is:  %dx^2 +%dx +%d = 0\n", a, b, c);
    printf("The solutions are: \n x1= %.2f\n x2=%.2f\n", x1, x2);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x18(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    11b7 <main+0x77>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x104>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe57(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    0x14(%rsp),%ecx
imul   0x18(%rsp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
js     122d <main+0xdd>
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%ebx
call   1070 <sqrt@plt>
sub    %ebx,%eax
mov    0x14(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x1c(%rsp)
mov    0xc(%rsp),%ebx
movss  0x10(%rsp),%xmm0
call   1070 <sqrt@plt>
add    %ebx,%eax
neg    %eax
mov    0x14(%rsp),%esi
lea    (%rsi,%rsi,1),%ecx
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe15(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1239 <main+0xe9>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"please enter values for a,b,c\0A\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [60 x i8] c"Oops! These numbers give a negative root. Please try again\0A\00"
@.str.3 = [48 x i8] c"The quadratic equation is: %dx^2 +%dx +%d = 0\0A\00"
@.str.4 = [40 x i8] c"The solutions are: \0A x1= %.2f\0A x2=%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%10 = load i32, i32* %5
%11 = call i32 @pow(i32 %10, i32 2)
%12 = load i32, i32* %4
%13 = mul nsw i32 4, %12
%14 = load i32, i32* %6
%15 = mul nsw i32 %13, %14
%16 = sub nsw i32 %11, %15
%17 = sitofp i32 %16 to float
store float %17, float* %7
%18 = load float, float* %7
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %50
22: ; preds = %0
%23 = load i32, i32* %5
%24 = sub nsw i32 0, %23
%25 = load float, float* %7
%26 = call i32 @sqrt(float %25)
%27 = add nsw i32 %24, %26
%28 = load i32, i32* %4
%29 = mul nsw i32 2, %28
%30 = sdiv i32 %27, %29
%31 = sitofp i32 %30 to float
store float %31, float* %2
%32 = load i32, i32* %5
%33 = sub nsw i32 0, %32
%34 = load float, float* %7
%35 = call i32 @sqrt(float %34)
%36 = sub nsw i32 %33, %35
%37 = load i32, i32* %4
%38 = mul nsw i32 2, %37
%39 = sdiv i32 %36, %38
%40 = sitofp i32 %39 to float
store float %40, float* %3
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
%45 = load float, float* %2
%46 = fpext float %45 to double
%47 = load float, float* %3
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), double %46, double %48)
br label %50
50: ; preds = %22, %20
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.3 = [48 x i8] c"The quadratic equation is: %dx^2 +%dx +%d = 0\0A\00"
@.str.4 = [40 x i8] c"The solutions are: \0A x1= %.2f\0A x2=%.2f\0A\00"
@str = [30 x i8] c"please enter values for a,b,c\00"
@str.5 = [59 x i8] c"Oops! These numbers give a negative root. Please try again\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = call i32 @pow(i32 %9, i32 2)
%11 = load i32, i32* %1
%12 = mul i32 %11, -4
%13 = load i32, i32* %3
%14 = mul i32 %12, %13
%15 = add i32 %14, %10
%16 = sitofp i32 %15 to float
%17 = icmp slt i32 %15, 0
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.5, i64 0, i64 0))
br label %42
20: ; preds = %0
%21 = load i32, i32* %2
%22 = call i32 @sqrt(float %16)
%23 = sub i32 %22, %21
%24 = load i32, i32* %1
%25 = shl nsw i32 %24, 1
%26 = sdiv i32 %23, %25
%27 = sitofp i32 %26 to float
%28 = load i32, i32* %2
%29 = call i32 @sqrt(float %16)
%30 = add i32 %28, %29
%31 = sub i32 0, %30
%32 = load i32, i32* %1
%33 = shl nsw i32 %32, 1
%34 = sdiv i32 %31, %33
%35 = sitofp i32 %34 to float
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %36, i32 %37)
%39 = fpext float %27 to double
%40 = fpext float %35 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), double %39, double %40)
br label %42
42: ; preds = %20, %18
ret i32 0
}