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


x86 assembly (clang, -O0):
<setRHS2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %edx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b3 <setRHS2D+0xa3>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a0 <setRHS2D+0x90>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%esi
call   1030 <f@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%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    114b <setRHS2D+0x3b>
jmp    11a5 <setRHS2D+0x95>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <setRHS2D+0x23>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setRHS2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r12
cmp    $0x3,%esi
jl     11b2 <setRHS2D+0xa2>
mov    %esi,%r15d
add    $0xffffffff,%r15d
mov    (%rsp),%rax
lea    -0x1(%rax),%r13d
mov    $0x1,%ebx
movsd  %xmm1,0x10(%rsp)
jmp    1159 <setRHS2D+0x49>
add    $0x1,%rbx
cmp    %r15,%rbx
je     11b2 <setRHS2D+0xa2>
cmpl   $0x3,(%rsp)
jl     1150 <setRHS2D+0x40>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%ebp
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    %ebp,%edi
call   1030 <f@plt>
movsd  0x10(%rsp),%xmm1
mov    (%r12,%rbx,8),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%r14
cmp    %r14,%r13
jne    1180 <setRHS2D+0x70>
jmp    1150 <setRHS2D+0x40>
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @setRHS2D(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
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 1, i32* %11
br label %13
13: ; preds = %48, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %51
18: ; preds = %13
store i32 1, i32* %12
br label %19
19: ; preds = %44, %18
%20 = load i32, i32* %12
%21 = load i32, i32* %10
%22 = sub nsw i32 %21, 1
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %47
24: ; preds = %19
%25 = load i32, i32* %11
%26 = sitofp i32 %25 to double
%27 = load double, double* %7
%28 = fmul double %26, %27
%29 = fptosi double %28 to i32
%30 = load i32, i32* %12
%31 = sitofp i32 %30 to double
%32 = load double, double* %8
%33 = fmul double %31, %32
%34 = fptosi double %33 to i32
%35 = call double @f(i32 %29, i32 %34)
%36 = load double**, double*** %6
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double*, double** %36, i64 %38
%40 = load double*, double** %39
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %35, double* %43
br label %44
44: ; preds = %24
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %19
47: ; preds = %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %13
51: ; preds = %13
%52 = load double**, double*** %6
ret double** %52
}

LLVM IR (-O2):
define double** @setRHS2D(double** returned %0, double %1, double %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, 2
br i1 %6, label %7, label %35
7: ; preds = %5
%8 = add nsw i32 %3, -1
%9 = add i32 %4, -1
%10 = icmp sgt i32 %4, 2
%11 = zext i32 %8 to i64
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %7, %32
%14 = phi i64 [ 1, %7 ], [ %33, %32 ]
br i1 %10, label %15, label %32
15: ; preds = %13
%16 = trunc i64 %14 to i32
%17 = sitofp i32 %16 to double
%18 = fmul double %17, %1
%19 = fptosi double %18 to i32
%20 = getelementptr inbounds double*, double** %0, i64 %14
br label %21
21: ; preds = %15, %21
%22 = phi i64 [ 1, %15 ], [ %30, %21 ]
%23 = trunc i64 %22 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double %24, %2
%26 = fptosi double %25 to i32
%27 = tail call double @f(i32 %19, i32 %26)
%28 = load double*, double** %20
%29 = getelementptr inbounds double, double* %28, i64 %22
store double %27, double* %29
%30 = add nuw nsw i64 %22, 1
%31 = icmp eq i64 %30, %12
br i1 %31, label %32, label %21
32: ; preds = %21, %13
%33 = add nuw nsw i64 %14, 1
%34 = icmp eq i64 %33, %11
br i1 %34, label %35, label %13
35: ; preds = %32, %5
ret double** %0
}