#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 exp(double);
int poissonsEquationExp2D(int *iwork, double *rwork, int nPoints, double t,
                          double *X, double *u) {
  int i = 0;
  double K = rwork[0];
  double x, y;
  for (i = 0; i < nPoints; i++) {
    x = X[i * 3 + 0];
    y = X[i * 3 + 1];
    u[i] = K * x * (1.0 - x) * y * (1.0 - y) * exp(x * x + y * y);
  }
  return 0;
}


x86 assembly (clang, -O0):
<poissonsEquationExp2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1205 <poissonsEquationExp2D+0xf5>
mov    -0x28(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
subsd  -0x50(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114b <poissonsEquationExp2D+0x3b>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poissonsEquationExp2D>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    11a7 <poissonsEquationExp2D+0x97>
mov    %r8,%r14
mov    %rcx,%r12
movsd  (%rsi),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r15d
add    $0x8,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  -0x8(%r12),%xmm0
movsd  (%r12),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  0xea1(%rip),%xmm4
movapd %xmm4,%xmm3
subsd  %xmm0,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
subsd  %xmm1,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,0x10(%rsp)
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
add    $0x18,%r12
cmp    %rbx,%r15
jne    1140 <poissonsEquationExp2D+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @poissonsEquationExp2D(i32* %0, double* %1, i32 %2, double %3, double* %4, double* %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32* %0, i32** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store double* %4, double** %11
store double* %5, double** %12
store i32 0, i32* %13
%17 = load double*, double** %8
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
store double %19, double* %14
store i32 0, i32* %13
br label %20
20: ; preds = %62, %6
%21 = load i32, i32* %13
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %65
24: ; preds = %20
%25 = load double*, double** %11
%26 = load i32, i32* %13
%27 = mul nsw i32 %26, 3
%28 = add nsw i32 %27, 0
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load double, double* %30
store double %31, double* %15
%32 = load double*, double** %11
%33 = load i32, i32* %13
%34 = mul nsw i32 %33, 3
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %32, i64 %36
%38 = load double, double* %37
store double %38, double* %16
%39 = load double, double* %14
%40 = load double, double* %15
%41 = fmul double %39, %40
%42 = load double, double* %15
%43 = fsub double 1.000000e+00, %42
%44 = fmul double %41, %43
%45 = load double, double* %16
%46 = fmul double %44, %45
%47 = load double, double* %16
%48 = fsub double 1.000000e+00, %47
%49 = fmul double %46, %48
%50 = load double, double* %15
%51 = load double, double* %15
%52 = load double, double* %16
%53 = load double, double* %16
%54 = fmul double %52, %53
%55 = call double @llvm.fmuladd.f64(double %50, double %51, double %54)
%56 = call double @exp(double %55)
%57 = fmul double %49, %56
%58 = load double*, double** %12
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
br label %62
62: ; preds = %24
%63 = load i32, i32* %13
%64 = add nsw i32 %63, 1
store i32 %64, i32* %13
br label %20
65: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
define i32 @poissonsEquationExp2D(i32* nocapture readnone %0, double* nocapture %1, i32 %2, double %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = load double, double* %1
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %30, %11 ]
%13 = mul nuw nsw i64 %12, 3
%14 = getelementptr inbounds double, double* %4, i64 %13
%15 = load double, double* %14
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds double, double* %4, i64 %16
%18 = load double, double* %17
%19 = fmul double %7, %15
%20 = fsub double 1.000000e+00, %15
%21 = fmul double %19, %20
%22 = fmul double %18, %21
%23 = fsub double 1.000000e+00, %18
%24 = fmul double %23, %22
%25 = fmul double %18, %18
%26 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %25)
%27 = tail call double @exp(double %26)
%28 = fmul double %27, %24
%29 = getelementptr inbounds double, double* %5, i64 %12
store double %28, double* %29
%30 = add nuw nsw i64 %12, 1
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %11
32: ; preds = %11, %6
ret i32 0
}