#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 */
typedef double DIm;

/* Variables and functions */
double deriv(double, double, double);
double prob_current1D(double *J, double *Re, double *Im, int nx, double stepx,
                      int dyn, double m) {
  int i, j;
  double DRe, DIm, work;
  for (i = 1; i < nx - 1; i++) {
    DRe = deriv(Re[i - 1], Re[i + 1], stepx);
    DIm = deriv(Im[i - 1], Im[i + 1], stepx);
    J[i] = (1 / m) * (Re[i] * (DIm)-Im[i] * DRe);
  }
}


x86 assembly (clang, -O0):
<prob_current1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
movsd  %xmm1,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1222 <prob_current1D+0x112>
mov    -0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1030 <deriv@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1030 <deriv@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  0xe45(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x58(%rbp),%xmm3
mov    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  -0x50(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    113c <prob_current1D+0x2c>
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prob_current1D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%ecx
jl     11c5 <prob_current1D+0xb5>
movaps %xmm0,%xmm2
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
add    $0xffffffff,%r14d
movsd  0xebe(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%ebx
movsd  %xmm2,(%rsp)
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rbx),%rbp
movsd  -0x8(%r13,%rbx,8),%xmm0
movsd  0x8(%r13,%rbx,8),%xmm1
movsd  (%rsp),%xmm2
call   1030 <deriv@plt>
movsd  %xmm0,0x10(%rsp)
movsd  -0x8(%r15,%rbx,8),%xmm0
movsd  0x8(%r15,%rbx,8),%xmm1
movsd  (%rsp),%xmm2
call   1030 <deriv@plt>
movsd  0x10(%rsp),%xmm1
mulsd  (%r15,%rbx,8),%xmm1
mulsd  0x0(%r13,%rbx,8),%xmm0
subsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
mov    %rbp,%rbx
cmp    %rbp,%r14
jne    1160 <prob_current1D+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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