#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 *, double);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int i;
  int tensu[5];
  int sum = 0;
  puts("请输入学生的分数");
  for (i = 0; i < 5; i++) {
    printf("%2d号:", i + 1);
    scanf("%d", &tensu[i]);
    sum += tensu[i];
  }
  printf("总分 %5d\n", sum);
  printf("平均分 %5.1f\n", (double)sum / 5);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11b0 <main+0x80>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9a(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x29>
cvtsi2sdl -0x24(%rbp),%xmm0
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xef6(%rip),%r14
movsd  0xead(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0xee7(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%ebp
movsd  0xe90(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
add    0x4(%rsp),%ebp
movsd  0xe77(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
add    0x8(%rsp),%ebp
movsd  0xe5e(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
add    0xc(%rsp),%ebp
movsd  0xe45(%rip),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
add    0x10(%rsp),%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
divsd  0xe05(%rip),%xmm0
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\A6\E7\94\9F\E7\9A\84\E5\88\86\E6\95\B0\00"
@.str.1 = [8 x i8] c"%2d\E5\8F\B7:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"\E6\80\BB\E5\88\86 %5d\0A\00"
@.str.4 = [17 x i8] c"\E5\B9\B3\E5\9D\87\E5\88\86 %5.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, %21
store i32 %23, i32* %4
br label %24
24: ; preds = %9
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %6
27: ; preds = %6
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to double
%33 = fdiv double %32, 5.000000e+00
%34 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\AD\A6\E7\94\9F\E7\9A\84\E5\88\86\E6\95\B0\00"
@.str.1 = [8 x i8] c"%2d\E5\8F\B7:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"\E6\80\BB\E5\88\86 %5d\0A\00"
@.str.4 = [17 x i8] c"\E5\B9\B3\E5\9D\87\E5\88\86 %5.1f\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+00)
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%7 = load i32, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+00)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%11 = load i32, i32* %9
%12 = add nsw i32 %11, %7
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+00)
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %14
%17 = add nsw i32 %16, %12
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+00)
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %19
%22 = add nsw i32 %21, %17
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double 5.000000e+00)
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = load i32, i32* %24
%27 = add nsw i32 %26, %22
%28 = sitofp i32 %27 to double
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %28)
%30 = fdiv double %28, 5.000000e+00
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %30)
ret i32 0
}