#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*/ copyVec(double *, double *, int);
int stub1(double, double *, double *, void *);
int stub2(double, double *, double *, void *);
int stub3(double, double *, double *, void *);
int /*<<< orphan*/ sumVec(double *, int, double *, double, double *, int);
int Graggs_Method(int (*f)(double, double *, double *, void *), double y0[],
                  double t0, double t, int NUMBER_OF_STEPS, void *params,
                  double yres[]) {
  double *pars = (double *)params;
  int order = (int)pars[0], i;
  double y1[order], dydt[order], y2[order], yaux[order];
  double h = (t - t0) / (double)NUMBER_OF_STEPS;
  double h2 = h + h;
  copyVec(yaux, y0, order);
  (*f)(t0, yaux, dydt, params);
  sumVec(y1, 1, yaux, h, dydt, order);
  while (--NUMBER_OF_STEPS) {
    t0 += h;
    (*f)(t0, y1, dydt, params);
    sumVec(y2, 1, yaux, h2, dydt, order);
    copyVec(yaux, y1, order);
    copyVec(y1, y2, order);
  }
  (*f)(t, y1, dydt, params);
  sumVec(yres, 0.5, yaux, 0.5, y1, order);
  sumVec(yres, 1, yres, 0.5 * h, dydt, order);
  return 0;
}


