#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*/ avg_sum(double *, int, double *, double *);
int /*<<< orphan*/ printf(char *, double, double);
int /*<<< orphan*/ system(char *);
int main() {
  int mn = 10;
  double ma[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
  double mavg, msum;
  avg_sum(ma, mn, &mavg, &msum);
  printf("mavg:%f\nmsum=%f\n", mavg, msum);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x68(%rbp),%rdx
lea    -0x70(%rbp),%rcx
call   1060 <avg_sum@plt>
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
movaps 0xf05(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
mov    $0xa,%esi
call   1050 <avg_sum@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@__const.main.ma = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@.str = [17 x i8] c"mavg:%f\0Amsum=%f\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x double]
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store i32 10, i32* %2
%6 = bitcast [10 x double]* %3 to i8*
%7 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @avg_sum(double* %7, i32 %8, double* %4, double* %5)
%10 = load double, double* %4
%11 = load double, double* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %10, double %11)
%13 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.ma = [10 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00, double 9.000000e+00, double 1.000000e+01]
@.str = [17 x i8] c"mavg:%f\0Amsum=%f\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca [10 x double]
%2 = alloca double
%3 = alloca double
%4 = bitcast [10 x double]* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = getelementptr inbounds [10 x double], [10 x double]* %1, i64 0, i64 0
%8 = call i32 @avg_sum(double* %7, i32 10, double* %2, double* %3)
%9 = load double, double* %2
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %9, double %10)
%12 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}