void __attribute__((no, noclone))
reduc_max_double(double (*restrict a)[(1024 / sizeof(double))],
                 double *restrict r, int n) {
  for (int i = 0; i < n; i++) {
    r[i] = a[i][0];
    for (int j = 0; j < (1024 / sizeof(double)); j++)
      r[i] = a[i][j] > r[i] ? a[i][j] : r[i];
  }
}


x86 assembly (clang, -O0):
<reduc_max_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11eb <reduc_max_double+0xeb>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x80,%rax
jae    11d8 <reduc_max_double+0xd8>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    11a6 <reduc_max_double+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b8 <reduc_max_double+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <reduc_max_double+0x49>
jmp    11dd <reduc_max_double+0xdd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <reduc_max_double+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<reduc_max_double>:
test   %edx,%edx
jle    1175 <reduc_max_double+0x75>
mov    %edx,%r8d
xor    %ecx,%ecx
mov    %rdi,%rdx
jmp    1125 <reduc_max_double+0x25>
xchg   %ax,%ax
movsd  %xmm1,(%rsi,%rcx,8)
add    $0x1,%rcx
add    $0x400,%rdx
cmp    %r8,%rcx
je     1175 <reduc_max_double+0x75>
mov    %rcx,%rax
shl    $0xa,%rax
movsd  (%rdi,%rax,1),%xmm0
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  -0x18(%rdx,%rax,8),%xmm1
maxsd  %xmm0,%xmm1
movsd  -0x10(%rdx,%rax,8),%xmm0
maxsd  %xmm1,%xmm0
movsd  -0x8(%rdx,%rax,8),%xmm1
maxsd  %xmm0,%xmm1
cmp    $0x80,%rax
je     1110 <reduc_max_double+0x10>
movsd  (%rdx,%rax,8),%xmm0
maxsd  %xmm1,%xmm0
add    $0x4,%rax
jmp    1140 <reduc_max_double+0x40>
ret

LLVM IR (-O0):
define void @reduc_max_double([128 x double]* noalias %0, double* noalias %1, i32 %2) {
%4 = alloca [128 x double]*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [128 x double]* %0, [128 x double]** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %68, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %71
13: ; preds = %9
%14 = load [128 x double]*, [128 x double]** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [128 x double], [128 x double]* %14, i64 %16
%18 = getelementptr inbounds [128 x double], [128 x double]* %17, i64 0, i64 0
%19 = load double, double* %18
%20 = load double*, double** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double %19, double* %23
store i32 0, i32* %8
br label %24
24: ; preds = %64, %13
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = icmp ult i64 %26, 128
br i1 %27, label %28, label %67
28: ; preds = %24
%29 = load [128 x double]*, [128 x double]** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [128 x double], [128 x double]* %29, i64 %31
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [128 x double], [128 x double]* %32, i64 0, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = fcmp ogt double %36, %41
br i1 %42, label %43, label %52
43: ; preds = %28
%44 = load [128 x double]*, [128 x double]** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [128 x double], [128 x double]* %44, i64 %46
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [128 x double], [128 x double]* %47, i64 0, i64 %49
%51 = load double, double* %50
br label %58
52: ; preds = %28
%53 = load double*, double** %5
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
br label %58
58: ; preds = %52, %43
%59 = phi double [ %51, %43 ], [ %57, %52 ]
%60 = load double*, double** %5
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double %59, double* %63
br label %64
64: ; preds = %58
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %24
67: ; preds = %24
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %9
71: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @reduc_max_double([128 x double]* noalias nocapture %0, double* noalias nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %8
7: ; preds = %13, %3
ret void
8: ; preds = %5, %13
%9 = phi i64 [ 0, %5 ], [ %14, %13 ]
%10 = getelementptr inbounds [128 x double], [128 x double]* %0, i64 %9, i64 0
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 %9
br label %16
13: ; preds = %16
store double %32, double* %12
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %6
br i1 %15, label %7, label %8
16: ; preds = %35, %8
%17 = phi i64 [ 1, %8 ], [ %40, %35 ]
%18 = phi double [ %11, %8 ], [ %39, %35 ]
%19 = getelementptr inbounds [128 x double], [128 x double]* %0, i64 %9, i64 %17
%20 = load double, double* %19
%21 = fcmp ogt double %20, %18
%22 = select i1 %21, double %20, double %18
%23 = add nuw nsw i64 %17, 1
%24 = getelementptr inbounds [128 x double], [128 x double]* %0, i64 %9, i64 %23
%25 = load double, double* %24
%26 = fcmp ogt double %25, %22
%27 = select i1 %26, double %25, double %22
%28 = add nuw nsw i64 %17, 2
%29 = getelementptr inbounds [128 x double], [128 x double]* %0, i64 %9, i64 %28
%30 = load double, double* %29
%31 = fcmp ogt double %30, %27
%32 = select i1 %31, double %30, double %27
%33 = add nuw nsw i64 %17, 3
%34 = icmp eq i64 %33, 128
br i1 %34, label %13, label %35
35: ; preds = %16
%36 = getelementptr inbounds [128 x double], [128 x double]* %0, i64 %9, i64 %33
%37 = load double, double* %36
%38 = fcmp ogt double %37, %32
%39 = select i1 %38, double %37, double %32
%40 = add nuw nsw i64 %17, 4
br label %16
}