#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*/ assert(int);
int /*<<< orphan*/ g5_get_forceMC(int, int, double **, double *);
int g5_get_number_of_pipelines();
int /*<<< orphan*/ g5_runMC0(int);
int /*<<< orphan*/ g5_set_xiMC0(int, int, double **, double *);
void g5_calculate_force_on_xMC0(int devid, double (*x)[3], double (*a)[3],
                                double *p, int ni, double *eps2) {
  assert(devid < (128));
  int off;
  int np = g5_get_number_of_pipelines();
  for (off = 0; off < ni; off += np) {
    int nii = np < ni - off ? np : ni - off;
    g5_set_xiMC0(devid, nii, x + off, eps2 + off);
    g5_runMC0(devid);
    g5_get_forceMC(devid, nii, a + off, p + off);
  }
}


x86 assembly (clang, -O0):
<g5_calculate_force_on_xMC0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x80,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0x0,%al
call   1030 <g5_get_number_of_pipelines@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1233 <g5_calculate_force_on_xMC0+0xe3>
mov    -0x38(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x34(%rbp),%ecx
cmp    %ecx,%eax
jge    11bc <g5_calculate_force_on_xMC0+0x6c>
mov    -0x38(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11c5 <g5_calculate_force_on_xMC0+0x75>
mov    -0x24(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
movslq -0x34(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1050 <g5_set_xiMC0@plt>
mov    -0x4(%rbp),%edi
call   1040 <g5_runMC0@plt>
mov    -0x4(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x18(%rbp),%rdx
movslq -0x34(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1060 <g5_get_forceMC@plt>
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1194 <g5_calculate_force_on_xMC0+0x44>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g5_calculate_force_on_xMC0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r14
mov    %r8d,%ebp
mov    %rcx,0x10(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%eax
xor    %edi,%edi
mov    %eax,0x4(%rsp)
cmp    $0x80,%eax
setl   %dil
call   1070 <assert@plt>
xor    %eax,%eax
call   1030 <g5_get_number_of_pipelines@plt>
test   %ebp,%ebp
jle    1240 <g5_calculate_force_on_xMC0+0xf0>
mov    %r15,%rcx
mov    %r14,%r15
cltq
mov    %ebp,%edx
mov    %rax,0x8(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x28(%rsp)
lea    (%rax,%rax,2),%rax
mov    %rax,0x20(%rsp)
xor    %r13d,%r13d
mov    %rdx,0x30(%rsp)
mov    %rdx,%rax
mov    %rdx,%r14
mov    0x4(%rsp),%r12d
nopl   0x0(%rax)
mov    %rcx,0x18(%rsp)
mov    0x8(%rsp),%rcx
sub    %rcx,%r14
mov    %ecx,%ebp
cmovle %eax,%ebp
mov    %r12d,%edi
mov    %ebp,%esi
mov    0x18(%rsp),%rdx
mov    %r15,%rcx
call   1050 <g5_set_xiMC0@plt>
mov    %r12d,%edi
call   1040 <g5_runMC0@plt>
mov    %r12d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    0x10(%rsp),%rbp
mov    %rbp,%rcx
call   1060 <g5_get_forceMC@plt>
mov    0x18(%rsp),%rcx
add    0x8(%rsp),%r13
mov    0x20(%rsp),%rdx
add    %rdx,%rcx
mov    0x28(%rsp),%rax
add    %rax,%r15
add    %rdx,%rbx
add    %rax,%rbp
mov    %rbp,0x10(%rsp)
mov    %r14,%rax
cmp    0x30(%rsp),%r13
jl     11d0 <g5_calculate_force_on_xMC0+0x80>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @g5_calculate_force_on_xMC0(i32 %0, [3 x double]* %1, [3 x double]* %2, double* %3, i32 %4, double* %5) {
%7 = alloca i32
%8 = alloca [3 x double]*
%9 = alloca [3 x double]*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %7
store [3 x double]* %1, [3 x double]** %8
store [3 x double]* %2, [3 x double]** %9
store double* %3, double** %10
store i32 %4, i32* %11
store double* %5, double** %12
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 128
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 (...) @g5_get_number_of_pipelines()
store i32 %20, i32* %14
store i32 0, i32* %13
br label %21
21: ; preds = %65, %6
%22 = load i32, i32* %13
%23 = load i32, i32* %11
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %69
25: ; preds = %21
%26 = load i32, i32* %14
%27 = load i32, i32* %11
%28 = load i32, i32* %13
%29 = sub nsw i32 %27, %28
%30 = icmp slt i32 %26, %29
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i32, i32* %14
br label %37
33: ; preds = %25
%34 = load i32, i32* %11
%35 = load i32, i32* %13
%36 = sub nsw i32 %34, %35
br label %37
37: ; preds = %33, %31
%38 = phi i32 [ %32, %31 ], [ %36, %33 ]
store i32 %38, i32* %15
%39 = load i32, i32* %7
%40 = load i32, i32* %15
%41 = load [3 x double]*, [3 x double]** %8
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 %43
%45 = bitcast [3 x double]* %44 to double**
%46 = load double*, double** %12
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = call i32 @g5_set_xiMC0(i32 %39, i32 %40, double** %45, double* %49)
%51 = load i32, i32* %7
%52 = call i32 @g5_runMC0(i32 %51)
%53 = load i32, i32* %7
%54 = load i32, i32* %15
%55 = load [3 x double]*, [3 x double]** %9
%56 = load i32, i32* %13
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x double], [3 x double]* %55, i64 %57
%59 = bitcast [3 x double]* %58 to double**
%60 = load double*, double** %10
%61 = load i32, i32* %13
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = call i32 @g5_get_forceMC(i32 %53, i32 %54, double** %59, double* %63)
br label %65
65: ; preds = %37
%66 = load i32, i32* %14
%67 = load i32, i32* %13
%68 = add nsw i32 %67, %66
store i32 %68, i32* %13
br label %21
69: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @g5_calculate_force_on_xMC0(i32 %0, [3 x double]* %1, [3 x double]* %2, double* %3, i32 %4, double* %5) {
%7 = icmp slt i32 %0, 128
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 (...) @g5_get_number_of_pipelines()
%11 = icmp sgt i32 %4, 0
br i1 %11, label %12, label %32
12: ; preds = %6
%13 = sext i32 %10 to i64
%14 = zext i32 %4 to i64
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 0, %12 ], [ %30, %15 ]
%17 = sub nsw i64 %14, %16
%18 = icmp sgt i64 %17, %13
%19 = trunc i64 %17 to i32
%20 = select i1 %18, i32 %10, i32 %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 %16
%22 = bitcast [3 x double]* %21 to double**
%23 = getelementptr inbounds double, double* %5, i64 %16
%24 = tail call i32 @g5_set_xiMC0(i32 %0, i32 %20, double** %22, double* %23)
%25 = tail call i32 @g5_runMC0(i32 %0)
%26 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %16
%27 = bitcast [3 x double]* %26 to double**
%28 = getelementptr inbounds double, double* %3, i64 %16
%29 = tail call i32 @g5_get_forceMC(i32 %0, i32 %20, double** %27, double* %28)
%30 = add i64 %16, %13
%31 = icmp slt i64 %30, %14
br i1 %31, label %15, label %32
32: ; preds = %15, %6
ret void
}