#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 */
scalar_t__ calloc(int, int);
double distorter_bilinear_filtering(double *, double, double, int, int);
double distorter_mirror(double);
double distorter_rand();
int /*<<< orphan*/ free(double *);
double pow(int, int);
void distorter_create_noise_map(double *map_buffer, int map_n, int noise_n,
                                int max_d) {
  int i, row, col;
  int t_noise = noise_n * noise_n;
  double *c_map = (double *)calloc(t_noise, sizeof(double));
  double *p_map = c_map;
  for (i = 0; i < t_noise; i++) {
    *p_map = distorter_rand() * 2.0 - 1.0;
    p_map++;
  }
  int t_disp = 2 * max_d;
  double *disp = (double *)calloc(2 * max_d, sizeof(double));
  double *p_disp = disp;
  for (i = 0; i < t_disp; i++) {
    *p_disp = distorter_rand();
    p_disp++;
  }
  for (row = 0; row < map_n; row++) {
    for (col = 0; col < map_n; col++) {
      map_buffer[row * map_n + col] = 0.0;
    }
  }
  double w, p_r, p_c, c_pow;
  for (i = 0; i < max_d; i++) {
    double dr = disp[i * 2];
    double dc = disp[i * 2 + 1];
    if (i < max_d - 1) {
      w = 1.0 / pow(2, i + 1);
    } else {
      w = 1.0 / pow(2, i);
    }
    c_pow = pow(2, i);
    for (row = 0; row < map_n; row++) {
      p_r = ((double)row / (double)map_n) * c_pow;
      p_r = distorter_mirror(p_r + dr);
      for (col = 0; col < map_n; col++) {
        p_c = ((double)col / (double)map_n) * c_pow;
        p_c = distorter_mirror(p_c + dc);
        map_buffer[row * map_n + col] +=
            w * distorter_bilinear_filtering(c_map, p_c, p_r, noise_n, noise_n);
      }
    }
  }
  free(disp);
  free(c_map);
}


