#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*/ avevar(float *, int, float *, float *);
int /*<<< orphan*/ free_vector(float *, int, int);
int gasdev(long *);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int main(void) {
  int i, j;
  long idum = (-5);
  float ave, shift, vrnce, *data;
  data = vector(1, 1000);
  printf("\n%9s %11s %12s\n", "shift", "average", "variance");
  for (i = 1; i <= 11; i++) {
    shift = (i - 1) * 0.1;
    for (j = 1; j <= 1000; j++)
      data[j] = shift + i * gasdev(&idum);
    avevar(data, 1000, &ave, &vrnce);
    printf("%8.2f %11.2f %12.2f\n", shift, ave, vrnce);
  }
  free_vector(data, 1, 1000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xfffffffffffffffb,-0x18(%rbp)
ff
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1060 <vector@plt>
mov    %rax,-0x30(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe90(%rip),%rsi
lea    0xe8f(%rip),%rdx
lea    0xe90(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xb,-0x8(%rbp)
jg     1277 <main+0x127>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe40(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jg     122a <main+0xda>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <gasdev@plt>
movss  -0x38(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <main+0x84>
mov    -0x30(%rbp),%rdi
mov    $0x3e8,%esi
lea    -0x1c(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1030 <avevar@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x24(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdcd(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a4 <main+0x54>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0xfffffffffffffffb,0x10(%rsp)
ff ff
mov    $0x1,%ebp
mov    $0x1,%edi
mov    $0x3e8,%esi
call   1060 <vector@plt>
mov    %rax,%rbx
lea    0xe83(%rip),%rdi
lea    0xe8c(%rip),%rsi
lea    0xe8b(%rip),%rdx
lea    0xe8c(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r12
lea    0xe7d(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe2e(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1070 <gasdev@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx,%r15,4)
add    $0x1,%r15
cmp    $0x3e9,%r15
jne    11f0 <main+0xa0>
mov    %rbx,%rdi
mov    $0x3e8,%esi
lea    0xc(%rsp),%rdx
mov    %r12,%rcx
call   1030 <avevar@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x8(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r13,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0xc,%ebp
jne    11c0 <main+0x70>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3e8,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0A%9s %11s %12s\0A\00"
@.str.1 = [6 x i8] c"shift\00"
@.str.2 = [8 x i8] c"average\00"
@.str.3 = [9 x i8] c"variance\00"
@.str.4 = [21 x i8] c"%8.2f %11.2f %12.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float*
store i32 0, i32* %1
store i64 -5, i64* %4
%9 = call float* @vector(i32 1, i32 1000)
store float* %9, float** %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %11
11: ; preds = %47, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 11
br i1 %13, label %14, label %50
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 1.000000e-01
%19 = fptrunc double %18 to float
store float %19, float* %6
store i32 1, i32* %3
br label %20
20: ; preds = %34, %14
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 1000
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = load float, float* %6
%25 = load i32, i32* %2
%26 = call i32 @gasdev(i64* %4)
%27 = mul nsw i32 %25, %26
%28 = sitofp i32 %27 to float
%29 = fadd float %24, %28
%30 = load float*, float** %8
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
store float %29, float* %33
br label %34
34: ; preds = %23
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %20
37: ; preds = %20
%38 = load float*, float** %8
%39 = call i32 @avevar(float* %38, i32 1000, float* %5, float* %7)
%40 = load float, float* %6
%41 = fpext float %40 to double
%42 = load float, float* %5
%43 = fpext float %42 to double
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %41, double %43, double %45)
br label %47
47: ; preds = %37
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %11
50: ; preds = %11
%51 = load float*, float** %8
%52 = call i32 @free_vector(float* %51, i32 1, i32 1000)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0A%9s %11s %12s\0A\00"
@.str.1 = [6 x i8] c"shift\00"
@.str.2 = [8 x i8] c"average\00"
@.str.3 = [9 x i8] c"variance\00"
@.str.4 = [21 x i8] c"%8.2f %11.2f %12.2f\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca float
%3 = alloca float
%4 = bitcast i64* %1 to i8*
store i64 -5, i64* %1
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call float* @vector(i32 1, i32 1000)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %0, %24
%10 = phi i32 [ 1, %0 ], [ %32, %24 ]
%11 = add nsw i32 %10, -1
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 1.000000e-01
%14 = fptrunc double %13 to float
br label %15
15: ; preds = %9, %15
%16 = phi i64 [ 1, %9 ], [ %22, %15 ]
%17 = call i32 @gasdev(i64* %1)
%18 = mul nsw i32 %17, %10
%19 = sitofp i32 %18 to float
%20 = fadd float %14, %19
%21 = getelementptr inbounds float, float* %7, i64 %16
store float %20, float* %21
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, 1001
br i1 %23, label %24, label %15
24: ; preds = %15
%25 = call i32 @avevar(float* %7, i32 1000, float* %2, float* %3)
%26 = fpext float %14 to double
%27 = load float, float* %2
%28 = fpext float %27 to double
%29 = load float, float* %3
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %26, double %28, double %30)
%32 = add nuw nsw i32 %10, 1
%33 = icmp eq i32 %32, 12
br i1 %33, label %34, label %9
34: ; preds = %24
%35 = call i32 @free_vector(float* %7, i32 1, i32 1000)
ret i32 0
}