#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(double *);
double *malloc(int);
double *standardize(unsigned n, double *numbers, double mean, double stdv) {
  double *results = malloc(sizeof(double) * n);
  assert(results);
  for (unsigned i = 0; i < n; i++) {
    results[i] = (numbers[i] - mean) / stdv;
  }
  return results;
}


x86 assembly (clang, -O0):
<standardize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <assert@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1197 <standardize+0x77>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <standardize+0x3b>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<standardize>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movapd %xmm1,0x10(%rsp)
movapd %xmm0,(%rsp)
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <assert@plt>
movapd (%rsp),%xmm4
movapd 0x10(%rsp),%xmm3
test   %r15d,%r15d
je     121c <standardize+0xfc>
mov    %r15d,%eax
cmp    $0x1,%r15d
jne    1176 <standardize+0x56>
xor    %ecx,%ecx
jmp    1200 <standardize+0xe0>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm4,%xmm0
unpcklpd %xmm4,%xmm0
movapd %xmm3,%xmm1
unpcklpd %xmm3,%xmm1
lea    -0x2(%rcx),%rsi
mov    %rsi,%rdx
shr    %rdx
add    $0x1,%rdx
test   %rsi,%rsi
je     1229 <standardize+0x109>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movupd (%r14,%rsi,8),%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
movupd 0x10(%r14,%rsi,8),%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0xfffffffffffffffe,%rdi
jne    11b0 <standardize+0x90>
test   $0x1,%dl
je     11fa <standardize+0xda>
movupd (%r14,%rsi,8),%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rsi,8)
cmp    %rax,%rcx
je     121c <standardize+0xfc>
nop
movsd  (%r14,%rcx,8),%xmm0
subsd  %xmm4,%xmm0
divsd  %xmm3,%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1200 <standardize+0xe0>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %esi,%esi
test   $0x1,%dl
jne    11e7 <standardize+0xc7>
jmp    11fa <standardize+0xda>

LLVM IR (-O0):
define double* @standardize(i32 %0, double* %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double*
%10 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double %2, double* %7
store double %3, double* %8
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call double* @malloc(i32 %14)
store double* %15, double** %9
%16 = load double*, double** %9
%17 = call i32 @assert(double* %16)
store i32 0, i32* %10
br label %18
18: ; preds = %36, %4
%19 = load i32, i32* %10
%20 = load i32, i32* %5
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load double*, double** %6
%24 = load i32, i32* %10
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double, double* %7
%29 = fsub double %27, %28
%30 = load double, double* %8
%31 = fdiv double %29, %30
%32 = load double*, double** %9
%33 = load i32, i32* %10
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %22
%37 = load i32, i32* %10
%38 = add i32 %37, 1
store i32 %38, i32* %10
br label %18
39: ; preds = %18
%40 = load double*, double** %9
ret double* %40
}

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