x86 assembly (clang, -O0):
<Graggs_Method>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cvttsd2si (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x44(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
mov    -0x44(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x44(%rbp),%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x90(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1030 <copyVec@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
call   *%rax
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%rcx
movsd  -0x78(%rbp),%xmm0
mov    -0x44(%rbp),%r8d
mov    $0x1,%esi
call   1040 <sumVec@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     12fd <Graggs_Method+0x1dd>
mov    -0x98(%rbp),%rdi
mov    -0x88(%rbp),%rsi
movsd  -0x78(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
call   *%rax
mov    -0x88(%rbp),%rcx
mov    -0x90(%rbp),%rdx
mov    -0xa0(%rbp),%rdi
movsd  -0x80(%rbp),%xmm0
mov    -0x44(%rbp),%r8d
mov    $0x1,%esi
call   1040 <sumVec@plt>
mov    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1030 <copyVec@plt>
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1030 <copyVec@plt>
jmp    1266 <Graggs_Method+0x146>
mov    -0x88(%rbp),%rsi
mov    -0x98(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
call   *%rax
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%r8d
xor    %esi,%esi
movsd  0xcc6(%rip),%xmm0
call   1040 <sumVec@plt>
mov    -0x88(%rbp),%rcx
mov    -0x38(%rbp),%rdi
mov    -0x38(%rbp),%rdx
movsd  0xcaa(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
mov    -0x44(%rbp),%r8d
mov    $0x1,%esi
call   1040 <sumVec@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Graggs_Method>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,-0x70(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %edx,%r14d
movsd  %xmm0,-0x48(%rbp)
mov    %rdi,-0x38(%rbp)
cvttsd2si (%rcx),%ebx
mov    %rsp,%r13
lea    0xf(,%rbx,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
movsd  %xmm1,-0x68(%rbp)
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x30(%rbp)
mov    %r12,%rdi
mov    %ebx,%edx
call   1030 <copyVec@plt>
movsd  -0x48(%rbp),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    -0x40(%rbp),%rdx
call   *-0x38(%rbp)
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r12,-0x58(%rbp)
mov    %r12,%rdx
movsd  -0x30(%rbp),%xmm0
mov    %r15,-0x60(%rbp)
mov    %r15,%rcx
mov    %ebx,%r8d
call   1040 <sumVec@plt>
add    $0xffffffff,%r14d
je     1269 <Graggs_Method+0x149>
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x60(%rbp),%r15
mov    -0x80(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,-0x4c(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    %r13,%rdi
mov    %r15,%rsi
mov    -0x40(%rbp),%rdx
call   *-0x38(%rbp)
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r13,%r14
mov    -0x58(%rbp),%r13
mov    %r13,%rdx
movsd  -0x78(%rbp),%xmm0
mov    %r15,%rcx
mov    %ebx,%r8d
call   1040 <sumVec@plt>
mov    %r13,%rdi
mov    %r14,%r13
mov    -0x4c(%rbp),%r14d
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <copyVec@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <copyVec@plt>
add    $0xffffffff,%r14d
jne    1200 <Graggs_Method+0xe0>
movsd  -0x68(%rbp),%xmm0
mov    %r13,%rdi
mov    -0x60(%rbp),%r15
mov    %r15,%rsi
mov    -0x40(%rbp),%rdx
call   *-0x38(%rbp)
movsd  0xd79(%rip),%xmm0
mov    -0x70(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    -0x58(%rbp),%rdx
mov    %r13,%rcx
mov    %ebx,%r8d
call   1040 <sumVec@plt>
movsd  -0x30(%rbp),%xmm0
mulsd  0xd54(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %ebx,%r8d
call   1040 <sumVec@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Graggs_Method(i32 (double, double*, double*, i8*)* %0, double* %1, double %2, double %3, i32 %4, i8* %5, double* %6) {
%8 = alloca i32 (double, double*, double*, i8*)*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i8*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
%23 = alloca double
%24 = alloca double
store i32 (double, double*, double*, i8*)* %0, i32 (double, double*, double*, i8*)** %8
store double* %1, double** %9
store double %2, double* %10
store double %3, double* %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store double* %6, double** %14
%25 = load i8*, i8** %13
%26 = bitcast i8* %25 to double*
store double* %26, double** %15
%27 = load double*, double** %15
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = fptosi double %29 to i32
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %18
%34 = alloca double, i64 %32
store i64 %32, i64* %19
%35 = load i32, i32* %16
%36 = zext i32 %35 to i64
%37 = alloca double, i64 %36
store i64 %36, i64* %20
%38 = load i32, i32* %16
%39 = zext i32 %38 to i64
%40 = alloca double, i64 %39
store i64 %39, i64* %21
%41 = load i32, i32* %16
%42 = zext i32 %41 to i64
%43 = alloca double, i64 %42
store i64 %42, i64* %22
%44 = load double, double* %11
%45 = load double, double* %10
%46 = fsub double %44, %45
%47 = load i32, i32* %12
%48 = sitofp i32 %47 to double
%49 = fdiv double %46, %48
store double %49, double* %23
%50 = load double, double* %23
%51 = load double, double* %23
%52 = fadd double %50, %51
store double %52, double* %24
%53 = load double*, double** %9
%54 = load i32, i32* %16
%55 = call i32 @copyVec(double* %43, double* %53, i32 %54)
%56 = load i32 (double, double*, double*, i8*)*, i32 (double, double*, double*, i8*)** %8
%57 = load double, double* %10
%58 = load i8*, i8** %13
%59 = call i32 %56(double %57, double* %43, double* %37, i8* %58)
%60 = load double, double* %23
%61 = load i32, i32* %16
%62 = call i32 @sumVec(double* %34, i32 1, double* %43, double %60, double* %37, i32 %61)
br label %63
63: ; preds = %67, %7
%64 = load i32, i32* %12
%65 = add nsw i32 %64, -1
store i32 %65, i32* %12
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %82
67: ; preds = %63
%68 = load double, double* %23
%69 = load double, double* %10
%70 = fadd double %69, %68
store double %70, double* %10
%71 = load i32 (double, double*, double*, i8*)*, i32 (double, double*, double*, i8*)** %8
%72 = load double, double* %10
%73 = load i8*, i8** %13
%74 = call i32 %71(double %72, double* %34, double* %37, i8* %73)
%75 = load double, double* %24
%76 = load i32, i32* %16
%77 = call i32 @sumVec(double* %40, i32 1, double* %43, double %75, double* %37, i32 %76)
%78 = load i32, i32* %16
%79 = call i32 @copyVec(double* %43, double* %34, i32 %78)
%80 = load i32, i32* %16
%81 = call i32 @copyVec(double* %34, double* %40, i32 %80)
br label %63
82: ; preds = %63
%83 = load i32 (double, double*, double*, i8*)*, i32 (double, double*, double*, i8*)** %8
%84 = load double, double* %11
%85 = load i8*, i8** %13
%86 = call i32 %83(double %84, double* %34, double* %37, i8* %85)
%87 = load double*, double** %14
%88 = load i32, i32* %16
%89 = call i32 @sumVec(double* %87, i32 0, double* %43, double 5.000000e-01, double* %34, i32 %88)
%90 = load double*, double** %14
%91 = load double*, double** %14
%92 = load double, double* %23
%93 = fmul double 5.000000e-01, %92
%94 = load i32, i32* %16
%95 = call i32 @sumVec(double* %90, i32 1, double* %91, double %93, double* %37, i32 %94)
%96 = load i8*, i8** %18
ret i32 0
}

LLVM IR (-O2):
define i32 @Graggs_Method(i32 (double, double*, double*, i8*)* nocapture %0, double* %1, double %2, double %3, i32 %4, i8* %5, double* %6) {
%8 = bitcast i8* %5 to double*
%9 = load double, double* %8
%10 = fptosi double %9 to i32
%11 = zext i32 %10 to i64
%12 = alloca double, i64 %11
%13 = alloca double, i64 %11
%14 = alloca double, i64 %11
%15 = alloca double, i64 %11
%16 = fsub double %3, %2
%17 = sitofp i32 %4 to double
%18 = fdiv double %16, %17
%19 = fadd double %18, %18
%20 = call i32 @copyVec(double* %15, double* %1, i32 %10)
%21 = call i32 %0(double %2, double* %15, double* %13, i8* %5)
%22 = call i32 @sumVec(double* %12, i32 1, double* %15, double %18, double* %13, i32 %10)
%23 = add nsw i32 %4, -1
%24 = icmp eq i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %7, %25
%26 = phi i32 [ %33, %25 ], [ %23, %7 ]
%27 = phi double [ %28, %25 ], [ %2, %7 ]
%28 = fadd double %18, %27
%29 = call i32 %0(double %28, double* %12, double* %13, i8* %5)
%30 = call i32 @sumVec(double* %14, i32 1, double* %15, double %19, double* %13, i32 %10)
%31 = call i32 @copyVec(double* %15, double* %12, i32 %10)
%32 = call i32 @copyVec(double* %12, double* %14, i32 %10)
%33 = add nsw i32 %26, -1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %25
35: ; preds = %25, %7
%36 = call i32 %0(double %3, double* %12, double* %13, i8* %5)
%37 = call i32 @sumVec(double* %6, i32 0, double* %15, double 5.000000e-01, double* %12, i32 %10)
%38 = fmul double %18, 5.000000e-01
%39 = call i32 @sumVec(double* %6, i32 1, double* %6, double %38, double* %13, i32 %10)
ret i32 0
}