#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 bessj(int, float);
double bessj0(float);
double bessj1(float);
int /*<<< orphan*/ derivs(float, float *, float *);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rk4(float *, float *, int, float, float, float *,
                       int /*<<< orphan*/ (*)(float, float *, float *));
float *vector(int, int);
int main(void) {
  int i, j;
  float h, x = 1.0, *y, *dydx, *yout;
  y = vector(1, 4);
  dydx = vector(1, 4);
  yout = vector(1, 4);
  y[1] = bessj0(x);
  y[2] = bessj1(x);
  y[3] = bessj(2, x);
  y[4] = bessj(3, x);
  derivs(x, y, dydx);
  printf("\n%16s %5s %12s %12s %12s\n", "Bessel function:", "j0", "j1", "j3",
         "j4");
  for (i = 1; i <= 5; i++) {
    h = 0.2 * i;
    rk4(y, dydx, 4, x, h, yout, derivs);
    printf("\nfor a step size of: %6.2f\n", h);
    printf("%12s", "rk4:");
    for (j = 1; j <= 4; j++)
      printf(" %12.6f", yout[j]);
    printf("\n%12s %12.6f %12.6f %12.6f %12.6f\n", "actual:", bessj0(x + h),
           bessj1(x + h), bessj(2, x + h), bessj(3, x + h));
  }
  free_vector(yout, 1, 4);
  free_vector(dydx, 1, 4);
  free_vector(y, 1, 4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe79(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
call   1080 <bessj0@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x14(%rbp),%xmm0
call   1030 <bessj1@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x14(%rbp),%xmm0
mov    $0x2,%edi
call   1090 <bessj@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0xc(%rax)
movss  -0x14(%rbp),%xmm0
mov    $0x3,%edi
call   1090 <bessj@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x10(%rax)
movss  -0x14(%rbp),%xmm0
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <derivs@plt>
lea    0xdcc(%rip),%rdi
lea    0xddf(%rip),%rsi
lea    0xde9(%rip),%rdx
lea    0xde5(%rip),%rcx
lea    0xde1(%rip),%r8
lea    0xddd(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     13b4 <main+0x244>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xd7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
mov    -0x30(%rbp),%rcx
mov    $0x4,%edx
mov    0x2d2d(%rip),%r8
call   1060 <rk4@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd77(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xd85(%rip),%rdi
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jg     132a <main+0x1ba>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd58(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12f3 <main+0x183>
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
call   1080 <bessj0@plt>
movsd  %xmm0,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
call   1030 <bessj1@plt>
movsd  %xmm0,-0x48(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1090 <bessj@plt>
movsd  %xmm0,-0x40(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
mov    $0x3,%edi
call   1090 <bessj@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
lea    0xcdd(%rip),%rdi
lea    0xcf9(%rip),%rsi
mov    $0x4,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1275 <main+0x105>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,%r15
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x4,%esi
call   1070 <vector@plt>
mov    %rax,%rbx
movss  0xe44(%rip),%xmm0
call   1080 <bessj0@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%r15)
movss  0xe2d(%rip),%xmm0
call   1030 <bessj1@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%r15)
mov    $0x2,%edi
movss  0xe11(%rip),%xmm0
call   1090 <bessj@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%r15)
mov    $0x3,%edi
movss  0xdf5(%rip),%xmm0
call   1090 <bessj@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%r15)
movss  0xdde(%rip),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <derivs@plt>
lea    0xde4(%rip),%rdi
lea    0xdf7(%rip),%rsi
lea    0xe01(%rip),%rdx
lea    0xdfd(%rip),%rcx
lea    0xdf9(%rip),%r8
lea    0xdf5(%rip),%r9
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0xda2(%rip),%xmm0
mov    $0x5,%ebp
lea    0xe03(%rip),%r13
lea    0xe27(%rip),%r12
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd7c(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
movss  0xd4c(%rip),%xmm0
mov    %rbx,%rcx
mov    0x2d2a(%rip),%r8
call   1060 <rk4@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xd89(%rip),%rdi
lea    0xd87(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
addss  0xcb6(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1080 <bessj0@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x4(%rsp),%xmm0
call   1030 <bessj1@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0x2,%edi
movss  0x4(%rsp),%xmm0
call   1090 <bessj@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x3,%edi
movss  0x4(%rsp),%xmm0
call   1090 <bessj@plt>
movaps %xmm0,%xmm3
lea    0xce1(%rip),%rdi
mov    %r12,%rsi
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xc42(%rip),%xmm0
add    $0xffffffff,%ebp
jne    1280 <main+0x110>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A%16s %5s %12s %12s %12s\0A\00"
@.str.1 = [17 x i8] c"Bessel function:\00"
@.str.2 = [3 x i8] c"j0\00"
@.str.3 = [3 x i8] c"j1\00"
@.str.4 = [3 x i8] c"j3\00"
@.str.5 = [3 x i8] c"j4\00"
@.str.6 = [28 x i8] c"\0Afor a step size of: %6.2f\0A\00"
@.str.7 = [5 x i8] c"%12s\00"
@.str.8 = [5 x i8] c"rk4:\00"
@.str.9 = [8 x i8] c" %12.6f\00"
@.str.10 = [35 x i8] c"\0A%12s %12.6f %12.6f %12.6f %12.6f\0A\00"
@.str.11 = [8 x i8] c"actual:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
store i32 0, i32* %1
store float 1.000000e+00, float* %5
%9 = call float* @vector(i32 1, i32 4)
store float* %9, float** %6
%10 = call float* @vector(i32 1, i32 4)
store float* %10, float** %7
%11 = call float* @vector(i32 1, i32 4)
store float* %11, float** %8
%12 = load float, float* %5
%13 = call double @bessj0(float %12)
%14 = fptrunc double %13 to float
%15 = load float*, float** %6
%16 = getelementptr inbounds float, float* %15, i64 1
store float %14, float* %16
%17 = load float, float* %5
%18 = call double @bessj1(float %17)
%19 = fptrunc double %18 to float
%20 = load float*, float** %6
%21 = getelementptr inbounds float, float* %20, i64 2
store float %19, float* %21
%22 = load float, float* %5
%23 = call double @bessj(i32 2, float %22)
%24 = fptrunc double %23 to float
%25 = load float*, float** %6
%26 = getelementptr inbounds float, float* %25, i64 3
store float %24, float* %26
%27 = load float, float* %5
%28 = call double @bessj(i32 3, float %27)
%29 = fptrunc double %28 to float
%30 = load float*, float** %6
%31 = getelementptr inbounds float, float* %30, i64 4
store float %29, float* %31
%32 = load float, float* %5
%33 = load float*, float** %6
%34 = load float*, float** %7
%35 = call i32 @derivs(float %32, float* %33, float* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %37
37: ; preds = %87, %0
%38 = load i32, i32* %2
%39 = icmp sle i32 %38, 5
br i1 %39, label %40, label %90
40: ; preds = %37
%41 = load i32, i32* %2
%42 = sitofp i32 %41 to double
%43 = fmul double 2.000000e-01, %42
%44 = fptrunc double %43 to float
store float %44, float* %4
%45 = load float*, float** %6
%46 = load float*, float** %7
%47 = load float, float* %5
%48 = load float, float* %4
%49 = load float*, float** %8
%50 = call i32 @rk4(float* %45, float* %46, i32 4, float %47, float %48, float* %49, i32 (float, float*, float*)* @derivs)
%51 = load float, float* %4
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %55
55: ; preds = %66, %40
%56 = load i32, i32* %3
%57 = icmp sle i32 %56, 4
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load float*, float** %8
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds float, float* %59, i64 %61
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double %64)
br label %66
66: ; preds = %58
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %55
69: ; preds = %55
%70 = load float, float* %5
%71 = load float, float* %4
%72 = fadd float %70, %71
%73 = call double @bessj0(float %72)
%74 = load float, float* %5
%75 = load float, float* %4
%76 = fadd float %74, %75
%77 = call double @bessj1(float %76)
%78 = load float, float* %5
%79 = load float, float* %4
%80 = fadd float %78, %79
%81 = call double @bessj(i32 2, float %80)
%82 = load float, float* %5
%83 = load float, float* %4
%84 = fadd float %82, %83
%85 = call double @bessj(i32 3, float %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), double %73, double %77, double %81, double %85)
br label %87
87: ; preds = %69
%88 = load i32, i32* %2
%89 = add nsw i32 %88, 1
store i32 %89, i32* %2
br label %37
90: ; preds = %37
%91 = load float*, float** %8
%92 = call i32 @free_vector(float* %91, i32 1, i32 4)
%93 = load float*, float** %7
%94 = call i32 @free_vector(float* %93, i32 1, i32 4)
%95 = load float*, float** %6
%96 = call i32 @free_vector(float* %95, i32 1, i32 4)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0A%16s %5s %12s %12s %12s\0A\00"
@.str.1 = [17 x i8] c"Bessel function:\00"
@.str.2 = [3 x i8] c"j0\00"
@.str.3 = [3 x i8] c"j1\00"
@.str.4 = [3 x i8] c"j3\00"
@.str.5 = [3 x i8] c"j4\00"
@.str.6 = [28 x i8] c"\0Afor a step size of: %6.2f\0A\00"
@.str.7 = [5 x i8] c"%12s\00"
@.str.8 = [5 x i8] c"rk4:\00"
@.str.9 = [8 x i8] c" %12.6f\00"
@.str.10 = [35 x i8] c"\0A%12s %12.6f %12.6f %12.6f %12.6f\0A\00"
@.str.11 = [8 x i8] c"actual:\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 4)
%2 = tail call float* @vector(i32 1, i32 4)
%3 = tail call float* @vector(i32 1, i32 4)
%4 = tail call double @bessj0(float 1.000000e+00)
%5 = fptrunc double %4 to float
%6 = getelementptr inbounds float, float* %1, i64 1
store float %5, float* %6
%7 = tail call double @bessj1(float 1.000000e+00)
%8 = fptrunc double %7 to float
%9 = getelementptr inbounds float, float* %1, i64 2
store float %8, float* %9
%10 = tail call double @bessj(i32 2, float 1.000000e+00)
%11 = fptrunc double %10 to float
%12 = getelementptr inbounds float, float* %1, i64 3
store float %11, float* %12
%13 = tail call double @bessj(i32 3, float 1.000000e+00)
%14 = fptrunc double %13 to float
%15 = getelementptr inbounds float, float* %1, i64 4
store float %14, float* %15
%16 = tail call i32 @derivs(float 1.000000e+00, float* %1, float* %2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%18 = getelementptr inbounds float, float* %3, i64 1
%19 = getelementptr inbounds float, float* %3, i64 2
%20 = getelementptr inbounds float, float* %3, i64 3
%21 = getelementptr inbounds float, float* %3, i64 4
br label %22
22: ; preds = %0, %22
%23 = phi i32 [ 1, %0 ], [ %49, %22 ]
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 2.000000e-01
%26 = fptrunc double %25 to float
%27 = tail call i32 @rk4(float* %1, float* %2, i32 4, float 1.000000e+00, float %26, float* %3, i32 (float, float*, float*)* @derivs)
%28 = fpext float %26 to double
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %28)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%31 = load float, float* %18
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double %32)
%34 = load float, float* %19
%35 = fpext float %34 to double
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double %35)
%37 = load float, float* %20
%38 = fpext float %37 to double
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double %38)
%40 = load float, float* %21
%41 = fpext float %40 to double
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double %41)
%43 = fadd float %26, 1.000000e+00
%44 = tail call double @bessj0(float %43)
%45 = tail call double @bessj1(float %43)
%46 = tail call double @bessj(i32 2, float %43)
%47 = tail call double @bessj(i32 3, float %43)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), double %44, double %45, double %46, double %47)
%49 = add nuw nsw i32 %23, 1
%50 = icmp eq i32 %49, 6
br i1 %50, label %51, label %22
51: ; preds = %22
%52 = tail call i32 @free_vector(float* %3, i32 1, i32 4)
%53 = tail call i32 @free_vector(float* %2, i32 1, i32 4)
%54 = tail call i32 @free_vector(float* %1, i32 1, i32 4)
ret i32 0
}