double *rectangular(double *w, const int leng) {
  int k;
  double *p;
  for (k = 0, p = w; k < leng; k++)
    *p++ = 1.0;
  return (w);
}


x86 assembly (clang, -O0):
<rectangular>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    114f <rectangular+0x4f>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    111a <rectangular+0x1a>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rectangular>:
mov    %rdi,%rax
test   %esi,%esi
jle    122c <rectangular+0x12c>
lea    -0x1(%rsi),%r8d
xor    %r9d,%r9d
mov    %rax,%rcx
cmp    $0x3,%r8d
jb     120b <rectangular+0x10b>
add    $0x1,%r8
mov    %r8,%r9
and    $0xfffffffffffffffc,%r9
lea    -0x4(%r9),%rcx
mov    %rcx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%edx
and    $0x7,%edx
cmp    $0x1c,%rcx
jae    114b <rectangular+0x4b>
xor    %ecx,%ecx
jmp    11d1 <rectangular+0xd1>
and    $0xfffffffffffffff8,%rdi
xor    %ecx,%ecx
movaps 0xea8(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,(%rax,%rcx,8)
movups %xmm0,0x10(%rax,%rcx,8)
movups %xmm0,0x20(%rax,%rcx,8)
movups %xmm0,0x30(%rax,%rcx,8)
movups %xmm0,0x40(%rax,%rcx,8)
movups %xmm0,0x50(%rax,%rcx,8)
movups %xmm0,0x60(%rax,%rcx,8)
movups %xmm0,0x70(%rax,%rcx,8)
movups %xmm0,0x80(%rax,%rcx,8)
movups %xmm0,0x90(%rax,%rcx,8)
movups %xmm0,0xa0(%rax,%rcx,8)
movups %xmm0,0xb0(%rax,%rcx,8)
movups %xmm0,0xc0(%rax,%rcx,8)
movups %xmm0,0xd0(%rax,%rcx,8)
movups %xmm0,0xe0(%rax,%rcx,8)
movups %xmm0,0xf0(%rax,%rcx,8)
add    $0x20,%rcx
add    $0xfffffffffffffff8,%rdi
jne    1160 <rectangular+0x60>
test   %rdx,%rdx
je     1202 <rectangular+0x102>
lea    (%rax,%rcx,8),%rcx
add    $0x10,%rcx
shl    $0x5,%rdx
xor    %edi,%edi
movaps 0xe15(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x10(%rcx,%rdi,1)
movups %xmm0,(%rcx,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    11f0 <rectangular+0xf0>
cmp    %r9,%r8
je     122c <rectangular+0x12c>
lea    (%rax,%r9,8),%rcx
sub    %r9d,%esi
xor    %edx,%edx
movabs $0x3ff0000000000000,%rdi
nopw   0x0(%rax,%rax,1)
mov    %rdi,(%rcx,%rdx,8)
add    $0x1,%rdx
cmp    %edx,%esi
jne    1220 <rectangular+0x120>
ret

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

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