#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(void) {
  int i = 0;
  int sum = 0;
  int num, tmp;
  printf("输入多少个整数");
  scanf("%d", &num);
  while (i < num) {
    printf("NO . %d:", ++i);
    scanf("%d", &tmp);
    sum += tmp;
  }
  printf("合计值 %d \n ", sum);
  printf(" 平均值 %.2f \n", (double)sum / num);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119c <main+0x7c>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
mov    -0xc(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe70(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1194 <main+0x74>
lea    0xebe(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
add    0xc(%rsp),%ebx
cmp    0x8(%rsp),%ebp
jl     1170 <main+0x50>
lea    0xe87(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cvtsi2sd %ebx,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\E8\BE\93\E5\85\A5\E5\A4\9A\E5\B0\91\E4\B8\AA\E6\95\B4\E6\95\B0\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"NO . %d:\00"
@.str.3 = [16 x i8] c"\E5\90\88\E8\AE\A1\E5\80\BC %d \0A \00"
@.str.4 = [18 x i8] c" \E5\B9\B3\E5\9D\87\E5\80\BC %.2f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %4)
br label %8
8: ; preds = %12, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = add nsw i32 %18, %17
store i32 %19, i32* %3
br label %8
20: ; preds = %8
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to double
%27 = fdiv double %24, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"\E8\BE\93\E5\85\A5\E5\A4\9A\E5\B0\91\E4\B8\AA\E6\95\B4\E6\95\B0\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"NO . %d:\00"
@.str.3 = [16 x i8] c"\E5\90\88\E8\AE\A1\E5\80\BC %d \0A \00"
@.str.4 = [18 x i8] c" \E5\B9\B3\E5\9D\87\E5\80\BC %.2f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0, %9
%10 = phi i32 [ %16, %9 ], [ 0, %0 ]
%11 = phi i32 [ %12, %9 ], [ 0, %0 ]
%12 = add nuw nsw i32 %11, 1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = add nsw i32 %15, %10
%17 = load i32, i32* %1
%18 = icmp slt i32 %12, %17
br i1 %18, label %9, label %19
19: ; preds = %9, %0
%20 = phi i32 [ 0, %0 ], [ %16, %9 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = sitofp i32 %20 to double
%23 = load i32, i32* %1
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %25)
ret i32 0
}