#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 main() {
  int x = 0;
  double num = 0;
  int count = 0;
  double per;
  printf("请输入一些数:");
  scanf("%d", &x);
  while (x != 0) {
    num += x;
    count++;
    scanf("%d", &x);
  }
  if (count > 0) {
    per = num / count;
    printf("%f \n", per);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     119a <main+0x7a>
cvtsi2sdl -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe88(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1163 <main+0x43>
cmpl   $0x0,-0x14(%rbp)
jle    11ca <main+0xaa>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
lea    0xec9(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11b6 <main+0x96>
xorpd  %xmm0,%xmm0
lea    0xeb0(%rip),%r14
lea    0x4(%rsp),%rbx
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    1170 <main+0x50>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\BA\9B\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sitofp i32 %12 to double
%14 = load double, double* %3
%15 = fadd double %14, %13
store double %15, double* %3
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
19: ; preds = %8
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load double, double* %3
%24 = load i32, i32* %4
%25 = sitofp i32 %24 to double
%26 = fdiv double %23, %25
store double %26, double* %5
%27 = load double, double* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %27)
br label %29
29: ; preds = %22, %19
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\BA\9B\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %15, %7 ], [ %5, %0 ]
%9 = phi double [ %12, %7 ], [ 0.000000e+00, %0 ]
%10 = phi i32 [ %13, %7 ], [ 0, %0 ]
%11 = sitofp i32 %8 to double
%12 = fadd double %9, %11
%13 = add nuw nsw i32 %10, 1
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = sitofp i32 %13 to double
%19 = fdiv double %12, %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %19)
br label %21
21: ; preds = %0, %17
ret i32 0
}