void __attribute__((noipa))
f_div_double(double *restrict dest, double *restrict cond, double limit,
             double *restrict src, double val, unsigned int n) {
  for (unsigned int i = 0; i < n; ++i) {
    double truev = ((src[i]) / (val));
    dest[i] = cond[i] < limit ? truev : src[i];
  }
}


x86 assembly (clang, -O0):
<f_div_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    11a0 <f_div_double+0xa0>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1170 <f_div_double+0x70>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1181 <f_div_double+0x81>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1124 <f_div_double+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_div_double>:
test   %ecx,%ecx
je     1231 <f_div_double+0x131>
mov    %ecx,%r8d
cmp    $0x1,%ecx
jne    1117 <f_div_double+0x17>
xor    %ecx,%ecx
jmp    11f0 <f_div_double+0xf0>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
lea    -0x2(%rcx),%rax
mov    %rax,%r9
shr    %r9
add    $0x1,%r9
test   %rax,%rax
je     1232 <f_div_double+0x132>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
movapd 0xeab(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rdx,%rax,8),%xmm5
movupd (%rsi,%rax,8),%xmm6
cmpltpd %xmm3,%xmm6
movapd %xmm2,%xmm7
andpd  %xmm6,%xmm7
andnpd %xmm4,%xmm6
orpd   %xmm7,%xmm6
divpd  %xmm6,%xmm5
movupd %xmm5,(%rdi,%rax,8)
movupd 0x10(%rdx,%rax,8),%xmm5
movupd 0x10(%rsi,%rax,8),%xmm6
cmpltpd %xmm3,%xmm6
movapd %xmm2,%xmm7
andpd  %xmm6,%xmm7
andnpd %xmm4,%xmm6
orpd   %xmm7,%xmm6
divpd  %xmm6,%xmm5
movupd %xmm5,0x10(%rdi,%rax,8)
add    $0x4,%rax
add    $0xfffffffffffffffe,%r10
jne    1160 <f_div_double+0x60>
test   $0x1,%r9b
je     11eb <f_div_double+0xeb>
movupd (%rsi,%rax,8),%xmm4
cmpltpd %xmm3,%xmm4
andpd  %xmm4,%xmm2
andnpd 0xe27(%rip),%xmm4
movupd (%rdx,%rax,8),%xmm3
orpd   %xmm2,%xmm4
divpd  %xmm4,%xmm3
movupd %xmm3,(%rdi,%rax,8)
cmp    %r8,%rcx
je     1231 <f_div_double+0x131>
movsd  0xe18(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%rcx,8),%xmm3
movsd  (%rsi,%rcx,8),%xmm4
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm5
andpd  %xmm1,%xmm5
andnpd %xmm2,%xmm4
orpd   %xmm5,%xmm4
divsd  %xmm4,%xmm3
movsd  %xmm3,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%r8
jne    1200 <f_div_double+0x100>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    11c3 <f_div_double+0xc3>
jmp    11eb <f_div_double+0xeb>

