#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int floor(double);
double *malloc(int);
void build_grid(int lgfiltre, int nfcns, const double *bands, int nbands,
                int lgrid, int nodd, const double *dev, const double *weight,
                double **FreqGrille, int *taillegrilledense, double **des,
                double **wt) {
  int np = floor(0.5 + (nfcns * bands[1]) / (0.5 + (bands[1] - bands[2])));
  if (np == 0)
    np++;
  int ns = nfcns + 1 - np;
  if (ns <= 1)
    ns = 2;
  while ((np + ns - 1) * lgrid + 2 <= lgfiltre)
    lgrid *= 2;
  *taillegrilledense = (np + ns - 1) * lgrid + 2;
  *FreqGrille = malloc(*taillegrilledense * sizeof(double));
  *des = malloc(*taillegrilledense * sizeof(double));
  *wt = malloc(*taillegrilledense * sizeof(double));
  double delf = 1.0 / (lgrid * np);
  for (int k = 0; k < np * lgrid + 1; k++) {
    (*FreqGrille)[k] = k * bands[1] * delf;
    (*des)[k] = dev[0];
    (*wt)[k] = weight[0];
  }
  delf = 1.0 / ((ns - 1) * lgrid);
  for (int k = 0; k < (ns - 1) * lgrid + 1; k++) {
    (*FreqGrille)[(np * lgrid) + 1 + k] =
        bands[2] + k * (bands[3] - bands[2]) * delf;
    (*des)[(np * lgrid) + 1 + k] = dev[1];
    (*wt)[(np * lgrid) + 1 + k] = weight[1];
  }
  if (nodd == 0 && (*FreqGrille)[*taillegrilledense - 1] > (0.5 - delf))
    (*taillegrilledense)--;
}


