void half(double *begin, double *end) {
  while (begin < end) {
    *begin /= 2;
    ++begin;
  }
}


x86 assembly (clang, -O0):
<half>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1143 <half+0x43>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xed6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    110c <half+0xc>
pop    %rbp
ret

x86 assembly (clang, -O2):
<half>:
cmp    %rsi,%rdi
jae    1205 <half+0x105>
lea    0x8(%rdi),%rcx
cmp    %rcx,%rsi
cmova  %rsi,%rcx
mov    %rdi,%rax
not    %rax
add    %rcx,%rax
cmp    $0x18,%rax
jb     11dd <half+0xdd>
shr    $0x3,%rax
add    $0x1,%rax
mov    %rax,%r8
and    $0xfffffffffffffffc,%r8
lea    -0x4(%r8),%rcx
mov    %rcx,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rcx,%rcx
je     1206 <half+0x106>
mov    %r9,%rcx
and    $0xfffffffffffffffe,%rcx
xor    %edx,%edx
movapd 0xea1(%rip),%xmm0
nop
movupd (%rdi,%rdx,8),%xmm1
movupd 0x10(%rdi,%rdx,8),%xmm2
movupd 0x20(%rdi,%rdx,8),%xmm3
movupd 0x30(%rdi,%rdx,8),%xmm4
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rdi,%rdx,8)
movupd %xmm2,0x10(%rdi,%rdx,8)
mulpd  %xmm0,%xmm3
mulpd  %xmm0,%xmm4
movupd %xmm3,0x20(%rdi,%rdx,8)
movupd %xmm4,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rcx
jne    1160 <half+0x60>
test   $0x1,%r9b
je     11d4 <half+0xd4>
movupd (%rdi,%rdx,8),%xmm0
movupd 0x10(%rdi,%rdx,8),%xmm1
movapd 0xe3f(%rip),%xmm2
mulpd  %xmm2,%xmm0
mulpd  %xmm2,%xmm1
movupd %xmm0,(%rdi,%rdx,8)
movupd %xmm1,0x10(%rdi,%rdx,8)
cmp    %r8,%rax
je     1205 <half+0x105>
lea    (%rdi,%r8,8),%rdi
movsd  0xe2b(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rdi),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi)
add    $0x8,%rdi
cmp    %rsi,%rdi
jb     11f0 <half+0xf0>
ret
xor    %edx,%edx
test   $0x1,%r9b
jne    11ae <half+0xae>
jmp    11d4 <half+0xd4>

LLVM IR (-O0):
define void @half(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
br label %5
5: ; preds = %9, %2
%6 = load double*, double** %3
%7 = load double*, double** %4
%8 = icmp ult double* %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load double*, double** %3
%11 = load double, double* %10
%12 = fdiv double %11, 2.000000e+00
store double %12, double* %10
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i32 1
store double* %14, double** %3
br label %5
15: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @half(double* %0, double* readnone %1) {
%3 = ptrtoint double* %0 to i64
%4 = icmp ult double* %0, %1
br i1 %4, label %5, label %75
5: ; preds = %2
%6 = ptrtoint double* %1 to i64
%7 = add i64 %3, 8
%8 = call i64 @llvm.umax.i64(i64 %6, i64 %7)
%9 = xor i64 %3, -1
%10 = add i64 %8, %9
%11 = lshr i64 %10, 3
%12 = add nuw nsw i64 %11, 1
%13 = icmp ult i64 %10, 24
br i1 %13, label %67, label %14
14: ; preds = %5
%15 = and i64 %12, 4611686018427387900
%16 = getelementptr double, double* %0, i64 %15
%17 = add nsw i64 %15, -4
%18 = lshr exact i64 %17, 2
%19 = add nuw nsw i64 %18, 1
%20 = and i64 %19, 1
%21 = icmp eq i64 %17, 0
br i1 %21, label %51, label %22
22: ; preds = %14
%23 = and i64 %19, 9223372036854775806
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %48, %24 ]
%26 = phi i64 [ 0, %22 ], [ %49, %24 ]
%27 = getelementptr double, double* %0, i64 %25
%28 = bitcast double* %27 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = getelementptr double, double* %27, i64 2
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = fmul <2 x double> %29, <double 5.000000e-01, double 5.000000e-01>
%34 = fmul <2 x double> %32, <double 5.000000e-01, double 5.000000e-01>
%35 = bitcast double* %27 to <2 x double>*
store <2 x double> %33, <2 x double>* %35
%36 = bitcast double* %30 to <2 x double>*
store <2 x double> %34, <2 x double>* %36
%37 = or i64 %25, 4
%38 = getelementptr double, double* %0, i64 %37
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = fmul <2 x double> %40, <double 5.000000e-01, double 5.000000e-01>
%45 = fmul <2 x double> %43, <double 5.000000e-01, double 5.000000e-01>
%46 = bitcast double* %38 to <2 x double>*
store <2 x double> %44, <2 x double>* %46
%47 = bitcast double* %41 to <2 x double>*
store <2 x double> %45, <2 x double>* %47
%48 = add nuw i64 %25, 8
%49 = add i64 %26, 2
%50 = icmp eq i64 %49, %23
br i1 %50, label %51, label %24
51: ; preds = %24, %14
%52 = phi i64 [ 0, %14 ], [ %48, %24 ]
%53 = icmp eq i64 %20, 0
br i1 %53, label %65, label %54
54: ; preds = %51
%55 = getelementptr double, double* %0, i64 %52
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = fmul <2 x double> %57, <double 5.000000e-01, double 5.000000e-01>
%62 = fmul <2 x double> %60, <double 5.000000e-01, double 5.000000e-01>
%63 = bitcast double* %55 to <2 x double>*
store <2 x double> %61, <2 x double>* %63
%64 = bitcast double* %58 to <2 x double>*
store <2 x double> %62, <2 x double>* %64
br label %65
65: ; preds = %51, %54
%66 = icmp eq i64 %12, %15
br i1 %66, label %75, label %67
67: ; preds = %5, %65
%68 = phi double* [ %0, %5 ], [ %16, %65 ]
br label %69
69: ; preds = %67, %69
%70 = phi double* [ %73, %69 ], [ %68, %67 ]
%71 = load double, double* %70
%72 = fmul double %71, 5.000000e-01
store double %72, double* %70
%73 = getelementptr inbounds double, double* %70, i64 1
%74 = icmp ult double* %73, %1
br i1 %74, label %69, label %75
75: ; preds = %69, %65, %2
ret void
}