#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 */
double fabs(double const);
double sqrt(double);
void HC_abs(long len, const double *x, double *z) {
  int i;
  double rx, ix;
  z[0] = fabs(x[0]);
  for (i = 1; i < (len + 1) / 2; i++) {
    rx = x[i];
    ix = x[len - i];
    z[i] = sqrt(rx * rx + ix * ix);
    z[len - i] = 0.0;
  }
  if (len % 2 == 0) {
    z[len / 2] = fabs(x[len / 2]);
  }
}


x86 assembly (clang, -O0):
<HC_abs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xecd(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jge    11ee <HC_abs+0xde>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
sub    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
sub    %rdx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1146 <HC_abs+0x36>
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1255 <HC_abs+0x145>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movaps 0xdd1(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HC_abs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
movsd  (%rsi),%xmm0
andpd  0xed0(%rip),%xmm0
movlpd %xmm0,(%rdx)
cmp    $0x3,%rdi
jl     1277 <HC_abs+0x167>
lea    0x1(%r15),%rax
shr    %rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rsp)
mov    $0x1,%ebx
cmp    $0x2,%rax
jne    1197 <HC_abs+0x87>
testb  $0x1,(%rsp)
je     1277 <HC_abs+0x167>
movsd  (%r12,%rbx,8),%xmm0
mov    %r15,%rbp
sub    %rbx,%rbp
movsd  (%r12,%rbp,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1264 <HC_abs+0x154>
sqrtsd %xmm0,%xmm0
jmp    1269 <HC_abs+0x159>
lea    -0x1(%r15),%rbp
mov    (%rsp),%r13
and    $0xfffffffffffffffe,%r13
neg    %r13
mov    $0x1,%ebx
xorpd  %xmm2,%xmm2
jmp    11f3 <HC_abs+0xe3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x8(%r14,%rbx,8)
movq   $0x0,-0x8(%r14,%rbp,8)
add    $0xfffffffffffffffe,%rbp
lea    (%rbx,%r13,1),%rax
add    $0x2,%rax
add    $0x2,%rbx
cmp    $0x1,%rax
je     1158 <HC_abs+0x48>
movsd  (%r12,%rbx,8),%xmm0
movsd  (%r12,%rbp,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1220 <HC_abs+0x110>
sqrtsd %xmm0,%xmm0
jmp    1229 <HC_abs+0x119>
nopw   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  %xmm0,(%r14,%rbx,8)
movq   $0x0,(%r14,%rbp,8)
movsd  0x8(%r12,%rbx,8),%xmm0
movsd  -0x8(%r12,%rbp,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11c0 <HC_abs+0xb0>
sqrtsd %xmm0,%xmm0
jmp    11c9 <HC_abs+0xb9>
call   1030 <sqrt@plt>
movsd  %xmm0,(%r14,%rbx,8)
movq   $0x0,(%r14,%rbp,8)
test   $0x1,%r15b
jne    12a3 <HC_abs+0x193>
mov    %r15,%rax
shr    $0x3f,%rax
add    %r15,%rax
shl    $0x2,%rax
and    $0xfffffffffffffff8,%rax
movsd  (%r12,%rax,1),%xmm0
andpd  0xd63(%rip),%xmm0
movlpd %xmm0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @HC_abs(i64 %0, double* %1, double* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i64 %0, i64* %4
store double* %1, double** %5
store double* %2, double** %6
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = call double @llvm.fabs.f64(double %12)
%14 = load double*, double** %6
%15 = getelementptr inbounds double, double* %14, i64 0
store double %13, double* %15
store i32 1, i32* %7
br label %16
16: ; preds = %53, %3
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = load i64, i64* %4
%20 = add nsw i64 %19, 1
%21 = sdiv i64 %20, 2
%22 = icmp slt i64 %18, %21
br i1 %22, label %23, label %56
23: ; preds = %16
%24 = load double*, double** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
store double %28, double* %8
%29 = load double*, double** %5
%30 = load i64, i64* %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = sub nsw i64 %30, %32
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load double, double* %34
store double %35, double* %9
%36 = load double, double* %8
%37 = load double, double* %8
%38 = load double, double* %9
%39 = load double, double* %9
%40 = fmul double %38, %39
%41 = call double @llvm.fmuladd.f64(double %36, double %37, double %40)
%42 = call double @sqrt(double %41)
%43 = load double*, double** %6
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %42, double* %46
%47 = load double*, double** %6
%48 = load i64, i64* %4
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = sub nsw i64 %48, %50
%52 = getelementptr inbounds double, double* %47, i64 %51
store double 0.000000e+00, double* %52
br label %53
53: ; preds = %23
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %16
56: ; preds = %16
%57 = load i64, i64* %4
%58 = srem i64 %57, 2
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %71
60: ; preds = %56
%61 = load double*, double** %5
%62 = load i64, i64* %4
%63 = sdiv i64 %62, 2
%64 = getelementptr inbounds double, double* %61, i64 %63
%65 = load double, double* %64
%66 = call double @llvm.fabs.f64(double %65)
%67 = load double*, double** %6
%68 = load i64, i64* %4
%69 = sdiv i64 %68, 2
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
br label %71
71: ; preds = %60, %56
ret void
}

LLVM IR (-O2):
define void @HC_abs(i64 %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = load double, double* %1
%5 = tail call double @llvm.fabs.f64(double %4)
store double %5, double* %2
%6 = icmp sgt i64 %0, 2
br i1 %6, label %7, label %56
7: ; preds = %3
%8 = add nuw nsw i64 %0, 1
%9 = lshr i64 %8, 1
%10 = add nsw i64 %9, -1
%11 = and i64 %10, 1
%12 = icmp eq i64 %9, 2
br i1 %12, label %42, label %13
13: ; preds = %7
%14 = and i64 %10, -2
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 1, %13 ], [ %39, %15 ]
%17 = phi i64 [ 0, %13 ], [ %40, %15 ]
%18 = getelementptr inbounds double, double* %1, i64 %16
%19 = load double, double* %18
%20 = sub nsw i64 %0, %16
%21 = getelementptr inbounds double, double* %1, i64 %20
%22 = load double, double* %21
%23 = fmul double %22, %22
%24 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %23)
%25 = tail call double @sqrt(double %24)
%26 = getelementptr inbounds double, double* %2, i64 %16
store double %25, double* %26
%27 = getelementptr inbounds double, double* %2, i64 %20
store double 0.000000e+00, double* %27
%28 = add nuw nsw i64 %16, 1
%29 = getelementptr inbounds double, double* %1, i64 %28
%30 = load double, double* %29
%31 = sub nsw i64 %0, %28
%32 = getelementptr inbounds double, double* %1, i64 %31
%33 = load double, double* %32
%34 = fmul double %33, %33
%35 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %34)
%36 = tail call double @sqrt(double %35)
%37 = getelementptr inbounds double, double* %2, i64 %28
store double %36, double* %37
%38 = getelementptr inbounds double, double* %2, i64 %31
store double 0.000000e+00, double* %38
%39 = add nuw nsw i64 %16, 2
%40 = add i64 %17, 2
%41 = icmp eq i64 %40, %14
br i1 %41, label %42, label %15
42: ; preds = %15, %7
%43 = phi i64 [ 1, %7 ], [ %39, %15 ]
%44 = icmp eq i64 %11, 0
br i1 %44, label %56, label %45
45: ; preds = %42
%46 = getelementptr inbounds double, double* %1, i64 %43
%47 = load double, double* %46
%48 = sub nsw i64 %0, %43
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = load double, double* %49
%51 = fmul double %50, %50
%52 = tail call double @llvm.fmuladd.f64(double %47, double %47, double %51)
%53 = tail call double @sqrt(double %52)
%54 = getelementptr inbounds double, double* %2, i64 %43
store double %53, double* %54
%55 = getelementptr inbounds double, double* %2, i64 %48
store double 0.000000e+00, double* %55
br label %56
56: ; preds = %45, %42, %3
%57 = and i64 %0, 1
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %56
%60 = sdiv i64 %0, 2
%61 = getelementptr inbounds double, double* %1, i64 %60
%62 = load double, double* %61
%63 = tail call double @llvm.fabs.f64(double %62)
%64 = getelementptr inbounds double, double* %2, i64 %60
store double %63, double* %64
br label %65
65: ; preds = %59, %56
ret void
}