x86 assembly (clang, -O0):
<distorter_create_noise_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e7 <distorter_create_noise_map+0x87>
mov    $0x0,%al
call   1070 <distorter_rand@plt>
addsd  %xmm0,%xmm0
movsd  0xe47(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a2 <distorter_create_noise_map+0x42>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x1,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1248 <distorter_create_noise_map+0xe8>
mov    $0x0,%al
call   1070 <distorter_rand@plt>
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1213 <distorter_create_noise_map+0xb3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12a8 <distorter_create_noise_map+0x148>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1295 <distorter_create_noise_map+0x135>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1262 <distorter_create_noise_map+0x102>
jmp    129a <distorter_create_noise_map+0x13a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124f <distorter_create_noise_map+0xef>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    145f <distorter_create_noise_map+0x2ff>
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1326 <distorter_create_noise_map+0x1c6>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    $0x2,%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xce8(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1347 <distorter_create_noise_map+0x1e7>
mov    -0x18(%rbp),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xcc2(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    144c <distorter_create_noise_map+0x2ec>
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
call   1040 <distorter_mirror@plt>
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1439 <distorter_create_noise_map+0x2d9>
cvtsi2sdl -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x80(%rbp),%xmm0
call   1040 <distorter_mirror@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x30(%rbp),%rdi
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1080 <distorter_bilinear_filtering@plt>
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    139f <distorter_create_noise_map+0x23f>
jmp    143e <distorter_create_noise_map+0x2de>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1360 <distorter_create_noise_map+0x200>
jmp    1451 <distorter_create_noise_map+0x2f1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12af <distorter_create_noise_map+0x14f>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distorter_create_noise_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %rsi,0x8(%rsp)
mov    %rdi,0x20(%rsp)
mov    %edx,%ebp
imul   %edx,%ebp
mov    %ebp,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
test   %ebp,%ebp
je     11d2 <distorter_create_noise_map+0x62>
mov    %ebp,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <distorter_rand@plt>
addsd  %xmm0,%xmm0
addsd  0xe3d(%rip),%xmm0
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    11b0 <distorter_create_noise_map+0x40>
lea    (%r15,%r15,1),%r14d
mov    %r14d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%r13
mov    %r15,0x30(%rsp)
test   %r15d,%r15d
jle    1217 <distorter_create_noise_map+0xa7>
cmp    $0x2,%r14d
mov    $0x1,%r15d
cmovge %r14d,%r15d
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <distorter_rand@plt>
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %ebp,%r15d
jne    1200 <distorter_create_noise_map+0x90>
mov    %r13,0x48(%rsp)
mov    0x8(%rsp),%r15
mov    %r15d,%r14d
test   %r15d,%r15d
jle    1366 <distorter_create_noise_map+0x1f6>
lea    0x0(,%r14,8),%rax
mov    %rax,(%rsp)
lea    -0x1(%r14),%rax
mov    %r14d,%ecx
and    $0x3,%ecx
mov    %rcx,0x28(%rsp)
xor    %r15d,%r15d
cmp    $0x3,%rax
jae    1259 <distorter_create_noise_map+0xe9>
xor    %r13d,%r13d
jmp    131d <distorter_create_noise_map+0x1ad>
mov    %r14d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x18(%rsp)
mov    0x8(%rsp),%rcx
lea    (%rcx,%rcx,1),%eax
mov    %rax,0x10(%rsp)
lea    0x0(,%rcx,4),%eax
mov    %eax,0x40(%rsp)
lea    (%rcx,%rcx,2),%eax
mov    %rax,0x38(%rsp)
xor    %r13d,%r13d
mov    0x20(%rsp),%rbp
nopl   0x0(%rax)
movslq %r15d,%r15
lea    0x0(,%r15,8),%rdi
add    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
call   1050 <memset@plt>
mov    0x8(%rsp),%rax
add    %r15d,%eax
cltq
lea    0x0(,%rax,8),%rdi
add    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
call   1050 <memset@plt>
mov    0x10(%rsp),%rax
add    %r15d,%eax
cltq
lea    0x0(,%rax,8),%rdi
add    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
call   1050 <memset@plt>
mov    0x38(%rsp),%rax
add    %r15d,%eax
cltq
lea    0x0(,%rax,8),%rdi
add    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
call   1050 <memset@plt>
add    $0x4,%r13
add    0x40(%rsp),%r15d
cmp    %r13,0x18(%rsp)
jne    1290 <distorter_create_noise_map+0x120>
mov    0x28(%rsp),%rbp
test   %rbp,%rbp
mov    0x8(%rsp),%r15
mov    0x20(%rsp),%rcx
je     1366 <distorter_create_noise_map+0x1f6>
imul   %r15d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
movslq %r13d,%r13
lea    (%rcx,%r13,8),%rdi
xor    %esi,%esi
mov    (%rsp),%rdx
mov    %rcx,%r15
call   1050 <memset@plt>
mov    %r15,%rcx
mov    0x8(%rsp),%r15
add    %r15d,%r13d
add    $0xffffffffffffffff,%rbp
jne    1340 <distorter_create_noise_map+0x1d0>
mov    0x30(%rsp),%rax
test   %eax,%eax
jle    14d9 <distorter_create_noise_map+0x369>
lea    -0x1(%rax),%ecx
mov    %rcx,0x58(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x18(%rsp)
movslq %r15d,%rcx
mov    %eax,%eax
mov    %rax,0x50(%rsp)
shl    $0x3,%rcx
mov    %rcx,0x28(%rsp)
xor    %ebp,%ebp
jmp    13b9 <distorter_create_noise_map+0x249>
mov    0x60(%rsp),%rbp
add    $0x1,%rbp
cmp    0x50(%rsp),%rbp
mov    0x8(%rsp),%r15
je     14d9 <distorter_create_noise_map+0x369>
mov    %rbp,%rax
shl    $0x4,%rax
mov    0x48(%rsp),%rcx
movsd  (%rcx,%rax,1),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rcx,%rax,1),%xmm0
movsd  %xmm0,0x40(%rsp)
cmp    0x58(%rsp),%rbp
jae    13f0 <distorter_create_noise_map+0x280>
lea    0x1(%rbp),%esi
mov    $0x2,%edi
jmp    13f7 <distorter_create_noise_map+0x287>
nopl   (%rax)
mov    $0x2,%edi
mov    %ebp,%esi
call   1070 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%edi
mov    %rbp,0x60(%rsp)
mov    %ebp,%esi
call   1070 <pow@plt>
test   %r15d,%r15d
jle    13a0 <distorter_create_noise_map+0x230>
movapd %xmm0,%xmm1
movsd  0xbe4(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
mov    0x20(%rsp),%rbp
xor    %r13d,%r13d
movsd  %xmm1,(%rsp)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x30(%rsp),%xmm0
call   1040 <distorter_mirror@plt>
movsd  %xmm0,0x10(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
divsd  0x18(%rsp),%xmm0
mulsd  (%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
call   1040 <distorter_mirror@plt>
mov    %r12,%rdi
movsd  0x10(%rsp),%xmm1
mov    %ebx,%esi
mov    %ebx,%edx
call   1090 <distorter_bilinear_filtering@plt>
mulsd  0x38(%rsp),%xmm0
addsd  0x0(%rbp,%r15,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    1470 <distorter_create_noise_map+0x300>
add    $0x1,%r13
add    0x28(%rsp),%rbp
cmp    %r14,%r13
movsd  (%rsp),%xmm1
jne    1440 <distorter_create_noise_map+0x2d0>
jmp    13a0 <distorter_create_noise_map+0x230>
mov    0x48(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @distorter_create_noise_map(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%24 = load i32, i32* %7
%25 = load i32, i32* %7
%26 = mul nsw i32 %24, %25
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = call i64 @calloc(i32 %27, i32 8)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %13
%30 = load double*, double** %13
store double* %30, double** %14
store i32 0, i32* %9
br label %31
31: ; preds = %41, %4
%32 = load i32, i32* %9
%33 = load i32, i32* %12
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = call double (...) @distorter_rand()
%37 = call double @llvm.fmuladd.f64(double %36, double 2.000000e+00, double -1.000000e+00)
%38 = load double*, double** %14
store double %37, double* %38
%39 = load double*, double** %14
%40 = getelementptr inbounds double, double* %39, i32 1
store double* %40, double** %14
br label %41
41: ; preds = %35
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %31
44: ; preds = %31
%45 = load i32, i32* %8
%46 = mul nsw i32 2, %45
store i32 %46, i32* %15
%47 = load i32, i32* %8
%48 = mul nsw i32 2, %47
%49 = call i64 @calloc(i32 %48, i32 8)
%50 = inttoptr i64 %49 to double*
store double* %50, double** %16
%51 = load double*, double** %16
store double* %51, double** %17
store i32 0, i32* %9
br label %52
52: ; preds = %61, %44
%53 = load i32, i32* %9
%54 = load i32, i32* %15
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %64
56: ; preds = %52
%57 = call double (...) @distorter_rand()
%58 = load double*, double** %17
store double %57, double* %58
%59 = load double*, double** %17
%60 = getelementptr inbounds double, double* %59, i32 1
store double* %60, double** %17
br label %61
61: ; preds = %56
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %52
64: ; preds = %52
store i32 0, i32* %10
br label %65
65: ; preds = %87, %64
%66 = load i32, i32* %10
%67 = load i32, i32* %6
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %90
69: ; preds = %65
store i32 0, i32* %11
br label %70
70: ; preds = %83, %69
%71 = load i32, i32* %11
%72 = load i32, i32* %6
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %86
74: ; preds = %70
%75 = load double*, double** %5
%76 = load i32, i32* %10
%77 = load i32, i32* %6
%78 = mul nsw i32 %76, %77
%79 = load i32, i32* %11
%80 = add nsw i32 %78, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %75, i64 %81
store double 0.000000e+00, double* %82
br label %83
83: ; preds = %74
%84 = load i32, i32* %11
%85 = add nsw i32 %84, 1
store i32 %85, i32* %11
br label %70
86: ; preds = %70
br label %87
87: ; preds = %86
%88 = load i32, i32* %10
%89 = add nsw i32 %88, 1
store i32 %89, i32* %10
br label %65
90: ; preds = %65
store i32 0, i32* %9
br label %91
91: ; preds = %182, %90
%92 = load i32, i32* %9
%93 = load i32, i32* %8
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %185
95: ; preds = %91
%96 = load double*, double** %16
%97 = load i32, i32* %9
%98 = mul nsw i32 %97, 2
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %96, i64 %99
%101 = load double, double* %100
store double %101, double* %22
%102 = load double*, double** %16
%103 = load i32, i32* %9
%104 = mul nsw i32 %103, 2
%105 = add nsw i32 %104, 1
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %102, i64 %106
%108 = load double, double* %107
store double %108, double* %23
%109 = load i32, i32* %9
%110 = load i32, i32* %8
%111 = sub nsw i32 %110, 1
%112 = icmp slt i32 %109, %111
br i1 %112, label %113, label %118
113: ; preds = %95
%114 = load i32, i32* %9
%115 = add nsw i32 %114, 1
%116 = call double @pow(i32 2, i32 %115)
%117 = fdiv double 1.000000e+00, %116
store double %117, double* %18
br label %122
118: ; preds = %95
%119 = load i32, i32* %9
%120 = call double @pow(i32 2, i32 %119)
%121 = fdiv double 1.000000e+00, %120
store double %121, double* %18
br label %122
122: ; preds = %118, %113
%123 = load i32, i32* %9
%124 = call double @pow(i32 2, i32 %123)
store double %124, double* %21
store i32 0, i32* %10
br label %125
125: ; preds = %178, %122
%126 = load i32, i32* %10
%127 = load i32, i32* %6
%128 = icmp slt i32 %126, %127
br i1 %128, label %129, label %181
129: ; preds = %125
%130 = load i32, i32* %10
%131 = sitofp i32 %130 to double
%132 = load i32, i32* %6
%133 = sitofp i32 %132 to double
%134 = fdiv double %131, %133
%135 = load double, double* %21
%136 = fmul double %134, %135
store double %136, double* %19
%137 = load double, double* %19
%138 = load double, double* %22
%139 = fadd double %137, %138
%140 = call double @distorter_mirror(double %139)
store double %140, double* %19
store i32 0, i32* %11
br label %141
141: ; preds = %174, %129
%142 = load i32, i32* %11
%143 = load i32, i32* %6
%144 = icmp slt i32 %142, %143
br i1 %144, label %145, label %177
145: ; preds = %141
%146 = load i32, i32* %11
%147 = sitofp i32 %146 to double
%148 = load i32, i32* %6
%149 = sitofp i32 %148 to double
%150 = fdiv double %147, %149
%151 = load double, double* %21
%152 = fmul double %150, %151
store double %152, double* %20
%153 = load double, double* %20
%154 = load double, double* %23
%155 = fadd double %153, %154
%156 = call double @distorter_mirror(double %155)
store double %156, double* %20
%157 = load double, double* %18
%158 = load double*, double** %13
%159 = load double, double* %20
%160 = load double, double* %19
%161 = load i32, i32* %7
%162 = load i32, i32* %7
%163 = call double @distorter_bilinear_filtering(double* %158, double %159, double %160, i32 %161, i32 %162)
%164 = load double*, double** %5
%165 = load i32, i32* %10
%166 = load i32, i32* %6
%167 = mul nsw i32 %165, %166
%168 = load i32, i32* %11
%169 = add nsw i32 %167, %168
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %164, i64 %170
%172 = load double, double* %171
%173 = call double @llvm.fmuladd.f64(double %157, double %163, double %172)
store double %173, double* %171
br label %174
174: ; preds = %145
%175 = load i32, i32* %11
%176 = add nsw i32 %175, 1
store i32 %176, i32* %11
br label %141
177: ; preds = %141
br label %178
178: ; preds = %177
%179 = load i32, i32* %10
%180 = add nsw i32 %179, 1
store i32 %180, i32* %10
br label %125
181: ; preds = %125
br label %182
182: ; preds = %181
%183 = load i32, i32* %9
%184 = add nsw i32 %183, 1
store i32 %184, i32* %9
br label %91
185: ; preds = %91
%186 = load double*, double** %16
%187 = call i32 @free(double* %186)
%188 = load double*, double** %13
%189 = call i32 @free(double* %188)
ret void
}

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