x86 assembly (clang, -O0):
<build_grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm2
movsd  0xe83(%rip),%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11ac <build_grid+0x8c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jg     11c9 <build_grid+0xa9>
movl   $0x2,-0x24(%rbp)
jmp    11ce <build_grid+0xae>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x1,%eax
imul   -0x18(%rbp),%eax
add    $0x2,%eax
cmp    -0x4(%rbp),%eax
jg     11f5 <build_grid+0xd5>
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ce <build_grid+0xae>
mov    -0x20(%rbp),%ecx
add    -0x24(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x18(%rbp),%ecx
add    $0x2,%ecx
mov    0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xd96(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    12f8 <build_grid+0x1d8>
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x30(%rbp),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x38(%rbp),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1282 <build_grid+0x162>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
imul   -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xcfa(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    13db <build_grid+0x2bb>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
cvtsi2sdl -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    0x30(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    0x38(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    131e <build_grid+0x1fe>
cmpl   $0x0,-0x1c(%rbp)
jne    141f <build_grid+0x2ff>
mov    0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x28(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xbfb(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    141f <build_grid+0x2ff>
mov    0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_grid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,%ebx
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%r13d
cvtsi2sd %esi,%xmm0
movsd  0x8(%rdx),%xmm1
mulsd  %xmm1,%xmm0
subsd  0x10(%rdx),%xmm1
movsd  0xea7(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
call   1040 <floor@plt>
test   %eax,%eax
mov    $0x1,%edx
cmovne %eax,%edx
sub    %edx,%r12d
add    $0x1,%r12d
cmp    $0x3,%r12d
mov    $0x2,%ecx
cmovge %r12d,%ecx
mov    %rdx,0x10(%rsp)
lea    (%rcx,%rdx,1),%eax
add    $0xffffffff,%eax
add    $0xffffffff,%ecx
mov    %ecx,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %ebx,%r14d
mov    %ebx,%r12d
imul   %eax,%r12d
lea    0x2(%r12),%ebp
lea    (%r14,%r14,1),%ebx
cmp    %r13d,%ebp
jle    11a0 <build_grid+0x80>
mov    0x68(%rsp),%r13
mov    %ebp,0x0(%r13)
shl    $0x3,%ebp
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    0x60(%rsp),%rbx
mov    %rax,(%rbx)
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    0x70(%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    0x78(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x10(%rsp),%r10
imul   %r14d,%r10d
movsd  0xe06(%rip),%xmm0
test   %r10d,%r10d
mov    0x58(%rsp),%r9
mov    0x50(%rsp),%rbp
js     12e8 <build_grid+0x1c8>
xorps  %xmm2,%xmm2
cvtsi2sd %r10d,%xmm2
movapd %xmm0,%xmm1
divsd  %xmm2,%xmm1
mov    (%rbx),%rdx
mov    0x70(%rsp),%rcx
mov    (%rcx),%rcx
lea    0x1(%r10),%r8d
test   %r10d,%r10d
je     13ab <build_grid+0x28b>
mov    %r8d,%edi
and    $0xfffffffe,%edi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm2,%xmm2
cvtsi2sd %esi,%xmm2
mulsd  0x8(%r15),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,(%rdx,%rsi,8)
movsd  0x0(%rbp),%xmm2
movsd  %xmm2,(%rcx,%rsi,8)
movsd  (%r9),%xmm2
movsd  %xmm2,(%rax,%rsi,8)
lea    0x1(%rsi),%ebx
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
mulsd  0x8(%r15),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rdx,%rsi,8)
movsd  0x0(%rbp),%xmm2
movsd  %xmm2,0x8(%rcx,%rsi,8)
movsd  (%r9),%xmm2
movsd  %xmm2,0x8(%rax,%rsi,8)
add    $0x2,%rsi
cmp    %rdi,%rsi
jne    1250 <build_grid+0x130>
mov    0x60(%rsp),%rbx
test   $0x1,%r8b
je     12e8 <build_grid+0x1c8>
xorps  %xmm2,%xmm2
cvtsi2sd %esi,%xmm2
mulsd  0x8(%r15),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%rdx,%rsi,8)
movsd  0x0(%rbp),%xmm1
movsd  %xmm1,(%rcx,%rsi,8)
movsd  (%r9),%xmm1
movsd  %xmm1,(%rax,%rsi,8)
imul   0x8(%rsp),%r14d
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
test   %r14d,%r14d
js     136f <build_grid+0x24f>
mov    (%rbx),%rcx
mov    0x70(%rsp),%rdx
mov    (%rdx),%rdx
add    $0x1,%r14d
add    $0x1,%r10d
xor    %edi,%edi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
movsd  0x10(%r15),%xmm2
movsd  0x18(%r15),%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
add    $0x1,%rsi
add    %r10d,%edi
movslq %edi,%rdi
movsd  %xmm3,(%rcx,%rdi,8)
movsd  0x8(%rbp),%xmm1
movsd  %xmm1,(%rdx,%rdi,8)
movsd  0x8(%r9),%xmm1
movsd  %xmm1,(%rax,%rdi,8)
mov    %rsi,%rdi
cmp    %rsi,%r14
jne    1320 <build_grid+0x200>
cmpl   $0x0,0xc(%rsp)
jne    139c <build_grid+0x27c>
mov    (%rbx),%rax
movslq %r12d,%rcx
movsd  0x8(%rax,%rcx,8),%xmm1
movsd  0xc76(%rip),%xmm2
subsd  %xmm0,%xmm2
ucomisd %xmm2,%xmm1
jbe    139c <build_grid+0x27c>
add    $0x1,%r12d
mov    %r12d,0x0(%r13)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %esi,%esi
test   $0x1,%r8b
jne    12be <build_grid+0x19e>
jmp    12e8 <build_grid+0x1c8>

LLVM IR (-O0):
define void @build_grid(i32 %0, i32 %1, double* %2, i32 %3, i32 %4, i32 %5, double* %6, double* %7, double** %8, i32* %9, double** %10, double** %11) {
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double*
%20 = alloca double*
%21 = alloca double**
%22 = alloca i32*
%23 = alloca double**
%24 = alloca double**
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
store i32 %0, i32* %13
store i32 %1, i32* %14
store double* %2, double** %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store double* %6, double** %19
store double* %7, double** %20
store double** %8, double*** %21
store i32* %9, i32** %22
store double** %10, double*** %23
store double** %11, double*** %24
%30 = load i32, i32* %14
%31 = sitofp i32 %30 to double
%32 = load double*, double** %15
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = fmul double %31, %34
%36 = load double*, double** %15
%37 = getelementptr inbounds double, double* %36, i64 1
%38 = load double, double* %37
%39 = load double*, double** %15
%40 = getelementptr inbounds double, double* %39, i64 2
%41 = load double, double* %40
%42 = fsub double %38, %41
%43 = fadd double 5.000000e-01, %42
%44 = fdiv double %35, %43
%45 = fadd double 5.000000e-01, %44
%46 = call i32 @floor(double %45)
store i32 %46, i32* %25
%47 = load i32, i32* %25
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %12
%50 = load i32, i32* %25
%51 = add nsw i32 %50, 1
store i32 %51, i32* %25
br label %52
52: ; preds = %49, %12
%53 = load i32, i32* %14
%54 = add nsw i32 %53, 1
%55 = load i32, i32* %25
%56 = sub nsw i32 %54, %55
store i32 %56, i32* %26
%57 = load i32, i32* %26
%58 = icmp sle i32 %57, 1
br i1 %58, label %59, label %60
59: ; preds = %52
store i32 2, i32* %26
br label %60
60: ; preds = %59, %52
br label %61
61: ; preds = %71, %60
%62 = load i32, i32* %25
%63 = load i32, i32* %26
%64 = add nsw i32 %62, %63
%65 = sub nsw i32 %64, 1
%66 = load i32, i32* %17
%67 = mul nsw i32 %65, %66
%68 = add nsw i32 %67, 2
%69 = load i32, i32* %13
%70 = icmp sle i32 %68, %69
br i1 %70, label %71, label %74
71: ; preds = %61
%72 = load i32, i32* %17
%73 = mul nsw i32 %72, 2
store i32 %73, i32* %17
br label %61
74: ; preds = %61
%75 = load i32, i32* %25
%76 = load i32, i32* %26
%77 = add nsw i32 %75, %76
%78 = sub nsw i32 %77, 1
%79 = load i32, i32* %17
%80 = mul nsw i32 %78, %79
%81 = add nsw i32 %80, 2
%82 = load i32*, i32** %22
store i32 %81, i32* %82
%83 = load i32*, i32** %22
%84 = load i32, i32* %83
%85 = sext i32 %84 to i64
%86 = mul i64 %85, 8
%87 = trunc i64 %86 to i32
%88 = call double* @malloc(i32 %87)
%89 = load double**, double*** %21
store double* %88, double** %89
%90 = load i32*, i32** %22
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = mul i64 %92, 8
%94 = trunc i64 %93 to i32
%95 = call double* @malloc(i32 %94)
%96 = load double**, double*** %23
store double* %95, double** %96
%97 = load i32*, i32** %22
%98 = load i32, i32* %97
%99 = sext i32 %98 to i64
%100 = mul i64 %99, 8
%101 = trunc i64 %100 to i32
%102 = call double* @malloc(i32 %101)
%103 = load double**, double*** %24
store double* %102, double** %103
%104 = load i32, i32* %17
%105 = load i32, i32* %25
%106 = mul nsw i32 %104, %105
%107 = sitofp i32 %106 to double
%108 = fdiv double 1.000000e+00, %107
store double %108, double* %27
store i32 0, i32* %28
br label %109
109: ; preds = %146, %74
%110 = load i32, i32* %28
%111 = load i32, i32* %25
%112 = load i32, i32* %17
%113 = mul nsw i32 %111, %112
%114 = add nsw i32 %113, 1
%115 = icmp slt i32 %110, %114
br i1 %115, label %116, label %149
116: ; preds = %109
%117 = load i32, i32* %28
%118 = sitofp i32 %117 to double
%119 = load double*, double** %15
%120 = getelementptr inbounds double, double* %119, i64 1
%121 = load double, double* %120
%122 = fmul double %118, %121
%123 = load double, double* %27
%124 = fmul double %122, %123
%125 = load double**, double*** %21
%126 = load double*, double** %125
%127 = load i32, i32* %28
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %126, i64 %128
store double %124, double* %129
%130 = load double*, double** %19
%131 = getelementptr inbounds double, double* %130, i64 0
%132 = load double, double* %131
%133 = load double**, double*** %23
%134 = load double*, double** %133
%135 = load i32, i32* %28
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds double, double* %134, i64 %136
store double %132, double* %137
%138 = load double*, double** %20
%139 = getelementptr inbounds double, double* %138, i64 0
%140 = load double, double* %139
%141 = load double**, double*** %24
%142 = load double*, double** %141
%143 = load i32, i32* %28
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
store double %140, double* %145
br label %146
146: ; preds = %116
%147 = load i32, i32* %28
%148 = add nsw i32 %147, 1
store i32 %148, i32* %28
br label %109
149: ; preds = %109
%150 = load i32, i32* %26
%151 = sub nsw i32 %150, 1
%152 = load i32, i32* %17
%153 = mul nsw i32 %151, %152
%154 = sitofp i32 %153 to double
%155 = fdiv double 1.000000e+00, %154
store double %155, double* %27
store i32 0, i32* %29
br label %156
156: ; preds = %216, %149
%157 = load i32, i32* %29
%158 = load i32, i32* %26
%159 = sub nsw i32 %158, 1
%160 = load i32, i32* %17
%161 = mul nsw i32 %159, %160
%162 = add nsw i32 %161, 1
%163 = icmp slt i32 %157, %162
br i1 %163, label %164, label %219
164: ; preds = %156
%165 = load double*, double** %15
%166 = getelementptr inbounds double, double* %165, i64 2
%167 = load double, double* %166
%168 = load i32, i32* %29
%169 = sitofp i32 %168 to double
%170 = load double*, double** %15
%171 = getelementptr inbounds double, double* %170, i64 3
%172 = load double, double* %171
%173 = load double*, double** %15
%174 = getelementptr inbounds double, double* %173, i64 2
%175 = load double, double* %174
%176 = fsub double %172, %175
%177 = fmul double %169, %176
%178 = load double, double* %27
%179 = call double @llvm.fmuladd.f64(double %177, double %178, double %167)
%180 = load double**, double*** %21
%181 = load double*, double** %180
%182 = load i32, i32* %25
%183 = load i32, i32* %17
%184 = mul nsw i32 %182, %183
%185 = add nsw i32 %184, 1
%186 = load i32, i32* %29
%187 = add nsw i32 %185, %186
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds double, double* %181, i64 %188
store double %179, double* %189
%190 = load double*, double** %19
%191 = getelementptr inbounds double, double* %190, i64 1
%192 = load double, double* %191
%193 = load double**, double*** %23
%194 = load double*, double** %193
%195 = load i32, i32* %25
%196 = load i32, i32* %17
%197 = mul nsw i32 %195, %196
%198 = add nsw i32 %197, 1
%199 = load i32, i32* %29
%200 = add nsw i32 %198, %199
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds double, double* %194, i64 %201
store double %192, double* %202
%203 = load double*, double** %20
%204 = getelementptr inbounds double, double* %203, i64 1
%205 = load double, double* %204
%206 = load double**, double*** %24
%207 = load double*, double** %206
%208 = load i32, i32* %25
%209 = load i32, i32* %17
%210 = mul nsw i32 %208, %209
%211 = add nsw i32 %210, 1
%212 = load i32, i32* %29
%213 = add nsw i32 %211, %212
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds double, double* %207, i64 %214
store double %205, double* %215
br label %216
216: ; preds = %164
%217 = load i32, i32* %29
%218 = add nsw i32 %217, 1
store i32 %218, i32* %29
br label %156
219: ; preds = %156
%220 = load i32, i32* %18
%221 = icmp eq i32 %220, 0
br i1 %221, label %222, label %238
222: ; preds = %219
%223 = load double**, double*** %21
%224 = load double*, double** %223
%225 = load i32*, i32** %22
%226 = load i32, i32* %225
%227 = sub nsw i32 %226, 1
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds double, double* %224, i64 %228
%230 = load double, double* %229
%231 = load double, double* %27
%232 = fsub double 5.000000e-01, %231
%233 = fcmp ogt double %230, %232
br i1 %233, label %234, label %238
234: ; preds = %222
%235 = load i32*, i32** %22
%236 = load i32, i32* %235
%237 = add nsw i32 %236, -1
store i32 %237, i32* %235
br label %238
238: ; preds = %234, %222, %219
ret void
}

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