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


x86 assembly (clang, -O0):
<poissonsEquationExp1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    11c5 <poissonsEquationExp1D+0xb5>
mov    -0x28(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%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 <poissonsEquationExp1D+0x3b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poissonsEquationExp1D>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    1188 <poissonsEquationExp1D+0x78>
mov    %r8,%r14
mov    %rcx,%r12
movsd  (%rsi),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xea8(%rip),%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
mulsd  %xmm0,%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 <poissonsEquationExp1D+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @poissonsEquationExp1D(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 %25
9: ; preds = %6
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %23, %11 ]
%13 = mul nuw nsw i64 %12, 3
%14 = getelementptr inbounds double, double* %4, i64 %13
%15 = load double, double* %14
%16 = fmul double %7, %15
%17 = fsub double 1.000000e+00, %15
%18 = fmul double %16, %17
%19 = fmul double %15, %15
%20 = tail call double @exp(double %19)
%21 = fmul double %20, %18
%22 = getelementptr inbounds double, double* %5, i64 %12
store double %21, double* %22
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %11
25: ; preds = %11, %6
ret i32 0
}