#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, char *, float *);
main() {
  char cat;
  cat = 'y';
  while (cat == 'y') {
    {
      float a, b, c, d, e;
      d = 0;
      e = 0;
      char dog;
      printf("请输入算式。\n");
      scanf("%f%c%f", &a, &dog, &b);
      {
        switch (dog) {
        case '+': {
          c = a + b;
          d++;
        } break;
        case '-': {
          c = a - b;
          d++;
        } break;
        case '*': {
          c = a * b;
          d++;
        } break;
        case '/': {
          d++;
          if (b == 0) {
            e = 1;
          } else
            c = a / b;
        } break;
        }
      }
      if (d == 0)
        printf("逻辑错误，CPU即将自毁！\n");
      else {
        if (e == 1)
          printf("%f%c%f=∞\n", a, dog, b);
        else
          printf("%f%c%f=%f\n", a, dog, b, c);
      }
    }
    {
      getchar();
      printf("是否要继续计算？（y/n）\n");
      cat = getchar();
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x79,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
jne    1334 <main+0x204>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x1d(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
movsbl -0x1d(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     126f <main+0x13f>
mov    -0x28(%rbp),%rax
lea    0xe5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe3b(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    126f <main+0x13f>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe15(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    126f <main+0x13f>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xdef(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    126f <main+0x13f>
movss  0xdd8(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    125b <main+0x12b>
jp     125b <main+0x12b>
movss  0xdaf(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    126a <main+0x13a>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126f <main+0x13f>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1299 <main+0x169>
jp     1299 <main+0x169>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
movss  -0x1c(%rbp),%xmm0
movss  0xd5a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    12de <main+0x1ae>
jp     12de <main+0x1ae>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x1d(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd88(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    130b <main+0x1db>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x1d(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd62(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1e0>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    1143 <main+0x13>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec7(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xf(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xee2(%rip),%rbp
lea    0xe92(%rip),%r14
jmp    11cb <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm2
addss  %xmm1,%xmm2
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xe89(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x79,%al
jne    12a3 <main+0x163>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1060 <scanf@plt>
movsbl 0xf(%rsp),%esi
lea    -0x2a(%rsi),%eax
cmp    $0x5,%eax
ja     1220 <main+0xe0>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm2
mulss  %xmm1,%xmm2
jmp    1193 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
jmp    11ad <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
jmp    1193 <main+0x53>
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp),%xmm1
ucomiss 0xd93(%rip),%xmm1
movss  0x14(%rsp),%xmm0
jne    1297 <main+0x157>
jp     1297 <main+0x157>
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xd9d(%rip),%rdi
mov    $0x2f,%esi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    11ad <main+0x6d>
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
jmp    1193 <main+0x53>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AE\97\E5\BC\8F\E3\80\82\0A\00"
@.str.1 = [7 x i8] c"%f%c%f\00"
@.str.2 = [35 x i8] c"\E9\80\BB\E8\BE\91\E9\94\99\E8\AF\AF\EF\BC\8CCPU\E5\8D\B3\E5\B0\86\E8\87\AA\E6\AF\81\EF\BC\81\0A\00"
@.str.3 = [12 x i8] c"%f%c%f=\E2\88\9E\0A\00"
@.str.4 = [11 x i8] c"%f%c%f=%f\0A\00"
@.str.5 = [35 x i8] c"\E6\98\AF\E5\90\A6\E8\A6\81\E7\BB\A7\E7\BB\AD\E8\AE\A1\E7\AE\97\EF\BC\9F\EF\BC\88y/n\EF\BC\89\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i8
store i32 0, i32* %1
store i8 121, i8* %2
br label %9
9: ; preds = %74, %0
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 121
br i1 %12, label %13, label %78
13: ; preds = %9
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %3, i8* %8, float* %4)
%16 = load i8, i8* %8
%17 = sext i8 %16 to i32
switch i32 %17, label %47 [
i32 43, label %18
i32 45, label %24
i32 42, label %30
i32 47, label %36
]
18: ; preds = %13
%19 = load float, float* %3
%20 = load float, float* %4
%21 = fadd float %19, %20
store float %21, float* %5
%22 = load float, float* %6
%23 = fadd float %22, 1.000000e+00
store float %23, float* %6
br label %47
24: ; preds = %13
%25 = load float, float* %3
%26 = load float, float* %4
%27 = fsub float %25, %26
store float %27, float* %5
%28 = load float, float* %6
%29 = fadd float %28, 1.000000e+00
store float %29, float* %6
br label %47
30: ; preds = %13
%31 = load float, float* %3
%32 = load float, float* %4
%33 = fmul float %31, %32
store float %33, float* %5
%34 = load float, float* %6
%35 = fadd float %34, 1.000000e+00
store float %35, float* %6
br label %47
36: ; preds = %13
%37 = load float, float* %6
%38 = fadd float %37, 1.000000e+00
store float %38, float* %6
%39 = load float, float* %4
%40 = fcmp oeq float %39, 0.000000e+00
br i1 %40, label %41, label %42
41: ; preds = %36
store float 1.000000e+00, float* %7
br label %46
42: ; preds = %36
%43 = load float, float* %3
%44 = load float, float* %4
%45 = fdiv float %43, %44
store float %45, float* %5
br label %46
46: ; preds = %42, %41
br label %47
47: ; preds = %13, %46, %30, %24, %18
%48 = load float, float* %6
%49 = fcmp oeq float %48, 0.000000e+00
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %74
52: ; preds = %47
%53 = load float, float* %7
%54 = fcmp oeq float %53, 1.000000e+00
br i1 %54, label %55, label %63
55: ; preds = %52
%56 = load float, float* %3
%57 = fpext float %56 to double
%58 = load i8, i8* %8
%59 = sext i8 %58 to i32
%60 = load float, float* %4
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %57, i32 %59, double %61)
br label %73
63: ; preds = %52
%64 = load float, float* %3
%65 = fpext float %64 to double
%66 = load i8, i8* %8
%67 = sext i8 %66 to i32
%68 = load float, float* %4
%69 = fpext float %68 to double
%70 = load float, float* %5
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %65, i32 %67, double %69, double %71)
br label %73
73: ; preds = %63, %55
br label %74
74: ; preds = %73, %50
%75 = call signext i8 (...) @getchar()
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%77 = call signext i8 (...) @getchar()
store i8 %77, i8* %2
br label %9
78: ; preds = %9
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%f%c%f\00"
@.str.3 = [12 x i8] c"%f%c%f=\E2\88\9E\0A\00"
@.str.4 = [11 x i8] c"%f%c%f=%f\0A\00"
@str = [19 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AE\97\E5\BC\8F\E3\80\82\00"
@str.6 = [34 x i8] c"\E6\98\AF\E5\90\A6\E8\A6\81\E7\BB\A7\E7\BB\AD\E8\AE\A1\E7\AE\97\EF\BC\9F\EF\BC\88y/n\EF\BC\89\00"
@str.7 = [34 x i8] c"\E9\80\BB\E8\BE\91\E9\94\99\E8\AF\AF\EF\BC\8CCPU\E5\8D\B3\E5\B0\86\E8\87\AA\E6\AF\81\EF\BC\81\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
br label %6
6: ; preds = %0, %43
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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), float* %1, i8* %3, float* %2)
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
switch i32 %10, label %29 [
i32 43, label %11
i32 45, label %15
i32 42, label %19
i32 47, label %23
]
11: ; preds = %6
%12 = load float, float* %1
%13 = load float, float* %2
%14 = fadd float %12, %13
br label %35
15: ; preds = %6
%16 = load float, float* %1
%17 = load float, float* %2
%18 = fsub float %16, %17
br label %35
19: ; preds = %6
%20 = load float, float* %1
%21 = load float, float* %2
%22 = fmul float %20, %21
br label %35
23: ; preds = %6
%24 = load float, float* %2
%25 = fcmp oeq float %24, 0.000000e+00
%26 = load float, float* %1
br i1 %25, label %31, label %27
27: ; preds = %23
%28 = fdiv float %26, %24
br label %35
29: ; preds = %6
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.7, i64 0, i64 0))
br label %43
31: ; preds = %23
%32 = fpext float %26 to double
%33 = fpext float %24 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %32, i32 47, double %33)
br label %43
35: ; preds = %11, %15, %19, %27
%36 = phi float [ %24, %27 ], [ %21, %19 ], [ %17, %15 ], [ %13, %11 ]
%37 = phi float [ %26, %27 ], [ %20, %19 ], [ %16, %15 ], [ %12, %11 ]
%38 = phi float [ %28, %27 ], [ %22, %19 ], [ %18, %15 ], [ %14, %11 ]
%39 = fpext float %37 to double
%40 = fpext float %36 to double
%41 = fpext float %38 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %39, i32 %10, double %40, double %41)
br label %43
43: ; preds = %31, %35, %29
%44 = call signext i8 (...) @getchar()
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.6, i64 0, i64 0))
%46 = call signext i8 (...) @getchar()
%47 = icmp eq i8 %46, 121
br i1 %47, label %6, label %48
48: ; preds = %43
ret i32 0
}