#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 /*<<< orphan*/ scanf(char *, int *, int *, int *);
int sqrt(int);
int main(void) {
  int a;
  int b;
  int c;
  int delta;
  double x1;
  double x2;
  printf("请输入a b c:");
  scanf("%d%d%d", &a, &b, &c);
  delta = b * b - 4 * a * c;
  if (a == 0) {
    printf("无效的表达式!\n");
    return 1;
  }
  if (delta < 0) {
    printf("无解!\n");
  } else if (delta == 0) {
    x1 = x2 = -b / (2 * a);
    printf("唯一解:%lf\n", x1);
  } else {
    x1 = (-b + sqrt(delta)) / (2 * a);
    x2 = (-b - sqrt(delta)) / (2 * a);
    printf("x1=%lf, x2=%lf\n", x1, x2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    119f <main+0x6f>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1270 <main+0x140>
cmpl   $0x0,-0x14(%rbp)
jge    11bc <main+0x8c>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1269 <main+0x139>
cmpl   $0x0,-0x14(%rbp)
jne    11fa <main+0xca>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1264 <main+0x134>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xde7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1269 <main+0x139>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
je     11e0 <main+0xa0>
mov    0x8(%rsp),%ebp
mov    %ebp,%ebx
imul   %ebp,%ebx
mov    0xc(%rsp),%eax
imul   %ecx,%eax
shl    $0x2,%eax
sub    %eax,%ebx
test   %ebx,%ebx
js     11f3 <main+0xb3>
je     1201 <main+0xc1>
mov    %ebx,%edi
call   1060 <sqrt@plt>
sub    %ebp,%eax
mov    0x4(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x8(%rsp),%ebp
mov    %ebx,%edi
call   1060 <sqrt@plt>
add    %ebp,%eax
neg    %eax
mov    0x4(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
lea    0xe55(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
jmp    121c <main+0xdc>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    121e <main+0xde>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
jmp    121c <main+0xdc>
add    %ecx,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
neg    %eax
cvtsi2sd %eax,%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5a b c:\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [21 x i8] c"\E6\97\A0\E6\95\88\E7\9A\84\E8\A1\A8\E8\BE\BE\E5\BC\8F!\0A\00"
@.str.3 = [9 x i8] c"\E6\97\A0\E8\A7\A3!\0A\00"
@.str.4 = [15 x i8] c"\E5\94\AF\E4\B8\80\E8\A7\A3:%lf\0A\00"
@.str.5 = [16 x i8] c"x1=%lf, x2=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %2
%14 = mul nsw i32 4, %13
%15 = load i32, i32* %4
%16 = mul nsw i32 %14, %15
%17 = sub nsw i32 %12, %16
store i32 %17, i32* %5
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %63
22: ; preds = %0
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %62
27: ; preds = %22
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = load i32, i32* %3
%32 = sub nsw i32 0, %31
%33 = load i32, i32* %2
%34 = mul nsw i32 2, %33
%35 = sdiv i32 %32, %34
%36 = sitofp i32 %35 to double
store double %36, double* %7
store double %36, double* %6
%37 = load double, double* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %37)
br label %61
39: ; preds = %27
%40 = load i32, i32* %3
%41 = sub nsw i32 0, %40
%42 = load i32, i32* %5
%43 = call i32 @sqrt(i32 %42)
%44 = add nsw i32 %41, %43
%45 = load i32, i32* %2
%46 = mul nsw i32 2, %45
%47 = sdiv i32 %44, %46
%48 = sitofp i32 %47 to double
store double %48, double* %6
%49 = load i32, i32* %3
%50 = sub nsw i32 0, %49
%51 = load i32, i32* %5
%52 = call i32 @sqrt(i32 %51)
%53 = sub nsw i32 %50, %52
%54 = load i32, i32* %2
%55 = mul nsw i32 2, %54
%56 = sdiv i32 %53, %55
%57 = sitofp i32 %56 to double
store double %57, double* %7
%58 = load double, double* %6
%59 = load double, double* %7
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %58, double %59)
br label %61
61: ; preds = %39, %30
br label %62
62: ; preds = %61, %25
store i32 0, i32* %1
br label %63
63: ; preds = %62, %20
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [16 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5a b c:\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.4 = [15 x i8] c"\E5\94\AF\E4\B8\80\E8\A7\A3:%lf\0A\00"
@.str.5 = [16 x i8] c"x1=%lf, x2=%lf\0A\00"
@str = [8 x i8] c"\E6\97\A0\E8\A7\A3!\00"
@str.6 = [20 x i8] c"\E6\97\A0\E6\95\88\E7\9A\84\E8\A1\A8\E8\BE\BE\E5\BC\8F!\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, %9
%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 = icmp eq i32 %11, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
br label %47
19: ; preds = %0
%20 = icmp slt i32 %15, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %47
23: ; preds = %19
%24 = icmp eq i32 %15, 0
br i1 %24, label %25, label %31
25: ; preds = %23
%26 = shl nsw i32 %11, 1
%27 = sdiv i32 %9, %26
%28 = sub nsw i32 0, %27
%29 = sitofp i32 %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %29)
br label %47
31: ; preds = %23
%32 = call i32 @sqrt(i32 %15)
%33 = sub i32 %32, %9
%34 = load i32, i32* %1
%35 = shl nsw i32 %34, 1
%36 = sdiv i32 %33, %35
%37 = sitofp i32 %36 to double
%38 = load i32, i32* %2
%39 = call i32 @sqrt(i32 %15)
%40 = add i32 %38, %39
%41 = sub i32 0, %40
%42 = load i32, i32* %1
%43 = shl nsw i32 %42, 1
%44 = sdiv i32 %41, %43
%45 = sitofp i32 %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %37, double %45)
br label %47
47: ; preds = %21, %31, %25, %17
%48 = phi i32 [ 1, %17 ], [ 0, %25 ], [ 0, %31 ], [ 0, %21 ]
ret i32 %48
}