void allone_dvector(double *ret, int dim) {
  int i;
  for (i = 0; i < dim; i++)
    ret[i] = 1.0;
}


x86 assembly (clang, -O0):
<allone_dvector>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1141 <allone_dvector+0x41>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  0xed2(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <allone_dvector+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<allone_dvector>:
test   %esi,%esi
jle    121d <allone_dvector+0x11d>
mov    %esi,%eax
cmp    $0x4,%esi
jae    1116 <allone_dvector+0x16>
xor    %ecx,%ecx
jmp    11f7 <allone_dvector+0xf7>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%r8d
and    $0x7,%r8d
cmp    $0x1c,%rdx
jae    113e <allone_dvector+0x3e>
xor    %edx,%edx
jmp    11c1 <allone_dvector+0xc1>
and    $0xfffffffffffffff8,%rsi
xor    %edx,%edx
movaps 0xeb5(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,(%rdi,%rdx,8)
movups %xmm0,0x10(%rdi,%rdx,8)
movups %xmm0,0x20(%rdi,%rdx,8)
movups %xmm0,0x30(%rdi,%rdx,8)
movups %xmm0,0x40(%rdi,%rdx,8)
movups %xmm0,0x50(%rdi,%rdx,8)
movups %xmm0,0x60(%rdi,%rdx,8)
movups %xmm0,0x70(%rdi,%rdx,8)
movups %xmm0,0x80(%rdi,%rdx,8)
movups %xmm0,0x90(%rdi,%rdx,8)
movups %xmm0,0xa0(%rdi,%rdx,8)
movups %xmm0,0xb0(%rdi,%rdx,8)
movups %xmm0,0xc0(%rdi,%rdx,8)
movups %xmm0,0xd0(%rdi,%rdx,8)
movups %xmm0,0xe0(%rdi,%rdx,8)
movups %xmm0,0xf0(%rdi,%rdx,8)
add    $0x20,%rdx
add    $0xfffffffffffffff8,%rsi
jne    1150 <allone_dvector+0x50>
test   %r8,%r8
je     11f2 <allone_dvector+0xf2>
lea    (%rdi,%rdx,8),%rdx
add    $0x10,%rdx
shl    $0x5,%r8
xor    %esi,%esi
movaps 0xe25(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x10(%rdx,%rsi,1)
movups %xmm0,(%rdx,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r8
jne    11e0 <allone_dvector+0xe0>
cmp    %rax,%rcx
je     121d <allone_dvector+0x11d>
movabs $0x3ff0000000000000,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdx,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1210 <allone_dvector+0x110>
ret

LLVM IR (-O0):
define void @allone_dvector(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %15, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load double*, double** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
store double 1.000000e+00, double* %14
br label %15
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %6
18: ; preds = %6
ret void
}

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