void layer_cloud(const double *cc, double *ll, long MaxLev, long MinLev,
                 long dimgp) {
  long i, k;
  double maxval, minval;
  double ZEPSEC;
  ZEPSEC = 1. - 1.0e-12;
  for (i = 0; i < dimgp; i++)
    ll[i] = 1. - cc[i + MaxLev * dimgp];
  for (k = MaxLev + 1; k <= MinLev; k++) {
    for (i = 0; i < dimgp; i++) {
      maxval = ((cc[i + (k - 1) * dimgp]) > (cc[i + k * dimgp])
                    ? (cc[i + (k - 1) * dimgp])
                    : (cc[i + k * dimgp]));
      minval = ((cc[i + (k - 1) * dimgp]) < (ZEPSEC) ? (cc[i + (k - 1) * dimgp])
                                                     : (ZEPSEC));
      ll[i] *= (1. - maxval) / (1. - minval);
    }
  }
  for (i = 0; i < dimgp; i++)
    ll[i] = 1. - ll[i];
}


x86 assembly (clang, -O0):
<layer_cloud>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  0xee0(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    117a <layer_cloud+0x7a>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  0xeb1(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    112d <layer_cloud+0x2d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     12f3 <layer_cloud+0x1f3>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    12dd <layer_cloud+0x1dd>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    $0x1,%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    120d <layer_cloud+0x10d>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    $0x1,%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    122b <layer_cloud+0x12b>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    $0x1,%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x50(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1288 <layer_cloud+0x188>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    $0x1,%rdx
imul   -0x28(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1292 <layer_cloud+0x192>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd64(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  0xd57(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    119c <layer_cloud+0x9c>
jmp    12e2 <layer_cloud+0x1e2>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1186 <layer_cloud+0x86>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    133c <layer_cloud+0x23c>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  0xcef(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12fb <layer_cloud+0x1fb>
pop    %rbp
ret

x86 assembly (clang, -O2):
<layer_cloud>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r15
test   %r8,%r8
jle    12d9 <layer_cloud+0x1d9>
mov    %r8,%r9
imul   %rdx,%r9
cmp    $0x4,%r8
jb     114c <layer_cloud+0x4c>
lea    0x8(,%rdx,8),%rax
imul   %r8,%rax
add    %rdi,%rax
cmp    %rsi,%rax
jbe    11fd <layer_cloud+0xfd>
lea    (%rsi,%r8,8),%rax
lea    (%rdi,%r9,8),%rbp
cmp    %rax,%rbp
jae    11fd <layer_cloud+0xfd>
xor    %eax,%eax
mov    %rax,%r10
not    %r10
add    %r8,%r10
mov    %r8,%rbx
and    $0x3,%rbx
je     1189 <layer_cloud+0x89>
lea    (%rdi,%r9,8),%rbp
movsd  0xeb4(%rip),%xmm0
nopl   0x0(%rax)
movapd %xmm0,%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
movsd  %xmm1,(%rsi,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rbx
jne    1170 <layer_cloud+0x70>
cmp    $0x3,%r10
jb     12d9 <layer_cloud+0x1d9>
lea    (%rdi,%r9,8),%rbp
add    $0x18,%rbp
movsd  0xe7d(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm0,%xmm1
subsd  -0x18(%rbp,%rax,8),%xmm1
movsd  %xmm1,(%rsi,%rax,8)
movapd %xmm0,%xmm1
subsd  -0x10(%rbp,%rax,8),%xmm1
movsd  %xmm1,0x8(%rsi,%rax,8)
movapd %xmm0,%xmm1
subsd  -0x8(%rbp,%rax,8),%xmm1
movsd  %xmm1,0x10(%rsi,%rax,8)
movapd %xmm0,%xmm1
subsd  0x0(%rbp,%rax,8),%xmm1
movsd  %xmm1,0x18(%rsi,%rax,8)
add    $0x4,%rax
cmp    %rax,%r8
jne    11b0 <layer_cloud+0xb0>
jmp    12d9 <layer_cloud+0x1d9>
mov    %r8,%rax
and    $0xfffffffffffffffc,%rax
lea    -0x4(%rax),%rbp
mov    %rbp,%r10
shr    $0x2,%r10
add    $0x1,%r10
test   %rbp,%rbp
je     15fb <layer_cloud+0x4fb>
mov    %r10,%rbx
and    $0xfffffffffffffffe,%rbx
lea    (%rdi,%r9,8),%r11
add    $0x30,%r11
xor    %ebp,%ebp
movapd 0xdcb(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movupd -0x30(%r11,%rbp,8),%xmm1
movupd -0x20(%r11,%rbp,8),%xmm2
movapd %xmm0,%xmm3
subpd  %xmm1,%xmm3
movapd %xmm0,%xmm1
subpd  %xmm2,%xmm1
movupd %xmm3,(%rsi,%rbp,8)
movupd %xmm1,0x10(%rsi,%rbp,8)
movupd -0x10(%r11,%rbp,8),%xmm1
movupd (%r11,%rbp,8),%xmm2
movapd %xmm0,%xmm3
subpd  %xmm1,%xmm3
movapd %xmm0,%xmm1
subpd  %xmm2,%xmm1
movupd %xmm3,0x20(%rsi,%rbp,8)
movupd %xmm1,0x30(%rsi,%rbp,8)
add    $0x8,%rbp
add    $0xfffffffffffffffe,%rbx
jne    1240 <layer_cloud+0x140>
test   $0x1,%r10b
je     12d0 <layer_cloud+0x1d0>
lea    (%r9,%rbp,1),%rbx
movupd (%rdi,%rbx,8),%xmm0
movupd 0x10(%rdi,%rbx,8),%xmm1
movapd 0xd47(%rip),%xmm2
movapd %xmm2,%xmm3
subpd  %xmm0,%xmm3
subpd  %xmm1,%xmm2
movupd %xmm3,(%rsi,%rbp,8)
movupd %xmm2,0x10(%rsi,%rbp,8)
cmp    %r8,%rax
jne    114e <layer_cloud+0x4e>
mov    %rdi,-0x38(%rsp)
cmp    %r15,%rdx
jge    14e4 <layer_cloud+0x3e4>
lea    (%rsi,%r8,8),%rax
mov    %rax,-0x8(%rsp)
lea    0x1(%rdx),%rdi
imul   %r8,%rdi
lea    0x10(,%rdx,8),%rax
imul   %r8,%rax
mov    %rax,-0x18(%rsp)
mov    %r8,%rax
imul   %rdx,%rax
lea    0x8(,%rdx,8),%rcx
imul   %r8,%rcx
mov    %rcx,-0x28(%rsp)
mov    %r8,%r10
and    $0xfffffffffffffffe,%r10
mov    -0x38(%rsp),%rbp
mov    %rax,-0x20(%rsp)
lea    0x0(,%rax,8),%rax
add    %rbp,%rax
lea    0x0(,%r8,8),%rcx
mov    %rdi,-0x10(%rsp)
lea    0x0(,%rdi,8),%rbx
add    %rbp,%rbx
xor    %r14d,%r14d
movsd  0xcc8(%rip),%xmm0
movsd  0xcb8(%rip),%xmm1
movapd 0xca0(%rip),%xmm2
movapd 0xc88(%rip),%xmm3
mov    %r15,-0x40(%rsp)
mov    -0x8(%rsp),%r12
jmp    13a3 <layer_cloud+0x2a3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
add    %rcx,%rax
add    %rcx,%rbx
cmp    %r15,%rdx
je     14e4 <layer_cloud+0x3e4>
add    $0x1,%rdx
test   %r8,%r8
jle    1390 <layer_cloud+0x290>
cmp    $0x1,%r8
jne    1400 <layer_cloud+0x300>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rax,%r13,8),%xmm4
movapd %xmm4,%xmm5
maxsd  (%rbx,%r13,8),%xmm5
minsd  %xmm0,%xmm4
movapd %xmm1,%xmm6
subsd  %xmm5,%xmm6
movapd %xmm1,%xmm5
subsd  %xmm4,%xmm5
divsd  %xmm5,%xmm6
mulsd  (%rsi,%r13,8),%xmm6
movsd  %xmm6,(%rsi,%r13,8)
add    $0x1,%r13
cmp    %r13,%r8
jne    13c0 <layer_cloud+0x2c0>
jmp    1390 <layer_cloud+0x290>
nop
mov    %rdx,-0x30(%rsp)
mov    %r14,%rbp
imul   %r8,%rbp
mov    -0x10(%rsp),%rdi
lea    (%rdi,%rbp,1),%r9
mov    -0x38(%rsp),%rdi
lea    (%rdi,%rbp,8),%r11
mov    -0x18(%rsp),%rdx
lea    (%r11,%rdx,1),%r13
add    -0x20(%rsp),%rbp
add    -0x28(%rsp),%r11
lea    (%rdi,%r9,8),%r9
cmp    %rsi,%r13
seta   %r13b
cmp    %r12,%r9
setb   %r15b
cmp    %rsi,%r11
seta   %r11b
lea    (%rdi,%rbp,8),%rbp
cmp    %r12,%rbp
setb   %r9b
test   %r15b,%r13b
jne    14d2 <layer_cloud+0x3d2>
mov    $0x0,%r13d
and    %r9b,%r11b
mov    -0x40(%rsp),%r15
mov    -0x30(%rsp),%rdx
jne    13c0 <layer_cloud+0x2c0>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rax,%rbp,8),%xmm4
movupd (%rbx,%rbp,8),%xmm5
movapd %xmm4,%xmm6
maxpd  %xmm5,%xmm6
minpd  %xmm2,%xmm4
movapd %xmm3,%xmm5
subpd  %xmm6,%xmm5
movapd %xmm3,%xmm6
subpd  %xmm4,%xmm6
divpd  %xmm6,%xmm5
movupd (%rsi,%rbp,8),%xmm4
mulpd  %xmm5,%xmm4
movupd %xmm4,(%rsi,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%r10
jne    1480 <layer_cloud+0x380>
mov    %r10,%r13
cmp    %r8,%r10
jne    13c0 <layer_cloud+0x2c0>
jmp    1390 <layer_cloud+0x290>
xor    %r13d,%r13d
mov    -0x40(%rsp),%r15
mov    -0x30(%rsp),%rdx
jmp    13c0 <layer_cloud+0x2c0>
test   %r8,%r8
jle    15e7 <layer_cloud+0x4e7>
cmp    $0x4,%r8
jae    14fa <layer_cloud+0x3fa>
xor    %eax,%eax
jmp    15bc <layer_cloud+0x4bc>
mov    %r8,%rax
and    $0xfffffffffffffffc,%rax
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     15f2 <layer_cloud+0x4f2>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %ecx,%ecx
movapd 0xad6(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movupd (%rsi,%rcx,8),%xmm1
movupd 0x10(%rsi,%rcx,8),%xmm2
movupd 0x20(%rsi,%rcx,8),%xmm3
movupd 0x30(%rsi,%rcx,8),%xmm4
movapd %xmm0,%xmm5
subpd  %xmm1,%xmm5
movapd %xmm0,%xmm1
subpd  %xmm2,%xmm1
movupd %xmm5,(%rsi,%rcx,8)
movupd %xmm1,0x10(%rsi,%rcx,8)
movapd %xmm0,%xmm1
subpd  %xmm3,%xmm1
movapd %xmm0,%xmm2
subpd  %xmm4,%xmm2
movupd %xmm1,0x20(%rsi,%rcx,8)
movupd %xmm2,0x30(%rsi,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%rdi
jne    1530 <layer_cloud+0x430>
test   $0x1,%dl
je     15b7 <layer_cloud+0x4b7>
movupd (%rsi,%rcx,8),%xmm0
movupd 0x10(%rsi,%rcx,8),%xmm1
movapd 0xa60(%rip),%xmm2
movapd %xmm2,%xmm3
subpd  %xmm0,%xmm3
subpd  %xmm1,%xmm2
movupd %xmm3,(%rsi,%rcx,8)
movupd %xmm2,0x10(%rsi,%rcx,8)
cmp    %r8,%rax
je     15e7 <layer_cloud+0x4e7>
movsd  0xa5c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm1
subsd  (%rsi,%rax,8),%xmm1
movsd  %xmm1,(%rsi,%rax,8)
add    $0x1,%rax
cmp    %rax,%r8
jne    15d0 <layer_cloud+0x4d0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ecx,%ecx
test   $0x1,%dl
jne    158d <layer_cloud+0x48d>
jmp    15b7 <layer_cloud+0x4b7>
xor    %ebp,%ebp
test   $0x1,%r10b
jne    12a2 <layer_cloud+0x1a2>
jmp    12d0 <layer_cloud+0x1d0>

LLVM IR (-O0):
define void @layer_cloud(double* %0, double* %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store double 0x3FEFFFFFFFFFDCD1, double* %15
store i64 0, i64* %11
br label %16
16: ; preds = %33, %5
%17 = load i64, i64* %11
%18 = load i64, i64* %10
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load double*, double** %6
%22 = load i64, i64* %11
%23 = load i64, i64* %8
%24 = load i64, i64* %10
%25 = mul nsw i64 %23, %24
%26 = add nsw i64 %22, %25
%27 = getelementptr inbounds double, double* %21, i64 %26
%28 = load double, double* %27
%29 = fsub double 1.000000e+00, %28
%30 = load double*, double** %7
%31 = load i64, i64* %11
%32 = getelementptr inbounds double, double* %30, i64 %31
store double %29, double* %32
br label %33
33: ; preds = %20
%34 = load i64, i64* %11
%35 = add nsw i64 %34, 1
store i64 %35, i64* %11
br label %16
36: ; preds = %16
%37 = load i64, i64* %8
%38 = add nsw i64 %37, 1
store i64 %38, i64* %12
br label %39
39: ; preds = %127, %36
%40 = load i64, i64* %12
%41 = load i64, i64* %9
%42 = icmp sle i64 %40, %41
br i1 %42, label %43, label %130
43: ; preds = %39
store i64 0, i64* %11
br label %44
44: ; preds = %123, %43
%45 = load i64, i64* %11
%46 = load i64, i64* %10
%47 = icmp slt i64 %45, %46
br i1 %47, label %48, label %126
48: ; preds = %44
%49 = load double*, double** %6
%50 = load i64, i64* %11
%51 = load i64, i64* %12
%52 = sub nsw i64 %51, 1
%53 = load i64, i64* %10
%54 = mul nsw i64 %52, %53
%55 = add nsw i64 %50, %54
%56 = getelementptr inbounds double, double* %49, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %6
%59 = load i64, i64* %11
%60 = load i64, i64* %12
%61 = load i64, i64* %10
%62 = mul nsw i64 %60, %61
%63 = add nsw i64 %59, %62
%64 = getelementptr inbounds double, double* %58, i64 %63
%65 = load double, double* %64
%66 = fcmp ogt double %57, %65
br i1 %66, label %67, label %77
67: ; preds = %48
%68 = load double*, double** %6
%69 = load i64, i64* %11
%70 = load i64, i64* %12
%71 = sub nsw i64 %70, 1
%72 = load i64, i64* %10
%73 = mul nsw i64 %71, %72
%74 = add nsw i64 %69, %73
%75 = getelementptr inbounds double, double* %68, i64 %74
%76 = load double, double* %75
br label %86
77: ; preds = %48
%78 = load double*, double** %6
%79 = load i64, i64* %11
%80 = load i64, i64* %12
%81 = load i64, i64* %10
%82 = mul nsw i64 %80, %81
%83 = add nsw i64 %79, %82
%84 = getelementptr inbounds double, double* %78, i64 %83
%85 = load double, double* %84
br label %86
86: ; preds = %77, %67
%87 = phi double [ %76, %67 ], [ %85, %77 ]
store double %87, double* %13
%88 = load double*, double** %6
%89 = load i64, i64* %11
%90 = load i64, i64* %12
%91 = sub nsw i64 %90, 1
%92 = load i64, i64* %10
%93 = mul nsw i64 %91, %92
%94 = add nsw i64 %89, %93
%95 = getelementptr inbounds double, double* %88, i64 %94
%96 = load double, double* %95
%97 = load double, double* %15
%98 = fcmp olt double %96, %97
br i1 %98, label %99, label %109
99: ; preds = %86
%100 = load double*, double** %6
%101 = load i64, i64* %11
%102 = load i64, i64* %12
%103 = sub nsw i64 %102, 1
%104 = load i64, i64* %10
%105 = mul nsw i64 %103, %104
%106 = add nsw i64 %101, %105
%107 = getelementptr inbounds double, double* %100, i64 %106
%108 = load double, double* %107
br label %111
109: ; preds = %86
%110 = load double, double* %15
br label %111
111: ; preds = %109, %99
%112 = phi double [ %108, %99 ], [ %110, %109 ]
store double %112, double* %14
%113 = load double, double* %13
%114 = fsub double 1.000000e+00, %113
%115 = load double, double* %14
%116 = fsub double 1.000000e+00, %115
%117 = fdiv double %114, %116
%118 = load double*, double** %7
%119 = load i64, i64* %11
%120 = getelementptr inbounds double, double* %118, i64 %119
%121 = load double, double* %120
%122 = fmul double %121, %117
store double %122, double* %120
br label %123
123: ; preds = %111
%124 = load i64, i64* %11
%125 = add nsw i64 %124, 1
store i64 %125, i64* %11
br label %44
126: ; preds = %44
br label %127
127: ; preds = %126
%128 = load i64, i64* %12
%129 = add nsw i64 %128, 1
store i64 %129, i64* %12
br label %39
130: ; preds = %39
store i64 0, i64* %11
br label %131
131: ; preds = %144, %130
%132 = load i64, i64* %11
%133 = load i64, i64* %10
%134 = icmp slt i64 %132, %133
br i1 %134, label %135, label %147
135: ; preds = %131
%136 = load double*, double** %7
%137 = load i64, i64* %11
%138 = getelementptr inbounds double, double* %136, i64 %137
%139 = load double, double* %138
%140 = fsub double 1.000000e+00, %139
%141 = load double*, double** %7
%142 = load i64, i64* %11
%143 = getelementptr inbounds double, double* %141, i64 %142
store double %140, double* %143
br label %144
144: ; preds = %135
%145 = load i64, i64* %11
%146 = add nsw i64 %145, 1
store i64 %146, i64* %11
br label %131
147: ; preds = %131
ret void
}

LLVM IR (-O2):
define void @layer_cloud(double* nocapture %0, double* nocapture %1, i64 %2, i64 %3, i64 %4) {
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %0 to i8*
%8 = icmp sgt i64 %4, 0
br i1 %8, label %9, label %103
9: ; preds = %5
%10 = mul nsw i64 %4, %2
%11 = icmp ult i64 %4, 4
br i1 %11, label %83, label %12
12: ; preds = %9
%13 = getelementptr double, double* %1, i64 %4
%14 = getelementptr double, double* %0, i64 %10
%15 = shl i64 %2, 3
%16 = add i64 %15, 8
%17 = mul i64 %16, %4
%18 = getelementptr i8, i8* %7, i64 %17
%19 = icmp ugt i8* %18, %6
%20 = icmp ult double* %14, %13
%21 = and i1 %19, %20
br i1 %21, label %83, label %22
22: ; preds = %12
%23 = and i64 %4, -4
%24 = add i64 %23, -4
%25 = lshr exact i64 %24, 2
%26 = add nuw nsw i64 %25, 1
%27 = and i64 %26, 1
%28 = icmp eq i64 %24, 0
br i1 %28, label %64, label %29
29: ; preds = %22
%30 = and i64 %26, 9223372036854775806
br label %31
31: ; preds = %31, %29
%32 = phi i64 [ 0, %29 ], [ %61, %31 ]
%33 = phi i64 [ 0, %29 ], [ %62, %31 ]
%34 = add nsw i64 %32, %10
%35 = getelementptr inbounds double, double* %0, i64 %34
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %35, i64 2
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %37
%42 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %40
%43 = getelementptr inbounds double, double* %1, i64 %32
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %41, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %42, <2 x double>* %46
%47 = or i64 %32, 4
%48 = add nsw i64 %47, %10
%49 = getelementptr inbounds double, double* %0, i64 %48
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = getelementptr inbounds double, double* %49, i64 2
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %51
%56 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %54
%57 = getelementptr inbounds double, double* %1, i64 %47
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %55, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %56, <2 x double>* %60
%61 = add nuw i64 %32, 8
%62 = add i64 %33, 2
%63 = icmp eq i64 %62, %30
br i1 %63, label %64, label %31
64: ; preds = %31, %22
%65 = phi i64 [ 0, %22 ], [ %61, %31 ]
%66 = icmp eq i64 %27, 0
br i1 %66, label %81, label %67
67: ; preds = %64
%68 = add nsw i64 %65, %10
%69 = getelementptr inbounds double, double* %0, i64 %68
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %71
%76 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %74
%77 = getelementptr inbounds double, double* %1, i64 %65
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %75, <2 x double>* %78
%79 = getelementptr inbounds double, double* %77, i64 2
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %76, <2 x double>* %80
br label %81
81: ; preds = %64, %67
%82 = icmp eq i64 %23, %4
br i1 %82, label %103, label %83
83: ; preds = %12, %9, %81
%84 = phi i64 [ 0, %12 ], [ 0, %9 ], [ %23, %81 ]
%85 = xor i64 %84, -1
%86 = add i64 %85, %4
%87 = and i64 %4, 3
%88 = icmp eq i64 %87, 0
br i1 %88, label %100, label %89
89: ; preds = %83, %89
%90 = phi i64 [ %97, %89 ], [ %84, %83 ]
%91 = phi i64 [ %98, %89 ], [ 0, %83 ]
%92 = add nsw i64 %90, %10
%93 = getelementptr inbounds double, double* %0, i64 %92
%94 = load double, double* %93
%95 = fsub double 1.000000e+00, %94
%96 = getelementptr inbounds double, double* %1, i64 %90
store double %95, double* %96
%97 = add nuw nsw i64 %90, 1
%98 = add i64 %91, 1
%99 = icmp eq i64 %98, %87
br i1 %99, label %100, label %89
100: ; preds = %89, %83
%101 = phi i64 [ %84, %83 ], [ %97, %89 ]
%102 = icmp ult i64 %86, 3
br i1 %102, label %103, label %118
103: ; preds = %100, %118, %81, %5
%104 = icmp slt i64 %2, %3
br i1 %104, label %105, label %201
105: ; preds = %103
%106 = getelementptr double, double* %1, i64 %4
%107 = add i64 %2, 1
%108 = mul i64 %107, %4
%109 = shl i64 %2, 3
%110 = add i64 %109, 16
%111 = mul i64 %110, %4
%112 = mul i64 %4, %2
%113 = add i64 %109, 8
%114 = mul i64 %113, %4
%115 = icmp eq i64 %4, 1
%116 = and i64 %4, -2
%117 = icmp eq i64 %116, %4
br label %148
118: ; preds = %100, %118
%119 = phi i64 [ %143, %118 ], [ %101, %100 ]
%120 = add nsw i64 %119, %10
%121 = getelementptr inbounds double, double* %0, i64 %120
%122 = load double, double* %121
%123 = fsub double 1.000000e+00, %122
%124 = getelementptr inbounds double, double* %1, i64 %119
store double %123, double* %124
%125 = add nuw nsw i64 %119, 1
%126 = add nsw i64 %125, %10
%127 = getelementptr inbounds double, double* %0, i64 %126
%128 = load double, double* %127
%129 = fsub double 1.000000e+00, %128
%130 = getelementptr inbounds double, double* %1, i64 %125
store double %129, double* %130
%131 = add nuw nsw i64 %119, 2
%132 = add nsw i64 %131, %10
%133 = getelementptr inbounds double, double* %0, i64 %132
%134 = load double, double* %133
%135 = fsub double 1.000000e+00, %134
%136 = getelementptr inbounds double, double* %1, i64 %131
store double %135, double* %136
%137 = add nuw nsw i64 %119, 3
%138 = add nsw i64 %137, %10
%139 = getelementptr inbounds double, double* %0, i64 %138
%140 = load double, double* %139
%141 = fsub double 1.000000e+00, %140
%142 = getelementptr inbounds double, double* %1, i64 %137
store double %141, double* %142
%143 = add nuw nsw i64 %119, 4
%144 = icmp eq i64 %143, %4
br i1 %144, label %103, label %118
145: ; preds = %258, %198, %148
%146 = icmp eq i64 %162, %3
%147 = add i64 %149, 1
br i1 %146, label %201, label %148
148: ; preds = %105, %145
%149 = phi i64 [ 0, %105 ], [ %147, %145 ]
%150 = phi i64 [ %2, %105 ], [ %162, %145 ]
%151 = mul i64 %149, %4
%152 = add i64 %108, %151
%153 = getelementptr double, double* %0, i64 %152
%154 = getelementptr double, double* %0, i64 %151
%155 = bitcast double* %154 to i8*
%156 = getelementptr i8, i8* %155, i64 %111
%157 = add i64 %112, %151
%158 = getelementptr double, double* %0, i64 %157
%159 = getelementptr double, double* %0, i64 %151
%160 = bitcast double* %159 to i8*
%161 = getelementptr i8, i8* %160, i64 %114
%162 = add nsw i64 %150, 1
br i1 %8, label %163, label %145
163: ; preds = %148
%164 = mul nsw i64 %150, %4
%165 = mul nsw i64 %162, %4
br i1 %115, label %199, label %166
166: ; preds = %163
%167 = icmp ugt i8* %156, %6
%168 = icmp ult double* %153, %106
%169 = and i1 %167, %168
%170 = icmp ugt i8* %161, %6
%171 = icmp ult double* %158, %106
%172 = and i1 %170, %171
%173 = or i1 %169, %172
br i1 %173, label %199, label %174
174: ; preds = %166, %174
%175 = phi i64 [ %196, %174 ], [ 0, %166 ]
%176 = add nsw i64 %175, %164
%177 = getelementptr inbounds double, double* %0, i64 %176
%178 = bitcast double* %177 to <2 x double>*
%179 = load <2 x double>, <2 x double>* %178
%180 = add nsw i64 %175, %165
%181 = getelementptr inbounds double, double* %0, i64 %180
%182 = bitcast double* %181 to <2 x double>*
%183 = load <2 x double>, <2 x double>* %182
%184 = fcmp ogt <2 x double> %179, %183
%185 = select <2 x i1> %184, <2 x double> %179, <2 x double> %183
%186 = fcmp olt <2 x double> %179, <double 0x3FEFFFFFFFFFDCD1, double 0x3FEFFFFFFFFFDCD1>
%187 = select <2 x i1> %186, <2 x double> %179, <2 x double> <double 0x3FEFFFFFFFFFDCD1, double 0x3FEFFFFFFFFFDCD1>
%188 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %185
%189 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %187
%190 = fdiv <2 x double> %188, %189
%191 = getelementptr inbounds double, double* %1, i64 %175
%192 = bitcast double* %191 to <2 x double>*
%193 = load <2 x double>, <2 x double>* %192
%194 = fmul <2 x double> %193, %190
%195 = bitcast double* %191 to <2 x double>*
store <2 x double> %194, <2 x double>* %195
%196 = add nuw i64 %175, 2
%197 = icmp eq i64 %196, %116
br i1 %197, label %198, label %174
198: ; preds = %174
br i1 %117, label %145, label %199
199: ; preds = %166, %163, %198
%200 = phi i64 [ 0, %166 ], [ 0, %163 ], [ %116, %198 ]
br label %258
201: ; preds = %145, %103
br i1 %8, label %202, label %285
202: ; preds = %201
%203 = icmp ult i64 %4, 4
br i1 %203, label %256, label %204
204: ; preds = %202
%205 = and i64 %4, -4
%206 = add i64 %205, -4
%207 = lshr exact i64 %206, 2
%208 = add nuw nsw i64 %207, 1
%209 = and i64 %208, 1
%210 = icmp eq i64 %206, 0
br i1 %210, label %240, label %211
211: ; preds = %204
%212 = and i64 %208, 9223372036854775806
br label %213
213: ; preds = %213, %211
%214 = phi i64 [ 0, %211 ], [ %237, %213 ]
%215 = phi i64 [ 0, %211 ], [ %238, %213 ]
%216 = getelementptr inbounds double, double* %1, i64 %214
%217 = bitcast double* %216 to <2 x double>*
%218 = load <2 x double>, <2 x double>* %217
%219 = getelementptr inbounds double, double* %216, i64 2
%220 = bitcast double* %219 to <2 x double>*
%221 = load <2 x double>, <2 x double>* %220
%222 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %218
%223 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %221
%224 = bitcast double* %216 to <2 x double>*
store <2 x double> %222, <2 x double>* %224
%225 = bitcast double* %219 to <2 x double>*
store <2 x double> %223, <2 x double>* %225
%226 = or i64 %214, 4
%227 = getelementptr inbounds double, double* %1, i64 %226
%228 = bitcast double* %227 to <2 x double>*
%229 = load <2 x double>, <2 x double>* %228
%230 = getelementptr inbounds double, double* %227, i64 2
%231 = bitcast double* %230 to <2 x double>*
%232 = load <2 x double>, <2 x double>* %231
%233 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %229
%234 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %232
%235 = bitcast double* %227 to <2 x double>*
store <2 x double> %233, <2 x double>* %235
%236 = bitcast double* %230 to <2 x double>*
store <2 x double> %234, <2 x double>* %236
%237 = add nuw i64 %214, 8
%238 = add i64 %215, 2
%239 = icmp eq i64 %238, %212
br i1 %239, label %240, label %213
240: ; preds = %213, %204
%241 = phi i64 [ 0, %204 ], [ %237, %213 ]
%242 = icmp eq i64 %209, 0
br i1 %242, label %254, label %243
243: ; preds = %240
%244 = getelementptr inbounds double, double* %1, i64 %241
%245 = bitcast double* %244 to <2 x double>*
%246 = load <2 x double>, <2 x double>* %245
%247 = getelementptr inbounds double, double* %244, i64 2
%248 = bitcast double* %247 to <2 x double>*
%249 = load <2 x double>, <2 x double>* %248
%250 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %246
%251 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %249
%252 = bitcast double* %244 to <2 x double>*
store <2 x double> %250, <2 x double>* %252
%253 = bitcast double* %247 to <2 x double>*
store <2 x double> %251, <2 x double>* %253
br label %254
254: ; preds = %240, %243
%255 = icmp eq i64 %205, %4
br i1 %255, label %285, label %256
256: ; preds = %202, %254
%257 = phi i64 [ 0, %202 ], [ %205, %254 ]
br label %278
258: ; preds = %199, %258
%259 = phi i64 [ %276, %258 ], [ %200, %199 ]
%260 = add nsw i64 %259, %164
%261 = getelementptr inbounds double, double* %0, i64 %260
%262 = load double, double* %261
%263 = add nsw i64 %259, %165
%264 = getelementptr inbounds double, double* %0, i64 %263
%265 = load double, double* %264
%266 = fcmp ogt double %262, %265
%267 = select i1 %266, double %262, double %265
%268 = fcmp olt double %262, 0x3FEFFFFFFFFFDCD1
%269 = select i1 %268, double %262, double 0x3FEFFFFFFFFFDCD1
%270 = fsub double 1.000000e+00, %267
%271 = fsub double 1.000000e+00, %269
%272 = fdiv double %270, %271
%273 = getelementptr inbounds double, double* %1, i64 %259
%274 = load double, double* %273
%275 = fmul double %274, %272
store double %275, double* %273
%276 = add nuw nsw i64 %259, 1
%277 = icmp eq i64 %276, %4
br i1 %277, label %145, label %258
278: ; preds = %256, %278
%279 = phi i64 [ %283, %278 ], [ %257, %256 ]
%280 = getelementptr inbounds double, double* %1, i64 %279
%281 = load double, double* %280
%282 = fsub double 1.000000e+00, %281
store double %282, double* %280
%283 = add nuw nsw i64 %279, 1
%284 = icmp eq i64 %283, %4
br i1 %284, label %285, label %278
285: ; preds = %278, %254, %201
ret void
}