#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*/ die(char *);
void stat(double *smallest, double *average, double *largest,
          const double *begin, const double *end) {
  unsigned elements = end - begin;
  if (begin == end)
    die("Zero elements defined. stat() needs at least one element to examine.");
  *smallest = *begin;
  *largest = *begin;
  while (begin < end) {
    if (*smallest >= *begin)
      *smallest = *begin;
    *average += *begin;
    if (*largest <= *begin)
      *largest = *begin;
    ++begin;
  }
  *average = *average / elements;
}


x86 assembly (clang, -O0):
<stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    1158 <stat+0x48>
lea    0xead(%rip),%rdi
call   1030 <die@plt>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11fb <stat+0xeb>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jb     11ac <stat+0x9c>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     11ea <stat+0xda>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1178 <stat+0x68>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x2c(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stat>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r13
cmp    %r8,%rcx
jne    1139 <stat+0x29>
lea    0xecc(%rip),%rdi
call   1030 <die@plt>
movsd  (%r15),%xmm0
movsd  %xmm0,0x0(%r13)
movsd  (%r15),%xmm0
movsd  %xmm0,(%r12)
cmp    %r14,%r15
jae    119f <stat+0x8f>
mov    %r15,%rax
jmp    1169 <stat+0x59>
nopl   0x0(%rax)
add    $0x8,%rax
cmp    %r14,%rax
jae    119f <stat+0x8f>
movsd  0x0(%r13),%xmm1
movsd  (%rax),%xmm0
ucomisd %xmm0,%xmm1
jb     1183 <stat+0x73>
movsd  %xmm0,0x0(%r13)
movsd  (%rax),%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
movsd  (%rax),%xmm0
ucomisd (%r12),%xmm0
jb     1160 <stat+0x50>
movsd  %xmm0,(%r12)
jmp    1160 <stat+0x50>
sub    %r15,%r14
shr    $0x3,%r14
movsd  (%rbx),%xmm0
mov    %r14d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [69 x i8] c"Zero elements defined. stat() needs at least one element to examine.\00"
define void @stat(double* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%12 = load double*, double** %10
%13 = load double*, double** %9
%14 = ptrtoint double* %12 to i64
%15 = ptrtoint double* %13 to i64
%16 = sub i64 %14, %15
%17 = sdiv exact i64 %16, 8
%18 = trunc i64 %17 to i32
store i32 %18, i32* %11
%19 = load double*, double** %9
%20 = load double*, double** %10
%21 = icmp eq double* %19, %20
br i1 %21, label %22, label %24
22: ; preds = %5
%23 = call i32 @die(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %5
%25 = load double*, double** %9
%26 = load double, double* %25
%27 = load double*, double** %6
store double %26, double* %27
%28 = load double*, double** %9
%29 = load double, double* %28
%30 = load double*, double** %8
store double %29, double* %30
br label %31
31: ; preds = %60, %24
%32 = load double*, double** %9
%33 = load double*, double** %10
%34 = icmp ult double* %32, %33
br i1 %34, label %35, label %63
35: ; preds = %31
%36 = load double*, double** %6
%37 = load double, double* %36
%38 = load double*, double** %9
%39 = load double, double* %38
%40 = fcmp oge double %37, %39
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = load double*, double** %9
%43 = load double, double* %42
%44 = load double*, double** %6
store double %43, double* %44
br label %45
45: ; preds = %41, %35
%46 = load double*, double** %9
%47 = load double, double* %46
%48 = load double*, double** %7
%49 = load double, double* %48
%50 = fadd double %49, %47
store double %50, double* %48
%51 = load double*, double** %8
%52 = load double, double* %51
%53 = load double*, double** %9
%54 = load double, double* %53
%55 = fcmp ole double %52, %54
br i1 %55, label %56, label %60
56: ; preds = %45
%57 = load double*, double** %9
%58 = load double, double* %57
%59 = load double*, double** %8
store double %58, double* %59
br label %60
60: ; preds = %56, %45
%61 = load double*, double** %9
%62 = getelementptr inbounds double, double* %61, i32 1
store double* %62, double** %9
br label %31
63: ; preds = %31
%64 = load double*, double** %7
%65 = load double, double* %64
%66 = load i32, i32* %11
%67 = uitofp i32 %66 to double
%68 = fdiv double %65, %67
%69 = load double*, double** %7
store double %68, double* %69
ret void
}

LLVM IR (-O2):
@.str = [69 x i8] c"Zero elements defined. stat() needs at least one element to examine.\00"
define void @stat(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* %3, double* %4) {
%6 = icmp eq double* %3, %4
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @die(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = load double, double* %3
store double %10, double* %0
%11 = load double, double* %3
store double %11, double* %2
%12 = icmp ult double* %3, %4
br i1 %12, label %13, label %31
13: ; preds = %9, %28
%14 = phi double* [ %29, %28 ], [ %3, %9 ]
%15 = load double, double* %0
%16 = load double, double* %14
%17 = fcmp ult double %15, %16
br i1 %17, label %20, label %18
18: ; preds = %13
store double %16, double* %0
%19 = load double, double* %14
br label %20
20: ; preds = %18, %13
%21 = phi double [ %19, %18 ], [ %16, %13 ]
%22 = load double, double* %1
%23 = fadd double %21, %22
store double %23, double* %1
%24 = load double, double* %2
%25 = load double, double* %14
%26 = fcmp ugt double %24, %25
br i1 %26, label %28, label %27
27: ; preds = %20
store double %25, double* %2
br label %28
28: ; preds = %27, %20
%29 = getelementptr inbounds double, double* %14, i64 1
%30 = icmp ult double* %29, %4
br i1 %30, label %13, label %31
31: ; preds = %28, %9
%32 = ptrtoint double* %4 to i64
%33 = ptrtoint double* %3 to i64
%34 = sub i64 %32, %33
%35 = lshr exact i64 %34, 3
%36 = trunc i64 %35 to i32
%37 = load double, double* %1
%38 = uitofp i32 %36 to double
%39 = fdiv double %37, %38
store double %39, double* %1
ret void
}