#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*/ assert(float *);
float vectorf_mean(float *, size_t);
void vectorf_remove_mean_inplace(float *self, size_t size) {
  assert(self);
  float mean = vectorf_mean(self, size);
  for (size_t i = 0; i < size; i++)
    self[i] -= mean;
}


x86 assembly (clang, -O0):
<vectorf_remove_mean_inplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vectorf_mean@plt>
movss  %xmm0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118d <vectorf_remove_mean_inplace+0x6d>
movss  -0x14(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1153 <vectorf_remove_mean_inplace+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectorf_remove_mean_inplace>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <vectorf_mean@plt>
test   %r14,%r14
je     11f7 <vectorf_remove_mean_inplace+0xd7>
cmp    $0x8,%r14
jae    1150 <vectorf_remove_mean_inplace+0x30>
xor    %eax,%eax
jmp    11e0 <vectorf_remove_mean_inplace+0xc0>
mov    %r14,%rax
and    $0xfffffffffffffff8,%rax
movaps %xmm0,%xmm1
shufps $0x0,%xmm0,%xmm1
lea    -0x8(%rax),%rcx
mov    %rcx,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     11ff <vectorf_remove_mean_inplace+0xdf>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
nop
movups (%rbx,%rcx,4),%xmm2
movups 0x10(%rbx,%rcx,4),%xmm3
movups 0x20(%rbx,%rcx,4),%xmm4
movups 0x30(%rbx,%rcx,4),%xmm5
subps  %xmm1,%xmm2
subps  %xmm1,%xmm3
movups %xmm2,(%rbx,%rcx,4)
movups %xmm3,0x10(%rbx,%rcx,4)
subps  %xmm1,%xmm4
subps  %xmm1,%xmm5
movups %xmm4,0x20(%rbx,%rcx,4)
movups %xmm5,0x30(%rbx,%rcx,4)
add    $0x10,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1180 <vectorf_remove_mean_inplace+0x60>
test   $0x1,%dl
je     11d9 <vectorf_remove_mean_inplace+0xb9>
movups (%rbx,%rcx,4),%xmm2
movups 0x10(%rbx,%rcx,4),%xmm3
subps  %xmm1,%xmm2
subps  %xmm1,%xmm3
movups %xmm2,(%rbx,%rcx,4)
movups %xmm3,0x10(%rbx,%rcx,4)
cmp    %r14,%rax
je     11f7 <vectorf_remove_mean_inplace+0xd7>
xchg   %ax,%ax
movss  (%rbx,%rax,4),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,(%rbx,%rax,4)
add    $0x1,%rax
cmp    %rax,%r14
jne    11e0 <vectorf_remove_mean_inplace+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %ecx,%ecx
test   $0x1,%dl
jne    11c1 <vectorf_remove_mean_inplace+0xa1>
jmp    11d9 <vectorf_remove_mean_inplace+0xb9>

LLVM IR (-O0):
define void @vectorf_remove_mean_inplace(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca float
%6 = alloca i64
store float* %0, float** %3
store i64 %1, i64* %4
%7 = load float*, float** %3
%8 = call i32 @assert(float* %7)
%9 = load float*, float** %3
%10 = load i64, i64* %4
%11 = call float @vectorf_mean(float* %9, i64 %10)
store float %11, float* %5
store i64 0, i64* %6
br label %12
12: ; preds = %23, %2
%13 = load i64, i64* %6
%14 = load i64, i64* %4
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load float, float* %5
%18 = load float*, float** %3
%19 = load i64, i64* %6
%20 = getelementptr inbounds float, float* %18, i64 %19
%21 = load float, float* %20
%22 = fsub float %21, %17
store float %22, float* %20
br label %23
23: ; preds = %16
%24 = load i64, i64* %6
%25 = add i64 %24, 1
store i64 %25, i64* %6
br label %12
26: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @vectorf_remove_mean_inplace(float* %0, i64 %1) {
%3 = tail call i32 @assert(float* %0)
%4 = tail call float @vectorf_mean(float* %0, i64 %1)
%5 = icmp eq i64 %1, 0
br i1 %5, label %66, label %6
6: ; preds = %2
%7 = icmp ult i64 %1, 8
br i1 %7, label %64, label %8
8: ; preds = %6
%9 = and i64 %1, -8
%10 = insertelement <4 x float> poison, float %4, i64 0
%11 = shufflevector <4 x float> %10, <4 x float> poison, <4 x i32> zeroinitializer
%12 = insertelement <4 x float> poison, float %4, i64 0
%13 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> zeroinitializer
%14 = add i64 %9, -8
%15 = lshr exact i64 %14, 3
%16 = add nuw nsw i64 %15, 1
%17 = and i64 %16, 1
%18 = icmp eq i64 %14, 0
br i1 %18, label %48, label %19
19: ; preds = %8
%20 = and i64 %16, 4611686018427387902
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %45, %21 ]
%23 = phi i64 [ 0, %19 ], [ %46, %21 ]
%24 = getelementptr inbounds float, float* %0, i64 %22
%25 = bitcast float* %24 to <4 x float>*
%26 = load <4 x float>, <4 x float>* %25
%27 = getelementptr inbounds float, float* %24, i64 4
%28 = bitcast float* %27 to <4 x float>*
%29 = load <4 x float>, <4 x float>* %28
%30 = fsub <4 x float> %26, %11
%31 = fsub <4 x float> %29, %13
%32 = bitcast float* %24 to <4 x float>*
store <4 x float> %30, <4 x float>* %32
%33 = bitcast float* %27 to <4 x float>*
store <4 x float> %31, <4 x float>* %33
%34 = or i64 %22, 8
%35 = getelementptr inbounds float, float* %0, i64 %34
%36 = bitcast float* %35 to <4 x float>*
%37 = load <4 x float>, <4 x float>* %36
%38 = getelementptr inbounds float, float* %35, i64 4
%39 = bitcast float* %38 to <4 x float>*
%40 = load <4 x float>, <4 x float>* %39
%41 = fsub <4 x float> %37, %11
%42 = fsub <4 x float> %40, %13
%43 = bitcast float* %35 to <4 x float>*
store <4 x float> %41, <4 x float>* %43
%44 = bitcast float* %38 to <4 x float>*
store <4 x float> %42, <4 x float>* %44
%45 = add nuw i64 %22, 16
%46 = add i64 %23, 2
%47 = icmp eq i64 %46, %20
br i1 %47, label %48, label %21
48: ; preds = %21, %8
%49 = phi i64 [ 0, %8 ], [ %45, %21 ]
%50 = icmp eq i64 %17, 0
br i1 %50, label %62, label %51
51: ; preds = %48
%52 = getelementptr inbounds float, float* %0, i64 %49
%53 = bitcast float* %52 to <4 x float>*
%54 = load <4 x float>, <4 x float>* %53
%55 = getelementptr inbounds float, float* %52, i64 4
%56 = bitcast float* %55 to <4 x float>*
%57 = load <4 x float>, <4 x float>* %56
%58 = fsub <4 x float> %54, %11
%59 = fsub <4 x float> %57, %13
%60 = bitcast float* %52 to <4 x float>*
store <4 x float> %58, <4 x float>* %60
%61 = bitcast float* %55 to <4 x float>*
store <4 x float> %59, <4 x float>* %61
br label %62
62: ; preds = %48, %51
%63 = icmp eq i64 %9, %1
br i1 %63, label %66, label %64
64: ; preds = %6, %62
%65 = phi i64 [ 0, %6 ], [ %9, %62 ]
br label %67
66: ; preds = %67, %62, %2
ret void
67: ; preds = %64, %67
%68 = phi i64 [ %72, %67 ], [ %65, %64 ]
%69 = getelementptr inbounds float, float* %0, i64 %68
%70 = load float, float* %69
%71 = fsub float %70, %4
store float %71, float* %69
%72 = add nuw i64 %68, 1
%73 = icmp eq i64 %72, %1
br i1 %73, label %66, label %67
}