void test_double_le(double *restrict r, double *restrict a, double *restrict b,
                    int n) {
  for (int i = 0; i < n; ++i)
    r[i] = __builtin_fabs(a[i]) <= __builtin_fabs(b[i]) ? 1.0 : 0.0;
}


x86 assembly (clang, -O0):
<test_double_le>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1190 <test_double_le+0x90>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xed6(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xebe(%rip),%xmm2
pand   %xmm2,%xmm1
movsd  0xea2(%rip),%xmm3
xorps  %xmm2,%xmm2
cmplesd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <test_double_le+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_le>:
test   %ecx,%ecx
jle    11d9 <test_double_le+0xd9>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    1117 <test_double_le+0x17>
xor    %ecx,%ecx
jmp    1191 <test_double_le+0x91>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
lea    0x0(,%r8,8),%r9
and    $0xffffffffffffffe0,%r9
xor    %eax,%eax
movapd 0xecd(%rip),%xmm0
movapd 0xed5(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%rax,1),%xmm2
movupd 0x10(%rsi,%rax,1),%xmm3
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm3
movupd (%rdx,%rax,1),%xmm4
movupd 0x10(%rdx,%rax,1),%xmm5
andpd  %xmm0,%xmm4
cmplepd %xmm4,%xmm2
andpd  %xmm0,%xmm5
cmplepd %xmm5,%xmm3
andpd  %xmm1,%xmm2
andpd  %xmm1,%xmm3
movupd %xmm2,(%rdi,%rax,1)
movupd %xmm3,0x10(%rdi,%rax,1)
add    $0x20,%rax
cmp    %rax,%r9
jne    1140 <test_double_le+0x40>
cmp    %r8,%rcx
je     11d9 <test_double_le+0xd9>
movapd 0xe67(%rip),%xmm0
movsd  0xe7f(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm2
andpd  %xmm0,%xmm2
movsd  (%rdx,%rcx,8),%xmm3
andpd  %xmm0,%xmm3
cmplesd %xmm3,%xmm2
andpd  %xmm1,%xmm2
movlpd %xmm2,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%r8
jne    11b0 <test_double_le+0xb0>
ret

LLVM IR (-O0):
define void @test_double_le(double* noalias %0, double* noalias %1, double* noalias %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %34, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load double*, double** %6
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = call double @llvm.fabs.f64(double %19)
%21 = load double*, double** %7
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = call double @llvm.fabs.f64(double %25)
%27 = fcmp ole double %20, %26
%28 = zext i1 %27 to i64
%29 = select i1 %27, double 1.000000e+00, double 0.000000e+00
%30 = load double*, double** %5
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
br label %34
34: ; preds = %14
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %10
37: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @test_double_le(double* noalias nocapture writeonly %0, double* noalias nocapture %1, double* noalias nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %43
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = icmp ult i32 %3, 4
br i1 %8, label %41, label %9
9: ; preds = %6
%10 = and i64 %7, 4294967292
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %37, %11 ]
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = bitcast double* %13 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = getelementptr inbounds double, double* %13, i64 2
%17 = bitcast double* %16 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %15)
%20 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %18)
%21 = getelementptr inbounds double, double* %2, i64 %12
%22 = bitcast double* %21 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = getelementptr inbounds double, double* %21, i64 2
%25 = bitcast double* %24 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %23)
%28 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %26)
%29 = fcmp ole <2 x double> %19, %27
%30 = fcmp ole <2 x double> %20, %28
%31 = select <2 x i1> %29, <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double> zeroinitializer
%32 = select <2 x i1> %30, <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double> zeroinitializer
%33 = getelementptr inbounds double, double* %0, i64 %12
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> %31, <2 x double>* %34
%35 = getelementptr inbounds double, double* %33, i64 2
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> %32, <2 x double>* %36
%37 = add nuw i64 %12, 4
%38 = icmp eq i64 %37, %10
br i1 %38, label %39, label %11
39: ; preds = %11
%40 = icmp eq i64 %10, %7
br i1 %40, label %43, label %41
41: ; preds = %6, %39
%42 = phi i64 [ 0, %6 ], [ %10, %39 ]
br label %44
43: ; preds = %44, %39, %4
ret void
44: ; preds = %41, %44
%45 = phi i64 [ %55, %44 ], [ %42, %41 ]
%46 = getelementptr inbounds double, double* %1, i64 %45
%47 = load double, double* %46
%48 = tail call double @llvm.fabs.f64(double %47)
%49 = getelementptr inbounds double, double* %2, i64 %45
%50 = load double, double* %49
%51 = tail call double @llvm.fabs.f64(double %50)
%52 = fcmp ole double %48, %51
%53 = select i1 %52, double 1.000000e+00, double 0.000000e+00
%54 = getelementptr inbounds double, double* %0, i64 %45
store double %53, double* %54
%55 = add nuw nsw i64 %45, 1
%56 = icmp eq i64 %55, %7
br i1 %56, label %43, label %44
}