#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 */
double _fxy(double, double);
int rngkg(double x0, double y0, int n, double h, double y[]) {
  static double cq[4] = {2.0, 1.0, 1.0, 2.0};
  static double ckq[4] = {0.5, 0.29289321881345248, 1.70710678118654752,
                          0.16666666666666667};
  static double ck[4] = {0.5, 0.29289321881345248, 1.70710678118654752, 0.5};
  double k, q, r, xx, yy;
  int i, j;
  if (h <= 0.0)
    return 999;
  q = 0.0;
  xx = x0;
  yy = y0;
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= 3; j++) {
      k = h * _fxy(xx, yy);
      r = (k - cq[j] * q) * ckq[j];
      yy += r;
      q += 3.0 * r - ck[j] * k;
      xx += h * ck[j];
      if (j == 3)
        y[i] = yy;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<rngkg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1148 <rngkg+0x38>
movl   $0x3e7,-0x4(%rbp)
jmp    12ca <rngkg+0x1ba>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x1,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     12c3 <rngkg+0x1b3>
movl   $0x0,-0x60(%rbp)
cmpl   $0x3,-0x60(%rbp)
jg     12b0 <rngkg+0x1a0>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <_fxy@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movslq -0x60(%rbp),%rcx
lea    0x2e6e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x60(%rbp),%rcx
lea    0x2e5a(%rip),%rax
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movslq -0x60(%rbp),%rcx
lea    0x2e51(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movslq -0x60(%rbp),%rcx
lea    0x2e06(%rip),%rax
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpl   $0x3,-0x60(%rbp)
jne    129d <rngkg+0x18d>
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12a2 <rngkg+0x192>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    117e <rngkg+0x6e>
jmp    12b5 <rngkg+0x1a5>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    116b <rngkg+0x5b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rngkg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movapd %xmm0,%xmm3
mov    $0x3e7,%r14d
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    1361 <rngkg+0x251>
mov    %edi,%ebp
xor    %r14d,%r14d
test   %edi,%edi
jle    1361 <rngkg+0x251>
mov    %rsi,%r15
add    $0x1,%ebp
xorpd  %xmm4,%xmm4
mov    $0x1,%ebx
movapd %xmm2,%xmm0
mulsd  0xea6(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movapd %xmm2,%xmm0
mulsd  0xeac(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
movapd %xmm2,%xmm0
mulsd  0xeaa(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm2,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm1,(%rsp)
movapd %xmm3,%xmm0
movsd  (%rsp),%xmm1
call   1030 <_fxy@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
mulsd  0xe2d(%rip),%xmm2
movsd  (%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe1f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1b(%rip),%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <_fxy@plt>
mulsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm3
subsd  %xmm3,%xmm2
mulsd  0xdd3(%rip),%xmm2
movsd  (%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
mulsd  0xdc5(%rip),%xmm0
mulsd  0xdad(%rip),%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <_fxy@plt>
mulsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm3
subsd  %xmm3,%xmm2
mulsd  0xd79(%rip),%xmm2
movsd  (%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
mulsd  0xd6b(%rip),%xmm0
mulsd  0xd43(%rip),%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <_fxy@plt>
movsd  0x8(%rsp),%xmm3
mulsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
movsd  (%rsp),%xmm1
mulsd  0xd0c(%rip),%xmm4
addsd  %xmm4,%xmm1
mulsd  0xcd0(%rip),%xmm0
mulsd  0xcd0(%rip),%xmm4
addsd  %xmm0,%xmm4
addsd  %xmm2,%xmm4
addsd  0x20(%rsp),%xmm3
movsd  %xmm1,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <rngkg+0x80>
mov    %r14d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@rngkg.cq = internal global [4 x double] [double 2.000000e+00, double 1.000000e+00, double 1.000000e+00, double 2.000000e+00]
@rngkg.ckq = internal global [4 x double] [double 5.000000e-01, double 0x3FD2BEC333018867, double 0x3FFB504F333F9DE6, double 0x3FC5555555555555]
@rngkg.ck = internal global [4 x double] [double 5.000000e-01, double 0x3FD2BEC333018867, double 0x3FFB504F333F9DE6, double 5.000000e-01]
define i32 @rngkg(double %0, double %1, i32 %2, double %3, double* %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double*
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
store double %0, double* %7
store double %1, double* %8
store i32 %2, i32* %9
store double %3, double* %10
store double* %4, double** %11
%19 = load double, double* %10
%20 = fcmp ole double %19, 0.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %5
store i32 999, i32* %6
br label %90
22: ; preds = %5
store double 0.000000e+00, double* %13
%23 = load double, double* %7
store double %23, double* %15
%24 = load double, double* %8
store double %24, double* %16
store i32 1, i32* %17
br label %25
25: ; preds = %86, %22
%26 = load i32, i32* %17
%27 = load i32, i32* %9
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %89
29: ; preds = %25
store i32 0, i32* %18
br label %30
30: ; preds = %82, %29
%31 = load i32, i32* %18
%32 = icmp sle i32 %31, 3
br i1 %32, label %33, label %85
33: ; preds = %30
%34 = load double, double* %10
%35 = load double, double* %15
%36 = load double, double* %16
%37 = call double @_fxy(double %35, double %36)
%38 = fmul double %34, %37
store double %38, double* %12
%39 = load double, double* %12
%40 = load i32, i32* %18
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x double], [4 x double]* @rngkg.cq, i64 0, i64 %41
%43 = load double, double* %42
%44 = load double, double* %13
%45 = fneg double %43
%46 = call double @llvm.fmuladd.f64(double %45, double %44, double %39)
%47 = load i32, i32* %18
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4 x double], [4 x double]* @rngkg.ckq, i64 0, i64 %48
%50 = load double, double* %49
%51 = fmul double %46, %50
store double %51, double* %14
%52 = load double, double* %14
%53 = load double, double* %16
%54 = fadd double %53, %52
store double %54, double* %16
%55 = load double, double* %14
%56 = load i32, i32* %18
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4 x double], [4 x double]* @rngkg.ck, i64 0, i64 %57
%59 = load double, double* %58
%60 = load double, double* %12
%61 = fmul double %59, %60
%62 = fneg double %61
%63 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %55, double %62)
%64 = load double, double* %13
%65 = fadd double %64, %63
store double %65, double* %13
%66 = load double, double* %10
%67 = load i32, i32* %18
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4 x double], [4 x double]* @rngkg.ck, i64 0, i64 %68
%70 = load double, double* %69
%71 = load double, double* %15
%72 = call double @llvm.fmuladd.f64(double %66, double %70, double %71)
store double %72, double* %15
%73 = load i32, i32* %18
%74 = icmp eq i32 %73, 3
br i1 %74, label %75, label %81
75: ; preds = %33
%76 = load double, double* %16
%77 = load double*, double** %11
%78 = load i32, i32* %17
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
store double %76, double* %80
br label %81
81: ; preds = %75, %33
br label %82
82: ; preds = %81
%83 = load i32, i32* %18
%84 = add nsw i32 %83, 1
store i32 %84, i32* %18
br label %30
85: ; preds = %30
br label %86
86: ; preds = %85
%87 = load i32, i32* %17
%88 = add nsw i32 %87, 1
store i32 %88, i32* %17
br label %25
89: ; preds = %25
store i32 0, i32* %6
br label %90
90: ; preds = %89, %21
%91 = load i32, i32* %6
ret i32 %91
}

LLVM IR (-O2):
define i32 @rngkg(double %0, double %1, i32 %2, double %3, double* nocapture writeonly %4) {
%6 = fcmp ugt double %3, 0.000000e+00
br i1 %6, label %7, label %56
7: ; preds = %5
%8 = icmp slt i32 %2, 1
br i1 %8, label %56, label %9
9: ; preds = %7
%10 = add nuw i32 %2, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ 1, %9 ], [ %54, %12 ]
%14 = phi double [ %1, %9 ], [ %49, %12 ]
%15 = phi double [ %0, %9 ], [ %53, %12 ]
%16 = phi double [ 0.000000e+00, %9 ], [ %52, %12 ]
%17 = getelementptr inbounds double, double* %4, i64 %13
%18 = tail call double @_fxy(double %15, double %14)
%19 = fmul double %18, %3
%20 = tail call double @llvm.fmuladd.f64(double %16, double -2.000000e+00, double %19)
%21 = fmul double %20, 5.000000e-01
%22 = fadd double %14, %21
%23 = fmul double %19, -5.000000e-01
%24 = tail call double @llvm.fmuladd.f64(double %21, double 3.000000e+00, double %23)
%25 = fadd double %16, %24
%26 = tail call double @llvm.fmuladd.f64(double %3, double 5.000000e-01, double %15)
%27 = tail call double @_fxy(double %26, double %22)
%28 = fmul double %27, %3
%29 = tail call double @llvm.fmuladd.f64(double %25, double -1.000000e+00, double %28)
%30 = fmul double %29, 0x3FD2BEC333018867
%31 = fadd double %22, %30
%32 = fmul double %28, 0xBFD2BEC333018867
%33 = tail call double @llvm.fmuladd.f64(double %30, double 3.000000e+00, double %32)
%34 = fadd double %25, %33
%35 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FD2BEC333018867, double %26)
%36 = tail call double @_fxy(double %35, double %31)
%37 = fmul double %36, %3
%38 = tail call double @llvm.fmuladd.f64(double %34, double -1.000000e+00, double %37)
%39 = fmul double %38, 0x3FFB504F333F9DE6
%40 = fadd double %31, %39
%41 = fmul double %37, 0xBFFB504F333F9DE6
%42 = tail call double @llvm.fmuladd.f64(double %39, double 3.000000e+00, double %41)
%43 = fadd double %34, %42
%44 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FFB504F333F9DE6, double %35)
%45 = tail call double @_fxy(double %44, double %40)
%46 = fmul double %45, %3
%47 = tail call double @llvm.fmuladd.f64(double %43, double -2.000000e+00, double %46)
%48 = fmul double %47, 0x3FC5555555555555
%49 = fadd double %40, %48
%50 = fmul double %46, -5.000000e-01
%51 = tail call double @llvm.fmuladd.f64(double %48, double 3.000000e+00, double %50)
%52 = fadd double %43, %51
%53 = tail call double @llvm.fmuladd.f64(double %3, double 5.000000e-01, double %44)
store double %49, double* %17
%54 = add nuw nsw i64 %13, 1
%55 = icmp eq i64 %54, %11
br i1 %55, label %56, label %12
56: ; preds = %12, %7, %5
%57 = phi i32 [ 999, %5 ], [ 0, %7 ], [ 0, %12 ]
ret i32 %57
}