#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*/ derivs(double, float *, float *);
int /*<<< orphan*/ free_matrix(float **, int, int, int, int);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ jacobn(double, float *, float *, float **, int);
float **matrix(int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ simpr(float *, float *, float *, float **, int, double,
                         double, int, float *,
                         int /*<<< orphan*/ (*)(double, float *, float *));
float *vector(int, int);
int main(void) {
  int i;
  float a1 = 0.5976, a2 = 1.4023, a3 = 0.0, *y, *yout, *dfdx, **dfdy, *dydx;
  y = vector(1, 3);
  yout = vector(1, 3);
  dfdx = vector(1, 3);
  dfdy = matrix(1, 3, 1, 3);
  dydx = vector(1, 3);
  y[1] = y[2] = 1.0;
  y[3] = 0.0;
  derivs(0.0, y, dydx);
  jacobn(0.0, y, dfdx, dfdy, 3);
  printf("Test Problem:\n");
  for (i = 5; i <= 50; i += 5) {
    simpr(y, dydx, dfdx, dfdy, 3, 0.0, 50.0, i, yout, derivs);
    printf("\n%s %5.2f %s %5.2f %s %2d %s \n", "x=", 0.0, " to ", 0.0 + 50.0,
           " in ", i, " steps");
    printf("%14s %9s\n", "integration", "bessj");
    printf("%12.6f %12.6f\n", yout[1], a1);
    printf("%12.6f %12.6f\n", yout[2], a2);
    printf("%12.6f %12.6f\n", yout[3], a3);
  }
  free_vector(dydx, 1, 3);
  free_matrix(dfdy, 1, 3, 1, 3);
  free_vector(dfdx, 1, 3);
  free_vector(yout, 1, 3);
  free_vector(y, 1, 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe81(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe70(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x1,%edi
mov    $0x3,%esi
call   1070 <vector@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x3,%esi
call   1070 <vector@plt>
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
mov    $0x3,%esi
call   1070 <vector@plt>
mov    %rax,-0x30(%rbp)
mov    $0x1,%edx
mov    $0x3,%ecx
mov    %edx,%edi
mov    %ecx,%esi
call   1060 <matrix@plt>
mov    %rax,-0x38(%rbp)
mov    $0x1,%edi
mov    $0x3,%esi
call   1070 <vector@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movss  0xdf0(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movss  0xddf(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
xorps  %xmm0,%xmm0
call   10a0 <derivs@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
xorps  %xmm0,%xmm0
mov    $0x3,%ecx
call   1080 <jacobn@plt>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x5,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jg     1387 <main+0x217>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x8(%rbp),%r9d
mov    -0x28(%rbp),%r10
mov    $0x3,%r8d
xorps  %xmm0,%xmm0
movsd  0xd6d(%rip),%xmm1
mov    0x2d3e(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1090 <simpr@plt>
mov    -0x8(%rbp),%r8d
lea    0xd64(%rip),%rdi
lea    0xd7c(%rip),%rsi
xorps  %xmm0,%xmm0
lea    0xd75(%rip),%rdx
movsd  0xd34(%rip),%xmm1
lea    0xd6b(%rip),%rcx
lea    0xd69(%rip),%r9
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xd62(%rip),%rdi
lea    0xd65(%rip),%rsi
lea    0xd6a(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd4c(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movss  0x8(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd28(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movss  0xc(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd04(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x8(%rbp)
jmp    1270 <main+0x100>
mov    -0x40(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <free_vector@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1,%ecx
mov    $0x3,%r8d
mov    %ecx,%esi
mov    %r8d,%edx
call   1030 <free_matrix@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <free_vector@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <free_vector@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0x3,%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
push   %rax
mov    $0x1,%edi
mov    $0x3,%esi
call   1080 <vector@plt>
mov    %rax,%rbp
mov    $0x1,%edi
mov    $0x3,%esi
call   1080 <vector@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    $0x3,%esi
call   1080 <vector@plt>
mov    %rax,%r14
mov    $0x1,%edi
mov    $0x3,%esi
mov    $0x1,%edx
mov    $0x3,%ecx
call   1070 <matrix@plt>
mov    %rax,%r12
mov    $0x1,%edi
mov    $0x3,%esi
call   1080 <vector@plt>
mov    %rax,%r13
movabs $0x3f8000003f800000,%rax
mov    %rax,0x4(%rbp)
movl   $0x0,0xc(%rbp)
xorps  %xmm0,%xmm0
mov    %rbp,%rdi
mov    %r13,%rsi
call   10b0 <derivs@plt>
xorps  %xmm0,%xmm0
mov    %rbp,(%rsp)
mov    %rbp,%rdi
mov    %r14,%r15
mov    %r14,%rsi
mov    %r12,%rdx
mov    $0x3,%ecx
call   1090 <jacobn@plt>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
lea    0xe25(%rip),%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x5,%r14d
xorps  %xmm0,%xmm0
mov    (%rsp),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0x3,%r8d
movsd  0xd8e(%rip),%xmm1
mov    %r14d,%r9d
push   0x2d6d(%rip)
push   %rbx
call   10a0 <simpr@plt>
add    $0x10,%rsp
xorps  %xmm0,%xmm0
lea    0xd89(%rip),%rdi
lea    0xda1(%rip),%rsi
lea    0xd9d(%rip),%rdx
movsd  0xd5b(%rip),%xmm1
lea    0xd93(%rip),%rcx
mov    %r14d,%r8d
lea    0xd8e(%rip),%r9
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xd87(%rip),%rdi
lea    0xd8a(%rip),%rsi
lea    0xd8f(%rip),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
movsd  0xd1b(%rip),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
movsd  0xd08(%rip),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
mov    %rbp,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
cmp    $0x2e,%r14d
jb     1250 <main+0xd0>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1060 <free_vector@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x1,%ecx
mov    $0x3,%r8d
call   1040 <free_matrix@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1060 <free_vector@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1060 <free_vector@plt>
mov    (%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Test Problem:\0A\00"
@.str.1 = [31 x i8] c"\0A%s %5.2f %s %5.2f %s %2d %s \0A\00"
@.str.2 = [3 x i8] c"x=\00"
@.str.3 = [5 x i8] c" to \00"
@.str.4 = [5 x i8] c" in \00"
@.str.5 = [7 x i8] c" steps\00"
@.str.6 = [10 x i8] c"%14s %9s\0A\00"
@.str.7 = [12 x i8] c"integration\00"
@.str.8 = [6 x i8] c"bessj\00"
@.str.9 = [15 x i8] c"%12.6f %12.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float**
%10 = alloca float*
store i32 0, i32* %1
store float 0x3FE31F8A00000000, float* %3
store float 0x3FF66FD220000000, float* %4
store float 0.000000e+00, float* %5
%11 = call float* @vector(i32 1, i32 3)
store float* %11, float** %6
%12 = call float* @vector(i32 1, i32 3)
store float* %12, float** %7
%13 = call float* @vector(i32 1, i32 3)
store float* %13, float** %8
%14 = call float** @matrix(i32 1, i32 3, i32 1, i32 3)
store float** %14, float*** %9
%15 = call float* @vector(i32 1, i32 3)
store float* %15, float** %10
%16 = load float*, float** %6
%17 = getelementptr inbounds float, float* %16, i64 2
store float 1.000000e+00, float* %17
%18 = load float*, float** %6
%19 = getelementptr inbounds float, float* %18, i64 1
store float 1.000000e+00, float* %19
%20 = load float*, float** %6
%21 = getelementptr inbounds float, float* %20, i64 3
store float 0.000000e+00, float* %21
%22 = load float*, float** %6
%23 = load float*, float** %10
%24 = call i32 @derivs(double 0.000000e+00, float* %22, float* %23)
%25 = load float*, float** %6
%26 = load float*, float** %8
%27 = load float**, float*** %9
%28 = call i32 @jacobn(double 0.000000e+00, float* %25, float* %26, float** %27, i32 3)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 5, i32* %2
br label %30
30: ; preds = %65, %0
%31 = load i32, i32* %2
%32 = icmp sle i32 %31, 50
br i1 %32, label %33, label %68
33: ; preds = %30
%34 = load float*, float** %6
%35 = load float*, float** %10
%36 = load float*, float** %8
%37 = load float**, float*** %9
%38 = load i32, i32* %2
%39 = load float*, float** %7
%40 = call i32 @simpr(float* %34, float* %35, float* %36, float** %37, i32 3, double 0.000000e+00, double 5.000000e+01, i32 %38, float* %39, i32 (double, float*, float*)* @derivs)
%41 = load i32, i32* %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double 0.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double 5.000000e+01, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%44 = load float*, float** %7
%45 = getelementptr inbounds float, float* %44, i64 1
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = load float, float* %3
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %47, double %49)
%51 = load float*, float** %7
%52 = getelementptr inbounds float, float* %51, i64 2
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = load float, float* %4
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %54, double %56)
%58 = load float*, float** %7
%59 = getelementptr inbounds float, float* %58, i64 3
%60 = load float, float* %59
%61 = fpext float %60 to double
%62 = load float, float* %5
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %61, double %63)
br label %65
65: ; preds = %33
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 5
store i32 %67, i32* %2
br label %30
68: ; preds = %30
%69 = load float*, float** %10
%70 = call i32 @free_vector(float* %69, i32 1, i32 3)
%71 = load float**, float*** %9
%72 = call i32 @free_matrix(float** %71, i32 1, i32 3, i32 1, i32 3)
%73 = load float*, float** %8
%74 = call i32 @free_vector(float* %73, i32 1, i32 3)
%75 = load float*, float** %7
%76 = call i32 @free_vector(float* %75, i32 1, i32 3)
%77 = load float*, float** %6
%78 = call i32 @free_vector(float* %77, i32 1, i32 3)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"\0A%s %5.2f %s %5.2f %s %2d %s \0A\00"
@.str.2 = [3 x i8] c"x=\00"
@.str.3 = [5 x i8] c" to \00"
@.str.4 = [5 x i8] c" in \00"
@.str.5 = [7 x i8] c" steps\00"
@.str.6 = [10 x i8] c"%14s %9s\0A\00"
@.str.7 = [12 x i8] c"integration\00"
@.str.8 = [6 x i8] c"bessj\00"
@.str.9 = [15 x i8] c"%12.6f %12.6f\0A\00"
@str = [14 x i8] c"Test Problem:\00"
define i32 @main() {
%1 = tail call float* @vector(i32 1, i32 3)
%2 = tail call float* @vector(i32 1, i32 3)
%3 = tail call float* @vector(i32 1, i32 3)
%4 = tail call float** @matrix(i32 1, i32 3, i32 1, i32 3)
%5 = tail call float* @vector(i32 1, i32 3)
%6 = getelementptr inbounds float, float* %1, i64 2
store float 1.000000e+00, float* %6
%7 = getelementptr inbounds float, float* %1, i64 1
store float 1.000000e+00, float* %7
%8 = getelementptr inbounds float, float* %1, i64 3
store float 0.000000e+00, float* %8
%9 = tail call i32 @derivs(double 0.000000e+00, float* %1, float* %5)
%10 = tail call i32 @jacobn(double 0.000000e+00, float* %1, float* %3, float** %4, i32 3)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%12 = getelementptr inbounds float, float* %2, i64 1
%13 = getelementptr inbounds float, float* %2, i64 2
%14 = getelementptr inbounds float, float* %2, i64 3
br label %15
15: ; preds = %0, %15
%16 = phi i32 [ 5, %0 ], [ %29, %15 ]
%17 = tail call i32 @simpr(float* %1, float* %5, float* %3, float** %4, i32 3, double 0.000000e+00, double 5.000000e+01, i32 %16, float* %2, i32 (double, float*, float*)* @derivs)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), double 0.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double 5.000000e+01, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%20 = load float, float* %12
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %21, double 0x3FE31F8A00000000)
%23 = load float, float* %13
%24 = fpext float %23 to double
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %24, double 0x3FF66FD220000000)
%26 = load float, float* %14
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %27, double 0.000000e+00)
%29 = add nuw nsw i32 %16, 5
%30 = icmp ult i32 %16, 46
br i1 %30, label %15, label %31
31: ; preds = %15
%32 = tail call i32 @free_vector(float* %5, i32 1, i32 3)
%33 = tail call i32 @free_matrix(float** %4, i32 1, i32 3, i32 1, i32 3)
%34 = tail call i32 @free_vector(float* %3, i32 1, i32 3)
%35 = tail call i32 @free_vector(float* %2, i32 1, i32 3)
%36 = tail call i32 @free_vector(float* %1, i32 1, i32 3)
ret i32 0
}