LLVM IR (-O0):
define void @f_div_double(double* noalias %0, double* noalias %1, double %2, double* noalias %3, double %4, i32 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double*
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store double %2, double* %9
store double* %3, double** %10
store double %4, double* %11
store i32 %5, i32* %12
store i32 0, i32* %13
br label %15
15: ; preds = %48, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %12
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load double*, double** %10
%21 = load i32, i32* %13
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double, double* %11
%26 = fdiv double %24, %25
store double %26, double* %14
%27 = load double*, double** %8
%28 = load i32, i32* %13
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double, double* %9
%33 = fcmp olt double %31, %32
br i1 %33, label %34, label %36
34: ; preds = %19
%35 = load double, double* %14
br label %42
36: ; preds = %19
%37 = load double*, double** %10
%38 = load i32, i32* %13
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
br label %42
42: ; preds = %36, %34
%43 = phi double [ %35, %34 ], [ %41, %36 ]
%44 = load double*, double** %7
%45 = load i32, i32* %13
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %48
48: ; preds = %42
%49 = load i32, i32* %13
%50 = add i32 %49, 1
store i32 %50, i32* %13
br label %15
51: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @f_div_double(double* noalias nocapture writeonly %0, double* noalias nocapture %1, double %2, double* noalias nocapture %3, double %4, i32 %5) {
%7 = icmp eq i32 %5, 0
br i1 %7, label %72, label %8
8: ; preds = %6
%9 = zext i32 %5 to i64
%10 = icmp eq i32 %5, 1
br i1 %10, label %70, label %11
11: ; preds = %8
%12 = and i64 %9, 4294967294
%13 = insertelement <2 x double> poison, double %2, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x double> poison, double %4, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = add nsw i64 %12, -2
%18 = lshr exact i64 %17, 1
%19 = add nuw i64 %18, 1
%20 = and i64 %19, 1
%21 = icmp eq i64 %17, 0
br i1 %21, label %53, label %22
22: ; preds = %11
%23 = and i64 %19, -2
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %50, %24 ]
%26 = phi i64 [ 0, %22 ], [ %51, %24 ]
%27 = getelementptr inbounds double, double* %3, i64 %25
%28 = bitcast double* %27 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = getelementptr inbounds double, double* %1, i64 %25
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = fcmp olt <2 x double> %32, %14
%34 = select <2 x i1> %33, <2 x double> %16, <2 x double> <double 1.000000e+00, double 1.000000e+00>
%35 = fdiv <2 x double> %29, %34
%36 = getelementptr inbounds double, double* %0, i64 %25
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> %35, <2 x double>* %37
%38 = or i64 %25, 2
%39 = getelementptr inbounds double, double* %3, i64 %38
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds double, double* %1, i64 %38
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = fcmp olt <2 x double> %44, %14
%46 = select <2 x i1> %45, <2 x double> %16, <2 x double> <double 1.000000e+00, double 1.000000e+00>
%47 = fdiv <2 x double> %41, %46
%48 = getelementptr inbounds double, double* %0, i64 %38
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %47, <2 x double>* %49
%50 = add nuw i64 %25, 4
%51 = add nuw i64 %26, 2
%52 = icmp eq i64 %51, %23
br i1 %52, label %53, label %24
53: ; preds = %24, %11
%54 = phi i64 [ 0, %11 ], [ %50, %24 ]
%55 = icmp eq i64 %20, 0
br i1 %55, label %68, label %56
56: ; preds = %53
%57 = getelementptr inbounds double, double* %3, i64 %54
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %1, i64 %54
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = fcmp olt <2 x double> %62, %14
%64 = select <2 x i1> %63, <2 x double> %16, <2 x double> <double 1.000000e+00, double 1.000000e+00>
%65 = fdiv <2 x double> %59, %64
%66 = getelementptr inbounds double, double* %0, i64 %54
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %65, <2 x double>* %67
br label %68
68: ; preds = %53, %56
%69 = icmp eq i64 %12, %9
br i1 %69, label %72, label %70
70: ; preds = %8, %68
%71 = phi i64 [ 0, %8 ], [ %12, %68 ]
br label %73
72: ; preds = %73, %68, %6
ret void
73: ; preds = %70, %73
%74 = phi i64 [ %83, %73 ], [ %71, %70 ]
%75 = getelementptr inbounds double, double* %3, i64 %74
%76 = load double, double* %75
%77 = getelementptr inbounds double, double* %1, i64 %74
%78 = load double, double* %77
%79 = fcmp olt double %78, %2
%80 = select i1 %79, double %4, double 1.000000e+00
%81 = fdiv double %76, %80
%82 = getelementptr inbounds double, double* %0, i64 %74
store double %81, double* %82
%83 = add nuw nsw i64 %74, 1
%84 = icmp eq i64 %83, %9
br i1 %84, label %72, label %73
}