#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 */
double fBC(double, double);
double **setBoundaries2D(double **array2D, double dx, double dy, int nX,
                         int nY) {
  int i, j;
  double x, y;
  for (j = 0; j < nY; j++) {
    x = 0;
    y = j * dy;
    array2D[0][j] = fBC(x, y);
  }
  for (j = 0; j < nY; j++) {
    x = (nX - 1) * dx;
    y = j * dy;
    array2D[nX - 1][j] = fBC(x, y);
  }
  for (i = 0; i < nX; i++) {
    x = i * dx;
    y = 0;
    array2D[i][0] = fBC(x, y);
  }
  for (i = 0; i < nX; i++) {
    x = i * dx;
    y = (nY - 1) * dy;
    array2D[i][nY - 1] = fBC(x, y);
  }
  return array2D;
}


x86 assembly (clang, -O0):
<setBoundaries2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %edx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1183 <setBoundaries2D+0x73>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <fBC@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1133 <setBoundaries2D+0x23>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f0 <setBoundaries2D+0xe0>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <fBC@plt>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118a <setBoundaries2D+0x7a>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1247 <setBoundaries2D+0x137>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <fBC@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f7 <setBoundaries2D+0xe7>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12b4 <setBoundaries2D+0x1a4>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <fBC@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124e <setBoundaries2D+0x13e>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBoundaries2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %esi,%r14d
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
test   %edx,%edx
movsd  %xmm1,(%rsp)
jle    11cd <setBoundaries2D+0xbd>
movapd %xmm1,%xmm2
mov    %r15d,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
call   1030 <fBC@plt>
movsd  (%rsp),%xmm2
mov    (%rbx),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1150 <setBoundaries2D+0x40>
test   %r15d,%r15d
jle    11cd <setBoundaries2D+0xbd>
lea    -0x1(%r14),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movslq %eax,%r12
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <fBC@plt>
movsd  (%rsp),%xmm2
mov    (%rbx,%r12,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11a0 <setBoundaries2D+0x90>
test   %r14d,%r14d
movsd  0x8(%rsp),%xmm1
jle    126e <setBoundaries2D+0x15e>
mov    %r14d,%r12d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
call   1030 <fBC@plt>
movsd  0x8(%rsp),%xmm1
mov    (%rbx,%rbp,8),%rax
movsd  %xmm0,(%rax)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11f0 <setBoundaries2D+0xe0>
test   %r14d,%r14d
movsd  (%rsp),%xmm0
jle    126e <setBoundaries2D+0x15e>
add    $0xffffffff,%r15d
xorps  %xmm2,%xmm2
cvtsi2sd %r15d,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movslq %r15d,%r14
xor    %ebp,%ebp
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
call   1030 <fBC@plt>
movsd  0x8(%rsp),%xmm1
mov    (%rbx,%rbp,8),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1240 <setBoundaries2D+0x130>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @setBoundaries2D(double** %0, double %1, double %2, i32 %3, i32 %4) {
%6 = alloca double**
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
store double** %0, double*** %6
store double %1, double* %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %12
br label %15
15: ; preds = %33, %5
%16 = load i32, i32* %12
%17 = load i32, i32* %10
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %36
19: ; preds = %15
store double 0.000000e+00, double* %13
%20 = load i32, i32* %12
%21 = sitofp i32 %20 to double
%22 = load double, double* %8
%23 = fmul double %21, %22
store double %23, double* %14
%24 = load double, double* %13
%25 = load double, double* %14
%26 = call double @fBC(double %24, double %25)
%27 = load double**, double*** %6
%28 = getelementptr inbounds double*, double** %27, i64 0
%29 = load double*, double** %28
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %26, double* %32
br label %33
33: ; preds = %19
%34 = load i32, i32* %12
%35 = add nsw i32 %34, 1
store i32 %35, i32* %12
br label %15
36: ; preds = %15
store i32 0, i32* %12
br label %37
37: ; preds = %63, %36
%38 = load i32, i32* %12
%39 = load i32, i32* %10
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %66
41: ; preds = %37
%42 = load i32, i32* %9
%43 = sub nsw i32 %42, 1
%44 = sitofp i32 %43 to double
%45 = load double, double* %7
%46 = fmul double %44, %45
store double %46, double* %13
%47 = load i32, i32* %12
%48 = sitofp i32 %47 to double
%49 = load double, double* %8
%50 = fmul double %48, %49
store double %50, double* %14
%51 = load double, double* %13
%52 = load double, double* %14
%53 = call double @fBC(double %51, double %52)
%54 = load double**, double*** %6
%55 = load i32, i32* %9
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double*, double** %54, i64 %57
%59 = load double*, double** %58
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double %53, double* %62
br label %63
63: ; preds = %41
%64 = load i32, i32* %12
%65 = add nsw i32 %64, 1
store i32 %65, i32* %12
br label %37
66: ; preds = %37
store i32 0, i32* %11
br label %67
67: ; preds = %85, %66
%68 = load i32, i32* %11
%69 = load i32, i32* %9
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %88
71: ; preds = %67
%72 = load i32, i32* %11
%73 = sitofp i32 %72 to double
%74 = load double, double* %7
%75 = fmul double %73, %74
store double %75, double* %13
store double 0.000000e+00, double* %14
%76 = load double, double* %13
%77 = load double, double* %14
%78 = call double @fBC(double %76, double %77)
%79 = load double**, double*** %6
%80 = load i32, i32* %11
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double*, double** %79, i64 %81
%83 = load double*, double** %82
%84 = getelementptr inbounds double, double* %83, i64 0
store double %78, double* %84
br label %85
85: ; preds = %71
%86 = load i32, i32* %11
%87 = add nsw i32 %86, 1
store i32 %87, i32* %11
br label %67
88: ; preds = %67
store i32 0, i32* %11
br label %89
89: ; preds = %115, %88
%90 = load i32, i32* %11
%91 = load i32, i32* %9
%92 = icmp slt i32 %90, %91
br i1 %92, label %93, label %118
93: ; preds = %89
%94 = load i32, i32* %11
%95 = sitofp i32 %94 to double
%96 = load double, double* %7
%97 = fmul double %95, %96
store double %97, double* %13
%98 = load i32, i32* %10
%99 = sub nsw i32 %98, 1
%100 = sitofp i32 %99 to double
%101 = load double, double* %8
%102 = fmul double %100, %101
store double %102, double* %14
%103 = load double, double* %13
%104 = load double, double* %14
%105 = call double @fBC(double %103, double %104)
%106 = load double**, double*** %6
%107 = load i32, i32* %11
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double*, double** %106, i64 %108
%110 = load double*, double** %109
%111 = load i32, i32* %10
%112 = sub nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %110, i64 %113
store double %105, double* %114
br label %115
115: ; preds = %93
%116 = load i32, i32* %11
%117 = add nsw i32 %116, 1
store i32 %117, i32* %11
br label %89
118: ; preds = %89
%119 = load double**, double*** %6
ret double** %119
}

LLVM IR (-O2):
define double** @setBoundaries2D(double** returned %0, double %1, double %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %27
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %17
9: ; preds = %17
br i1 %6, label %10, label %27
10: ; preds = %9
%11 = add nsw i32 %3, -1
%12 = sitofp i32 %11 to double
%13 = fmul double %12, %1
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds double*, double** %0, i64 %14
%16 = zext i32 %4 to i64
br label %31
17: ; preds = %7, %17
%18 = phi i64 [ 0, %7 ], [ %25, %17 ]
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to double
%21 = fmul double %20, %2
%22 = tail call double @fBC(double 0.000000e+00, double %21)
%23 = load double*, double** %0
%24 = getelementptr inbounds double, double* %23, i64 %18
store double %22, double* %24
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %9, label %17
27: ; preds = %31, %5, %9
%28 = icmp sgt i32 %3, 0
br i1 %28, label %29, label %69
29: ; preds = %27
%30 = zext i32 %3 to i64
br label %48
31: ; preds = %10, %31
%32 = phi i64 [ 0, %10 ], [ %39, %31 ]
%33 = trunc i64 %32 to i32
%34 = sitofp i32 %33 to double
%35 = fmul double %34, %2
%36 = tail call double @fBC(double %13, double %35)
%37 = load double*, double** %15
%38 = getelementptr inbounds double, double* %37, i64 %32
store double %36, double* %38
%39 = add nuw nsw i64 %32, 1
%40 = icmp eq i64 %39, %16
br i1 %40, label %27, label %31
41: ; preds = %48
br i1 %28, label %42, label %69
42: ; preds = %41
%43 = add nsw i32 %4, -1
%44 = sitofp i32 %43 to double
%45 = fmul double %44, %2
%46 = sext i32 %43 to i64
%47 = zext i32 %3 to i64
br label %58
48: ; preds = %29, %48
%49 = phi i64 [ 0, %29 ], [ %56, %48 ]
%50 = trunc i64 %49 to i32
%51 = sitofp i32 %50 to double
%52 = fmul double %51, %1
%53 = tail call double @fBC(double %52, double 0.000000e+00)
%54 = getelementptr inbounds double*, double** %0, i64 %49
%55 = load double*, double** %54
store double %53, double* %55
%56 = add nuw nsw i64 %49, 1
%57 = icmp eq i64 %56, %30
br i1 %57, label %41, label %48
58: ; preds = %42, %58
%59 = phi i64 [ 0, %42 ], [ %67, %58 ]
%60 = trunc i64 %59 to i32
%61 = sitofp i32 %60 to double
%62 = fmul double %61, %1
%63 = tail call double @fBC(double %62, double %45)
%64 = getelementptr inbounds double*, double** %0, i64 %59
%65 = load double*, double** %64
%66 = getelementptr inbounds double, double* %65, i64 %46
store double %63, double* %66
%67 = add nuw nsw i64 %59, 1
%68 = icmp eq i64 %67, %47
br i1 %68, label %69, label %58
69: ; preds = %58, %27, %41
ret double** %0
}