#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);
void abs_dvector(double *ret, double *x, int dim) {
  int i;
  for (i = 0; i < dim; i++)
    ret[i] = fabs(x[i]);
}


x86 assembly (clang, -O0):
<abs_dvector>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1155 <abs_dvector+0x55>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xeca(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <abs_dvector+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<abs_dvector>:
test   %edx,%edx
jle    125a <abs_dvector+0x15a>
mov    %edx,%r9d
cmp    $0x4,%edx
jb     112a <abs_dvector+0x2a>
lea    (%rsi,%r9,8),%rax
cmp    %rdi,%rax
jbe    11c4 <abs_dvector+0xc4>
lea    (%rdi,%r9,8),%rax
cmp    %rsi,%rax
jbe    11c4 <abs_dvector+0xc4>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
add    %r9,%rax
mov    %r9,%rdx
and    $0x3,%rdx
je     1166 <abs_dvector+0x66>
movaps 0xebb(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsi,%rcx,8),%xmm1
andps  %xmm0,%xmm1
movlps %xmm1,(%rdi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
jne    1150 <abs_dvector+0x50>
cmp    $0x3,%rax
jb     125a <abs_dvector+0x15a>
movaps 0xe89(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm1
andps  %xmm0,%xmm1
movlps %xmm1,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
andps  %xmm0,%xmm1
movlps %xmm1,0x8(%rdi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm1
andps  %xmm0,%xmm1
movlps %xmm1,0x10(%rdi,%rcx,8)
movsd  0x18(%rsi,%rcx,8),%xmm1
andps  %xmm0,%xmm1
movlps %xmm1,0x18(%rdi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r9
jne    1180 <abs_dvector+0x80>
jmp    125a <abs_dvector+0x15a>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rax,%rax
je     125b <abs_dvector+0x15b>
mov    %r8,%rax
and    $0xfffffffffffffffe,%rax
xor    %edx,%edx
movaps 0xe12(%rip),%xmm0
xchg   %ax,%ax
movups (%rsi,%rdx,8),%xmm1
movups 0x10(%rsi,%rdx,8),%xmm2
andps  %xmm0,%xmm1
andps  %xmm0,%xmm2
movups %xmm1,(%rdi,%rdx,8)
movups %xmm2,0x10(%rdi,%rdx,8)
movups 0x20(%rsi,%rdx,8),%xmm1
movups 0x30(%rsi,%rdx,8),%xmm2
andps  %xmm0,%xmm1
andps  %xmm0,%xmm2
movups %xmm1,0x20(%rdi,%rdx,8)
movups %xmm2,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rax
jne    11f0 <abs_dvector+0xf0>
test   $0x1,%r8b
je     1251 <abs_dvector+0x151>
movups (%rsi,%rdx,8),%xmm0
movups 0x10(%rsi,%rdx,8),%xmm1
movaps 0xdbe(%rip),%xmm2
andps  %xmm2,%xmm0
andps  %xmm2,%xmm1
movups %xmm0,(%rdi,%rdx,8)
movups %xmm1,0x10(%rdi,%rdx,8)
cmp    %r9,%rcx
jne    112c <abs_dvector+0x2c>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    1232 <abs_dvector+0x132>
jmp    1251 <abs_dvector+0x151>

LLVM IR (-O0):
define void @abs_dvector(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %23, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load double*, double** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call double @llvm.fabs.f64(double %17)
%19 = load double*, double** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
store double %18, double* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @abs_dvector(double* nocapture writeonly %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %114
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = icmp ult i32 %2, 4
br i1 %7, label %72, label %8
8: ; preds = %5
%9 = getelementptr double, double* %0, i64 %6
%10 = getelementptr double, double* %1, i64 %6
%11 = icmp ugt double* %10, %0
%12 = icmp ugt double* %9, %1
%13 = and i1 %11, %12
br i1 %13, label %72, label %14
14: ; preds = %8
%15 = and i64 %6, 4294967292
%16 = add nsw i64 %15, -4
%17 = lshr exact i64 %16, 2
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 1
%20 = icmp eq i64 %16, 0
br i1 %20, label %54, label %21
21: ; preds = %14
%22 = and i64 %18, 9223372036854775806
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %51, %23 ]
%25 = phi i64 [ 0, %21 ], [ %52, %23 ]
%26 = getelementptr inbounds double, double* %1, i64 %24
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = getelementptr inbounds double, double* %26, i64 2
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %28)
%33 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %31)
%34 = getelementptr inbounds double, double* %0, i64 %24
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> %32, <2 x double>* %35
%36 = getelementptr inbounds double, double* %34, i64 2
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> %33, <2 x double>* %37
%38 = or i64 %24, 4
%39 = getelementptr inbounds double, double* %1, i64 %38
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds double, double* %39, i64 2
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %41)
%46 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %44)
%47 = getelementptr inbounds double, double* %0, i64 %38
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %45, <2 x double>* %48
%49 = getelementptr inbounds double, double* %47, i64 2
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %46, <2 x double>* %50
%51 = add nuw i64 %24, 8
%52 = add i64 %25, 2
%53 = icmp eq i64 %52, %22
br i1 %53, label %54, label %23
54: ; preds = %23, %14
%55 = phi i64 [ 0, %14 ], [ %51, %23 ]
%56 = icmp eq i64 %19, 0
br i1 %56, label %70, label %57
57: ; preds = %54
%58 = getelementptr inbounds double, double* %1, i64 %55
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %58, i64 2
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %60)
%65 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %63)
%66 = getelementptr inbounds double, double* %0, i64 %55
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %64, <2 x double>* %67
%68 = getelementptr inbounds double, double* %66, i64 2
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %65, <2 x double>* %69
br label %70
70: ; preds = %54, %57
%71 = icmp eq i64 %15, %6
br i1 %71, label %114, label %72
72: ; preds = %8, %5, %70
%73 = phi i64 [ 0, %8 ], [ 0, %5 ], [ %15, %70 ]
%74 = xor i64 %73, -1
%75 = add nsw i64 %74, %6
%76 = and i64 %6, 3
%77 = icmp eq i64 %76, 0
br i1 %77, label %88, label %78
78: ; preds = %72, %78
%79 = phi i64 [ %85, %78 ], [ %73, %72 ]
%80 = phi i64 [ %86, %78 ], [ 0, %72 ]
%81 = getelementptr inbounds double, double* %1, i64 %79
%82 = load double, double* %81
%83 = tail call double @llvm.fabs.f64(double %82)
%84 = getelementptr inbounds double, double* %0, i64 %79
store double %83, double* %84
%85 = add nuw nsw i64 %79, 1
%86 = add i64 %80, 1
%87 = icmp eq i64 %86, %76
br i1 %87, label %88, label %78
88: ; preds = %78, %72
%89 = phi i64 [ %73, %72 ], [ %85, %78 ]
%90 = icmp ult i64 %75, 3
br i1 %90, label %114, label %91
91: ; preds = %88, %91
%92 = phi i64 [ %112, %91 ], [ %89, %88 ]
%93 = getelementptr inbounds double, double* %1, i64 %92
%94 = load double, double* %93
%95 = tail call double @llvm.fabs.f64(double %94)
%96 = getelementptr inbounds double, double* %0, i64 %92
store double %95, double* %96
%97 = add nuw nsw i64 %92, 1
%98 = getelementptr inbounds double, double* %1, i64 %97
%99 = load double, double* %98
%100 = tail call double @llvm.fabs.f64(double %99)
%101 = getelementptr inbounds double, double* %0, i64 %97
store double %100, double* %101
%102 = add nuw nsw i64 %92, 2
%103 = getelementptr inbounds double, double* %1, i64 %102
%104 = load double, double* %103
%105 = tail call double @llvm.fabs.f64(double %104)
%106 = getelementptr inbounds double, double* %0, i64 %102
store double %105, double* %106
%107 = add nuw nsw i64 %92, 3
%108 = getelementptr inbounds double, double* %1, i64 %107
%109 = load double, double* %108
%110 = tail call double @llvm.fabs.f64(double %109)
%111 = getelementptr inbounds double, double* %0, i64 %107
store double %110, double* %111
%112 = add nuw nsw i64 %92, 4
%113 = icmp eq i64 %112, %6
br i1 %113, label %114, label %91
114: ; preds = %88, %91, %70, %3
ret void
}