#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double *malloc(int);
int /*<<< orphan*/ stderr;
double *integrate(double t0, int N, long M, double h, double *x0,
                  double *(*dx)(double t, double *x)) {
  double *y = malloc(N * M * sizeof(double));
  int n, m;
  if (y == NULL) {
    fprintf(stderr, "Insufficient memory");
    exit(1);
  }
  for (m = 0; n < M; n++) {
    y[0] = x0[m];
  }
  double k1[M], k2[M], k3[M], k4[M], t = t0;
  return y;
}


x86 assembly (clang, -O0):
<integrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movslq -0xc(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1193 <integrate+0x63>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x40(%rbp)
movslq -0x3c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11cb <integrate+0x9b>
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119a <integrate+0x6a>
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integrate>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
imul   %ebx,%edi
shl    $0x3,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1160 <integrate+0x30>
test   %rbx,%rbx
jle    1158 <integrate+0x28>
movsd  (%r14),%xmm0
movsd  %xmm0,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Insufficient memory\00"
define double* @integrate(double %0, i32 %1, i64 %2, double %3, double* %4, double* (double, double*)* %5) {
%7 = alloca double
%8 = alloca i32
%9 = alloca i64
%10 = alloca double
%11 = alloca double*
%12 = alloca double* (double, double*)*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca double
store double %0, double* %7
store i32 %1, i32* %8
store i64 %2, i64* %9
store double %3, double* %10
store double* %4, double** %11
store double* (double, double*)* %5, double* (double, double*)** %12
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = load i64, i64* %9
%25 = mul nsw i64 %23, %24
%26 = mul i64 %25, 8
%27 = trunc i64 %26 to i32
%28 = call double* @malloc(i32 %27)
store double* %28, double** %13
%29 = load double*, double** %13
%30 = icmp eq double* %29, null
br i1 %30, label %31, label %35
31: ; preds = %6
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %6
store i32 0, i32* %15
br label %36
36: ; preds = %49, %35
%37 = load i32, i32* %14
%38 = sext i32 %37 to i64
%39 = load i64, i64* %9
%40 = icmp slt i64 %38, %39
br i1 %40, label %41, label %52
41: ; preds = %36
%42 = load double*, double** %11
%43 = load i32, i32* %15
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = load double*, double** %13
%48 = getelementptr inbounds double, double* %47, i64 0
store double %46, double* %48
br label %49
49: ; preds = %41
%50 = load i32, i32* %14
%51 = add nsw i32 %50, 1
store i32 %51, i32* %14
br label %36
52: ; preds = %36
%53 = load i64, i64* %9
%54 = call i8* @llvm.stacksave()
store i8* %54, i8** %16
%55 = alloca double, i64 %53
store i64 %53, i64* %17
%56 = load i64, i64* %9
%57 = alloca double, i64 %56
store i64 %56, i64* %18
%58 = load i64, i64* %9
%59 = alloca double, i64 %58
store i64 %58, i64* %19
%60 = load i64, i64* %9
%61 = alloca double, i64 %60
store i64 %60, i64* %20
%62 = load double, double* %7
store double %62, double* %21
%63 = load double*, double** %13
%64 = load i8*, i8** %16
ret double* %63
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Insufficient memory\00"
define noalias double* @integrate(double %0, i32 %1, i64 %2, double %3, double* nocapture %4, double* (double, double*)* nocapture readnone %5) {
%7 = trunc i64 %2 to i32
%8 = shl i32 %1, 3
%9 = mul i32 %8, %7
%10 = tail call double* @malloc(i32 %9)
%11 = icmp eq double* %10, null
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = icmp sgt i64 %2, 0
br i1 %13, label %14, label %20
14: ; preds = %12
%15 = load double, double* %4
store double %15, double* %10
br label %20
16: ; preds = %6
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %14, %12
ret double* %10
}