__float128 compute_mean(const int N, const __float128 data[]) {
  assert(N >= 1);
  __float128 sum = data[0];
  __float128 c = 0.0, y, t;
  int i;
  for (i = 1; i < N; i++) {
    y = data[i] - c;
    t = sum + y;
    c = (t - sum) - y;
    sum = t;
  }
  return sum / (__float128)N;
}


x86 assembly (clang, -O0):
<compute_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
xor    %eax,%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
test   %eax,%eax
setg   %al
movzbl %al,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
movaps (%rax),%xmm0
movaps %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b6 <compute_mean+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
shl    $0x4,%rcx
movaps (%rax,%rcx,1),%xmm0
movaps -0x30(%rbp),%xmm1
call   3110 <__subtf3>
movaps %xmm0,-0x40(%rbp)
movaps -0x20(%rbp),%xmm0
movaps -0x40(%rbp),%xmm1
call   11e0 <__addtf3>
movaps %xmm0,-0x50(%rbp)
movaps -0x50(%rbp),%xmm0
movaps -0x20(%rbp),%xmm1
call   3110 <__subtf3>
movaps -0x40(%rbp),%xmm1
call   3110 <__subtf3>
movaps %xmm0,-0x30(%rbp)
movaps -0x50(%rbp),%xmm0
movaps %xmm0,-0x20(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    114c <compute_mean+0x3c>
movaps -0x20(%rbp),%xmm0
movaps %xmm0,-0x70(%rbp)
mov    -0x4(%rbp),%edi
call   4450 <__floatsitf>
movaps %xmm0,%xmm1
movaps -0x70(%rbp),%xmm0
call   25c0 <__divtf3>
add    $0x70,%rsp
pop    %rbp
ret
nopl   0x0(%rax,%rax,1)

x86 assembly (clang, -O2):
<compute_mean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %edi,%r12d
xor    %edi,%edi
test   %r12d,%r12d
setg   %dil
xor    %eax,%eax
call   1030 <assert@plt>
movaps (%r14),%xmm0
cmp    $0x2,%r12d
movaps %xmm0,(%rsp)
jl     1233 <compute_mean+0x123>
mov    %r12d,%r15d
add    $0xffffffffffffffff,%r15
cmp    $0x2,%r12d
jne    1160 <compute_mean+0x50>
xorps  %xmm1,%xmm1
mov    $0x1,%ebx
jmp    120f <compute_mean+0xff>
lea    0x20(%r14),%rbp
mov    %r15,%r13
and    $0xfffffffffffffffe,%r13
neg    %r13
xorps  %xmm1,%xmm1
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
movaps -0x10(%rbp),%xmm0
movaps 0x0(%rbp),%xmm2
movaps %xmm2,0x10(%rsp)
call   3190 <__subtf3>
movaps %xmm0,%xmm1
movaps %xmm0,0x30(%rsp)
movaps (%rsp),%xmm0
call   1260 <__addtf3>
movaps %xmm0,0x20(%rsp)
movaps (%rsp),%xmm1
call   3190 <__subtf3>
movaps 0x30(%rsp),%xmm1
call   3190 <__subtf3>
movaps %xmm0,%xmm1
movaps 0x10(%rsp),%xmm0
call   3190 <__subtf3>
movaps %xmm0,%xmm1
movaps %xmm0,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1260 <__addtf3>
movaps %xmm0,(%rsp)
movaps 0x20(%rsp),%xmm1
call   3190 <__subtf3>
movaps 0x10(%rsp),%xmm1
call   3190 <__subtf3>
movaps %xmm0,%xmm1
add    $0x20,%rbp
lea    (%rbx,%r13,1),%rax
add    $0x2,%rax
add    $0x2,%rbx
cmp    $0x1,%rax
jne    1180 <compute_mean+0x70>
test   $0x1,%r15b
je     1233 <compute_mean+0x123>
shl    $0x4,%rbx
movaps (%r14,%rbx,1),%xmm0
call   3190 <__subtf3>
movaps %xmm0,%xmm1
movaps (%rsp),%xmm0
call   1260 <__addtf3>
movaps %xmm0,(%rsp)
mov    %r12d,%edi
call   44d0 <__floatsitf>
movaps %xmm0,%xmm1
movaps (%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    2640 <__divtf3>
cs nopw 0x0(%rax,%rax,1)
nop

LLVM IR (-O0):
define fp128 @compute_mean(i32 %0, fp128* %1) {
%3 = alloca i32
%4 = alloca fp128*
%5 = alloca fp128
%6 = alloca fp128
%7 = alloca fp128
%8 = alloca fp128
%9 = alloca i32
store i32 %0, i32* %3
store fp128* %1, fp128** %4
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %12)
%14 = load fp128*, fp128** %4
%15 = getelementptr inbounds fp128, fp128* %14, i64 0
%16 = load fp128, fp128* %15
store fp128 %16, fp128* %5
store fp128 0xL00000000000000000000000000000000, fp128* %6
store i32 1, i32* %9
br label %17
17: ; preds = %38, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = load fp128*, fp128** %4
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds fp128, fp128* %22, i64 %24
%26 = load fp128, fp128* %25
%27 = load fp128, fp128* %6
%28 = fsub fp128 %26, %27
store fp128 %28, fp128* %7
%29 = load fp128, fp128* %5
%30 = load fp128, fp128* %7
%31 = fadd fp128 %29, %30
store fp128 %31, fp128* %8
%32 = load fp128, fp128* %8
%33 = load fp128, fp128* %5
%34 = fsub fp128 %32, %33
%35 = load fp128, fp128* %7
%36 = fsub fp128 %34, %35
store fp128 %36, fp128* %6
%37 = load fp128, fp128* %8
store fp128 %37, fp128* %5
br label %38
38: ; preds = %21
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %17
41: ; preds = %17
%42 = load fp128, fp128* %5
%43 = load i32, i32* %3
%44 = sitofp i32 %43 to fp128
%45 = fdiv fp128 %42, %44
ret fp128 %45
}

LLVM IR (-O2):
define fp128 @compute_mean(i32 %0, fp128* nocapture %1) {
%3 = icmp sgt i32 %0, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %4)
%6 = load fp128, fp128* %1
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %47
8: ; preds = %2
%9 = zext i32 %0 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %10, 1
%12 = icmp eq i32 %0, 2
br i1 %12, label %36, label %13
13: ; preds = %8
%14 = and i64 %10, -2
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 1, %13 ], [ %33, %15 ]
%17 = phi fp128 [ %6, %13 ], [ %30, %15 ]
%18 = phi fp128 [ 0xL00000000000000000000000000000000, %13 ], [ %32, %15 ]
%19 = phi i64 [ 0, %13 ], [ %34, %15 ]
%20 = getelementptr inbounds fp128, fp128* %1, i64 %16
%21 = load fp128, fp128* %20
%22 = fsub fp128 %21, %18
%23 = fadd fp128 %17, %22
%24 = fsub fp128 %23, %17
%25 = fsub fp128 %24, %22
%26 = add nuw nsw i64 %16, 1
%27 = getelementptr inbounds fp128, fp128* %1, i64 %26
%28 = load fp128, fp128* %27
%29 = fsub fp128 %28, %25
%30 = fadd fp128 %23, %29
%31 = fsub fp128 %30, %23
%32 = fsub fp128 %31, %29
%33 = add nuw nsw i64 %16, 2
%34 = add i64 %19, 2
%35 = icmp eq i64 %34, %14
br i1 %35, label %36, label %15
36: ; preds = %15, %8
%37 = phi fp128 [ undef, %8 ], [ %30, %15 ]
%38 = phi i64 [ 1, %8 ], [ %33, %15 ]
%39 = phi fp128 [ %6, %8 ], [ %30, %15 ]
%40 = phi fp128 [ 0xL00000000000000000000000000000000, %8 ], [ %32, %15 ]
%41 = icmp eq i64 %11, 0
br i1 %41, label %47, label %42
42: ; preds = %36
%43 = getelementptr inbounds fp128, fp128* %1, i64 %38
%44 = load fp128, fp128* %43
%45 = fsub fp128 %44, %40
%46 = fadd fp128 %39, %45
br label %47
47: ; preds = %42, %36, %2
%48 = phi fp128 [ %6, %2 ], [ %37, %36 ], [ %46, %42 ]
%49 = sitofp i32 %0 to fp128
%50 = fdiv fp128 %48, %49
ret fp128 %50
}