#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  FILE *fp = NULL;
  int ninzu = 0;
  char name[100] = {0};
  double height = 0.0, weight = 0.0;
  double hsum = 0.0;
  double wsum = 0.0;
  if ((fp = fopen("hw.dat", "r")) == NULL) {
    printf("\a文件打开失败\n");
  } else {
    while (fscanf(fp, "%s%lf%lf", name, &height, &weight) == 3) {
      printf("%-10s %5.1f %5.1f\n", name, height, weight);
      ninzu++;
      hsum += height;
      wsum += weight;
    }
    printf("----------------------\n");
    printf("平均       %5.1f %5.1f\n", hsum / ninzu, wsum / ninzu);
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
lea    0xe4c(%rip),%rdi
lea    0xe4c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11e1 <main+0x91>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b8 <main+0x168>
jmp    11e6 <main+0x96>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe29(%rip),%rsi
lea    -0x88(%rbp),%rcx
lea    -0x90(%rbp),%r8
call   1060 <fscanf@plt>
cmp    $0x3,%eax
jne    1271 <main+0x121>
lea    -0x80(%rbp),%rsi
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm1
ff
lea    0xdfb(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
addsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
addsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    11e6 <main+0x96>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x98(%rbp),%xmm0
ff
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  -0xa0(%rbp),%xmm1
ff
cvtsi2sdl -0x14(%rbp),%xmm2
divsd  %xmm2,%xmm1
lea    0xdaa(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x80(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movl   $0x0,0x90(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xe50(%rip),%rdi
lea    0xe50(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12ea <main+0x19a>
mov    %rax,%r15
lea    0xe3a(%rip),%rsi
lea    0x30(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %rax,%rdi
call   1060 <fscanf@plt>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
cmp    $0x3,%eax
jne    12a6 <main+0x156>
xor    %r14d,%r14d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x30(%rsp),%rbx
lea    0xde9(%rip),%r12
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%rbp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xdbf(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x1,%r14d
movsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1060 <fscanf@plt>
cmp    $0x3,%eax
je     1240 <main+0xf0>
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
movsd  %xmm1,0x28(%rsp)
lea    0xd8c(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm2
divsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm2,%xmm1
lea    0xd4c(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    12f6 <main+0x1a6>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"hw.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"\07\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E5\A4\B1\E8\B4\A5\0A\00"
@.str.3 = [9 x i8] c"%s%lf%lf\00"
@.str.4 = [19 x i8] c"%-10s %5.1f %5.1f\0A\00"
@.str.5 = [24 x i8] c"----------------------\0A\00"
@.str.6 = [26 x i8] c"\E5\B9\B3\E5\9D\87 %5.1f %5.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
store i32* null, i32** %2
store i32 0, i32* %3
%9 = bitcast [100 x i8]* %4 to i8*
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %46
14: ; preds = %0
br label %15
15: ; preds = %20, %14
%16 = load i32*, i32** %2
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %17, double* %5, double* %6)
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %33
20: ; preds = %15
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%22 = load double, double* %5
%23 = load double, double* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %21, double %22, double %23)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = load double, double* %5
%28 = load double, double* %7
%29 = fadd double %28, %27
store double %29, double* %7
%30 = load double, double* %6
%31 = load double, double* %8
%32 = fadd double %31, %30
store double %32, double* %8
br label %15
33: ; preds = %15
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%35 = load double, double* %7
%36 = load i32, i32* %3
%37 = sitofp i32 %36 to double
%38 = fdiv double %35, %37
%39 = load double, double* %8
%40 = load i32, i32* %3
%41 = sitofp i32 %40 to double
%42 = fdiv double %39, %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %38, double %42)
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
br label %46
46: ; preds = %33, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"hw.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [9 x i8] c"%s%lf%lf\00"
@.str.4 = [19 x i8] c"%-10s %5.1f %5.1f\0A\00"
@.str.6 = [26 x i8] c"\E5\B9\B3\E5\9D\87 %5.1f %5.1f\0A\00"
@str = [23 x i8] c"----------------------\00"
@str.7 = [20 x i8] c"\07\E6\96\87\E4\BB\B6\E6\89\93\E5\BC\80\E5\A4\B1\E8\B4\A5\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca double
%3 = alloca double
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4, double* %2, double* %3)
%11 = icmp eq i32 %10, 3
br i1 %11, label %14, label %30
12: ; preds = %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
br label %39
14: ; preds = %9, %14
%15 = phi double [ %25, %14 ], [ 0.000000e+00, %9 ]
%16 = phi double [ %23, %14 ], [ 0.000000e+00, %9 ]
%17 = phi i32 [ %21, %14 ], [ 0, %9 ]
%18 = load double, double* %2
%19 = load double, double* %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %4, double %18, double %19)
%21 = add nuw nsw i32 %17, 1
%22 = load double, double* %2
%23 = fadd double %16, %22
%24 = load double, double* %3
%25 = fadd double %15, %24
%26 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4, double* %2, double* %3)
%27 = icmp eq i32 %26, 3
br i1 %27, label %14, label %28
28: ; preds = %14
%29 = sitofp i32 %21 to double
br label %30
30: ; preds = %28, %9
%31 = phi double [ 0.000000e+00, %9 ], [ %29, %28 ]
%32 = phi double [ 0.000000e+00, %9 ], [ %23, %28 ]
%33 = phi double [ 0.000000e+00, %9 ], [ %25, %28 ]
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%35 = fdiv double %32, %31
%36 = fdiv double %33, %31
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %35, double %36)
%38 = call i32 @fclose(i32* %7)
br label %39
39: ; preds = %30, %12
ret i32 0
}