#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*/ g5_get_forceMC(int, int, double **, double *);
int g5_get_number_of_pipelines();
int /*<<< orphan*/ g5_runMC(int);
int /*<<< orphan*/ g5_set_xiMC(int, int, double **);
void g5_calculate_force_on_xMC(int devid, double (*x)[3], double (*a)[3],
                               double *p, int ni) {
  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_xiMC(devid, nii, x + off);
    g5_runMC(devid);
    g5_get_forceMC(devid, nii, a + off, p + off);
  }
}


x86 assembly (clang, -O0):
<g5_calculate_force_on_xMC>:
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    $0x0,%al
call   1030 <g5_get_number_of_pipelines@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11fc <g5_calculate_force_on_xMC+0xbc>
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    1194 <g5_calculate_force_on_xMC+0x54>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    119d <g5_calculate_force_on_xMC+0x5d>
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x10(%rbp),%rdx
movslq -0x28(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
call   1050 <g5_set_xiMC@plt>
mov    -0x4(%rbp),%edi
call   1060 <g5_runMC@plt>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x18(%rbp),%rdx
movslq -0x28(%rbp),%rax
imul   $0x18,%rax,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1040 <g5_get_forceMC@plt>
mov    -0x2c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    116c <g5_calculate_force_on_xMC+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g5_calculate_force_on_xMC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %edi,0xc(%rsp)
xor    %eax,%eax
call   1030 <g5_get_number_of_pipelines@plt>
test   %r14d,%r14d
jle    1211 <g5_calculate_force_on_xMC+0xd1>
cltq
mov    %r14d,%ecx
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x28(%rsp)
lea    (%rax,%rax,2),%rax
mov    %rax,0x20(%rsp)
xor    %r13d,%r13d
mov    %rcx,0x30(%rsp)
mov    %rcx,%rax
mov    %rcx,%r12
mov    0xc(%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,0x18(%rsp)
mov    0x10(%rsp),%rcx
sub    %rcx,%r12
mov    %ecx,%r15d
cmovle %eax,%r15d
mov    %r14d,%edi
mov    %r15d,%esi
mov    0x18(%rsp),%rdx
call   1050 <g5_set_xiMC@plt>
mov    %r14d,%edi
call   1060 <g5_runMC@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1040 <g5_get_forceMC@plt>
mov    0x18(%rsp),%r15
add    0x10(%rsp),%r13
mov    0x20(%rsp),%rax
add    %rax,%r15
add    %rax,%rbp
add    0x28(%rsp),%rbx
mov    %r12,%rax
cmp    0x30(%rsp),%r13
jl     11b0 <g5_calculate_force_on_xMC+0x70>
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_xMC(i32 %0, [3 x double]* %1, [3 x double]* %2, double* %3, i32 %4) {
%6 = alloca i32
%7 = alloca [3 x double]*
%8 = alloca [3 x double]*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store [3 x double]* %1, [3 x double]** %7
store [3 x double]* %2, [3 x double]** %8
store double* %3, double** %9
store i32 %4, i32* %10
%14 = call i32 (...) @g5_get_number_of_pipelines()
store i32 %14, i32* %12
store i32 0, i32* %11
br label %15
15: ; preds = %55, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %10
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %59
19: ; preds = %15
%20 = load i32, i32* %12
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = sub nsw i32 %21, %22
%24 = icmp slt i32 %20, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i32, i32* %12
br label %31
27: ; preds = %19
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = sub nsw i32 %28, %29
br label %31
31: ; preds = %27, %25
%32 = phi i32 [ %26, %25 ], [ %30, %27 ]
store i32 %32, i32* %13
%33 = load i32, i32* %6
%34 = load i32, i32* %13
%35 = load [3 x double]*, [3 x double]** %7
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 %37
%39 = bitcast [3 x double]* %38 to double**
%40 = call i32 @g5_set_xiMC(i32 %33, i32 %34, double** %39)
%41 = load i32, i32* %6
%42 = call i32 @g5_runMC(i32 %41)
%43 = load i32, i32* %6
%44 = load i32, i32* %13
%45 = load [3 x double]*, [3 x double]** %8
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 %47
%49 = bitcast [3 x double]* %48 to double**
%50 = load double*, double** %9
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = call i32 @g5_get_forceMC(i32 %43, i32 %44, double** %49, double* %53)
br label %55
55: ; preds = %31
%56 = load i32, i32* %12
%57 = load i32, i32* %11
%58 = add nsw i32 %57, %56
store i32 %58, i32* %11
br label %15
59: ; preds = %15
ret void
}

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