#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 */
int /*<<< orphan*/ coulomb_force_one_pair(double const *, double const *,
                                          double, double, double *);
void ca_coulomb_force_per_particle_charge(const double *positions,
                                          const double *charge, double dt,
                                          int num_ptcls, double delta, double k,
                                          double *forces) {
  double kp = dt * k;
  double ki;
  const double *r0;
  double *f;
  const double *r1;
  double kij;
  int i, j;
  for (i = 0; i < num_ptcls; ++i) {
    ki = kp * charge[i];
    r0 = &positions[i * 3];
    f = &forces[i * 3];
    for (j = 0; j < num_ptcls; ++j) {
      if (j == i)
        continue;
      r1 = &positions[j * 3];
      kij = ki * charge[j];
      coulomb_force_one_pair(r0, r1, kij, delta, f);
    }
  }
}


x86 assembly (clang, -O0):
<ca_coulomb_force_per_particle_charge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1228 <ca_coulomb_force_per_particle_charge+0x118>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3,-0x6c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
imul   $0x3,-0x6c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1215 <ca_coulomb_force_per_particle_charge+0x105>
mov    -0x70(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jne    11bf <ca_coulomb_force_per_particle_charge+0xaf>
jmp    1207 <ca_coulomb_force_per_particle_charge+0xf7>
mov    -0x8(%rbp),%rax
imul   $0x3,-0x70(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
movsd  -0x68(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mov    -0x58(%rbp),%rdx
call   1030 <coulomb_force_one_pair@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    11a2 <ca_coulomb_force_per_particle_charge+0x92>
jmp    121a <ca_coulomb_force_per_particle_charge+0x10a>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    114c <ca_coulomb_force_per_particle_charge+0x3c>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ca_coulomb_force_per_particle_charge>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x28(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x10(%rsp)
test   %edx,%edx
jle    11fc <ca_coulomb_force_per_particle_charge+0xec>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edx,%eax
mov    %rax,0x18(%rsp)
lea    (%rax,%rax,2),%r14
xor    %ebp,%ebp
xor    %eax,%eax
jmp    1184 <ca_coulomb_force_per_particle_charge+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x30(%rsp),%rax
add    $0x1,%rax
add    $0x3,%rbp
cmp    0x18(%rsp),%rax
je     11fc <ca_coulomb_force_per_particle_charge+0xec>
mov    0x20(%rsp),%r15
movsd  (%r15,%rax,8),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
mov    %rax,0x30(%rsp)
lea    (%rax,%rax,2),%eax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%r13
mov    0x28(%rsp),%rcx
lea    (%rcx,%rax,8),%rbx
xor    %r12d,%r12d
jmp    11cd <ca_coulomb_force_per_particle_charge+0xbd>
nopw   0x0(%rax,%rax,1)
add    $0x3,%r12
add    $0x8,%r15
cmp    %r12,%r14
je     1170 <ca_coulomb_force_per_particle_charge+0x60>
cmp    %r12,%rbp
je     11c0 <ca_coulomb_force_per_particle_charge+0xb0>
mov    %r12d,%eax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
movsd  (%r15),%xmm0
mulsd  0x40(%rsp),%xmm0
mov    %r13,%rdi
movsd  0x38(%rsp),%xmm1
mov    %rbx,%rdx
call   1030 <coulomb_force_one_pair@plt>
jmp    11c0 <ca_coulomb_force_per_particle_charge+0xb0>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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