void rect(const int N, double *v) {
  int i;
  for (i = 0; i < N; i++) {
    *(v + i) = 1.0;
  }
}


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

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

LLVM IR (-O0):
define void @rect(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
store i32 0, i32* %5
br label %6
6: ; preds = %15, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load double*, double** %4
%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 @rect(i32 %0, double* nocapture writeonly %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %83
4: ; preds = %2
%5 = zext i32 %0 to i64
%6 = icmp ult i32 %0, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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* %1, 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
}