#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*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ tridiag_free();
int /*<<< orphan*/ tridiag_malloc(int);
int /*<<< orphan*/ tridiag_premalloc(double *, double *, double *, double *,
                                     double *, int);
void implicit_precalc_2Dy(double *phi, double *ay, double *by, double *cy,
                          double dt, int L, int M, int Lstart, int Lend) {
  int ii, jj;
  double *b = malloc(M * sizeof(*b));
  double *r = malloc(M * sizeof(*r));
  tridiag_malloc(M);
  for (ii = Lstart; ii < Lend; ii++) {
    for (jj = 0; jj < M; jj++) {
      b[jj] = by[ii * M + jj] + 1 / dt;
      r[jj] = 1 / dt * phi[ii * M + jj];
    }
    tridiag_premalloc(&ay[ii * M], b, &cy[ii * M], r, &phi[ii * M], M);
  }
  tridiag_free();
  free(b);
  free(r);
}


x86 assembly (clang, -O0):
<implicit_precalc_2Dy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <tridiag_malloc@plt>
mov    0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    129b <implicit_precalc_2Dy+0x14b>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1240 <implicit_precalc_2Dy+0xf0>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe14(%rip),%xmm1
divsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xdf6(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c2 <implicit_precalc_2Dy+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x34(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x48(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x34(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x30(%rbp),%r9d
call   1040 <tridiag_premalloc@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11af <implicit_precalc_2Dy+0x5f>
mov    $0x0,%al
call   1050 <tridiag_free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<implicit_precalc_2Dy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9d,%ebx
movsd  %xmm0,0x8(%rsp)
mov    %rcx,0x68(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x60(%rsp)
mov    %rdi,(%rsp)
mov    0xd8(%rsp),%r12d
mov    0xd0(%rsp),%r14d
lea    0x0(,%rbx,8),%r15d
mov    %r15d,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r15d,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rbx,0x20(%rsp)
mov    %ebx,%edi
call   1070 <tridiag_malloc@plt>
mov    %r12d,0x14(%rsp)
cmp    %r12d,%r14d
jge    13e9 <implicit_precalc_2Dy+0x299>
movsd  0xe33(%rip),%xmm1
divsd  0x8(%rsp),%xmm1
movslq %r14d,%rsi
mov    0x20(%rsp),%rax
movslq %eax,%rcx
mov    %eax,%edi
mov    %edi,%eax
and    $0xfffffffe,%eax
mov    %rax,0x40(%rsp)
add    $0xfffffffffffffffe,%rax
mov    %rax,0x38(%rsp)
mov    %rax,%rdx
shr    %rdx
add    $0x1,%rdx
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
mov    %rdx,%rax
mov    %rdx,0x30(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,0x28(%rsp)
mov    %rsi,%rax
imul   %rcx,%rax
mov    (%rsp),%rdx
lea    (%rdx,%rax,8),%r13
add    $0x10,%r13
mov    %rcx,0x58(%rsp)
lea    0x0(,%rcx,8),%rcx
mov    %rcx,0x48(%rsp)
mov    0x18(%rsp),%rcx
lea    0x10(%rcx,%rax,8),%rbx
lea    (%rcx,%rax,8),%r12
lea    (%rdx,%rax,8),%r14
movapd %xmm1,0x80(%rsp)
mov    %rdi,0x50(%rsp)
movapd %xmm2,0x70(%rsp)
jmp    12cd <implicit_precalc_2Dy+0x17d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x60(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x68(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%r8
mov    %rbp,%rsi
mov    %r15,%rcx
call   1040 <tridiag_premalloc@plt>
movapd 0x70(%rsp),%xmm2
mov    0x50(%rsp),%rdi
movapd 0x80(%rsp),%xmm1
mov    0x8(%rsp),%rsi
add    $0x1,%rsi
mov    0x48(%rsp),%rax
add    %rax,%r13
add    %rax,%rbx
add    %rax,%r12
add    %rax,%r14
cmp    0x14(%rsp),%esi
je     13e9 <implicit_precalc_2Dy+0x299>
mov    %rsi,0x8(%rsp)
mov    %rsi,%rax
imul   0x58(%rsp),%rax
mov    0x20(%rsp),%r9
test   %r9d,%r9d
jle    1270 <implicit_precalc_2Dy+0x120>
cmp    $0x1,%r9d
jne    1300 <implicit_precalc_2Dy+0x1b0>
xor    %ecx,%ecx
jmp    13b0 <implicit_precalc_2Dy+0x260>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0x0,0x38(%rsp)
je     13de <implicit_precalc_2Dy+0x28e>
mov    0x28(%rsp),%rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movupd -0x10(%rbx,%rcx,8),%xmm0
addpd  %xmm2,%xmm0
movupd %xmm0,0x0(%rbp,%rcx,8)
movupd -0x10(%r13,%rcx,8),%xmm0
mulpd  %xmm2,%xmm0
movupd %xmm0,(%r15,%rcx,8)
movupd (%rbx,%rcx,8),%xmm0
addpd  %xmm2,%xmm0
movupd %xmm0,0x10(%rbp,%rcx,8)
movupd 0x0(%r13,%rcx,8),%xmm0
mulpd  %xmm2,%xmm0
movupd %xmm0,0x10(%r15,%rcx,8)
add    $0x4,%rcx
add    $0xfffffffffffffffe,%rdx
jne    1320 <implicit_precalc_2Dy+0x1d0>
testb  $0x1,0x30(%rsp)
je     139e <implicit_precalc_2Dy+0x24e>
lea    (%rcx,%rax,1),%rdx
mov    0x18(%rsp),%rsi
movupd (%rsi,%rdx,8),%xmm0
addpd  %xmm2,%xmm0
movupd %xmm0,0x0(%rbp,%rcx,8)
mov    (%rsp),%rsi
movupd (%rsi,%rdx,8),%xmm0
mulpd  %xmm2,%xmm0
movupd %xmm0,(%r15,%rcx,8)
mov    0x40(%rsp),%rdx
mov    %rdx,%rcx
cmp    %rdi,%rdx
je     1270 <implicit_precalc_2Dy+0x120>
nop
movsd  (%r12,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%rcx,8)
movsd  (%r14,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rdi
jne    13b0 <implicit_precalc_2Dy+0x260>
jmp    1270 <implicit_precalc_2Dy+0x120>
xor    %ecx,%ecx
testb  $0x1,0x30(%rsp)
jne    1373 <implicit_precalc_2Dy+0x223>
jmp    139e <implicit_precalc_2Dy+0x24e>
xor    %eax,%eax
call   1050 <tridiag_free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @implicit_precalc_2Dy(double* %0, double* %1, double* %2, double* %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double*
%22 = alloca double*
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store double %4, double* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%23 = load i32, i32* %16
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call double* @malloc(i32 %26)
store double* %27, double** %21
%28 = load i32, i32* %16
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 8
%31 = trunc i64 %30 to i32
%32 = call double* @malloc(i32 %31)
store double* %32, double** %22
%33 = load i32, i32* %16
%34 = call i32 @tridiag_malloc(i32 %33)
%35 = load i32, i32* %17
store i32 %35, i32* %19
br label %36
36: ; preds = %104, %9
%37 = load i32, i32* %19
%38 = load i32, i32* %18
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %107
40: ; preds = %36
store i32 0, i32* %20
br label %41
41: ; preds = %78, %40
%42 = load i32, i32* %20
%43 = load i32, i32* %16
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %81
45: ; preds = %41
%46 = load double*, double** %12
%47 = load i32, i32* %19
%48 = load i32, i32* %16
%49 = mul nsw i32 %47, %48
%50 = load i32, i32* %20
%51 = add nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %46, i64 %52
%54 = load double, double* %53
%55 = load double, double* %14
%56 = fdiv double 1.000000e+00, %55
%57 = fadd double %54, %56
%58 = load double*, double** %21
%59 = load i32, i32* %20
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
%62 = load double, double* %14
%63 = fdiv double 1.000000e+00, %62
%64 = load double*, double** %10
%65 = load i32, i32* %19
%66 = load i32, i32* %16
%67 = mul nsw i32 %65, %66
%68 = load i32, i32* %20
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %64, i64 %70
%72 = load double, double* %71
%73 = fmul double %63, %72
%74 = load double*, double** %22
%75 = load i32, i32* %20
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
store double %73, double* %77
br label %78
78: ; preds = %45
%79 = load i32, i32* %20
%80 = add nsw i32 %79, 1
store i32 %80, i32* %20
br label %41
81: ; preds = %41
%82 = load double*, double** %11
%83 = load i32, i32* %19
%84 = load i32, i32* %16
%85 = mul nsw i32 %83, %84
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %82, i64 %86
%88 = load double*, double** %21
%89 = load double*, double** %13
%90 = load i32, i32* %19
%91 = load i32, i32* %16
%92 = mul nsw i32 %90, %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %89, i64 %93
%95 = load double*, double** %22
%96 = load double*, double** %10
%97 = load i32, i32* %19
%98 = load i32, i32* %16
%99 = mul nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %96, i64 %100
%102 = load i32, i32* %16
%103 = call i32 @tridiag_premalloc(double* %87, double* %88, double* %94, double* %95, double* %101, i32 %102)
br label %104
104: ; preds = %81
%105 = load i32, i32* %19
%106 = add nsw i32 %105, 1
store i32 %106, i32* %19
br label %36
107: ; preds = %36
%108 = call i32 (...) @tridiag_free()
%109 = load double*, double** %21
%110 = call i32 @free(double* %109)
%111 = load double*, double** %22
%112 = call i32 @free(double* %111)
ret void
}

LLVM IR (-O2):
define void @implicit_precalc_2Dy(double* %0, double* %1, double* nocapture %2, double* %3, double %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = shl i32 %6, 3
%11 = tail call double* @malloc(i32 %10)
%12 = tail call double* @malloc(i32 %10)
%13 = tail call i32 @tridiag_malloc(i32 %6)
%14 = icmp slt i32 %7, %8
br i1 %14, label %15, label %112
15: ; preds = %9
%16 = icmp sgt i32 %6, 0
%17 = fdiv double 1.000000e+00, %4
%18 = sext i32 %7 to i64
%19 = sext i32 %6 to i64
%20 = zext i32 %6 to i64
%21 = and i64 %20, 4294967294
%22 = add nsw i64 %21, -2
%23 = lshr exact i64 %22, 1
%24 = add nuw i64 %23, 1
%25 = icmp eq i32 %6, 1
%26 = and i64 %20, 4294967294
%27 = insertelement <2 x double> poison, double %17, i64 0
%28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> zeroinitializer
%29 = and i64 %24, 1
%30 = icmp eq i64 %22, 0
%31 = and i64 %24, -2
%32 = icmp eq i64 %29, 0
%33 = icmp eq i64 %26, %20
br label %34
34: ; preds = %15, %104
%35 = phi i64 [ %18, %15 ], [ %109, %104 ]
%36 = mul nsw i64 %35, %19
br i1 %16, label %37, label %104
37: ; preds = %34
br i1 %25, label %89, label %38
38: ; preds = %37
br i1 %30, label %72, label %39
39: ; preds = %38, %39
%40 = phi i64 [ %69, %39 ], [ 0, %38 ]
%41 = phi i64 [ %70, %39 ], [ 0, %38 ]
%42 = add nsw i64 %40, %36
%43 = getelementptr inbounds double, double* %2, i64 %42
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = fadd <2 x double> %28, %45
%47 = getelementptr inbounds double, double* %11, i64 %40
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %46, <2 x double>* %48
%49 = getelementptr inbounds double, double* %0, i64 %42
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fmul <2 x double> %28, %51
%53 = getelementptr inbounds double, double* %12, i64 %40
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %52, <2 x double>* %54
%55 = or i64 %40, 2
%56 = add nsw i64 %55, %36
%57 = getelementptr inbounds double, double* %2, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = fadd <2 x double> %28, %59
%61 = getelementptr inbounds double, double* %11, i64 %55
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %60, <2 x double>* %62
%63 = getelementptr inbounds double, double* %0, i64 %56
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = fmul <2 x double> %28, %65
%67 = getelementptr inbounds double, double* %12, i64 %55
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %66, <2 x double>* %68
%69 = add nuw i64 %40, 4
%70 = add nuw i64 %41, 2
%71 = icmp eq i64 %70, %31
br i1 %71, label %72, label %39
72: ; preds = %39, %38
%73 = phi i64 [ 0, %38 ], [ %69, %39 ]
br i1 %32, label %88, label %74
74: ; preds = %72
%75 = add nsw i64 %73, %36
%76 = getelementptr inbounds double, double* %2, i64 %75
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = fadd <2 x double> %28, %78
%80 = getelementptr inbounds double, double* %11, i64 %73
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %79, <2 x double>* %81
%82 = getelementptr inbounds double, double* %0, i64 %75
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = fmul <2 x double> %28, %84
%86 = getelementptr inbounds double, double* %12, i64 %73
%87 = bitcast double* %86 to <2 x double>*
store <2 x double> %85, <2 x double>* %87
br label %88
88: ; preds = %72, %74
br i1 %33, label %104, label %89
89: ; preds = %37, %88
%90 = phi i64 [ 0, %37 ], [ %26, %88 ]
br label %91
91: ; preds = %89, %91
%92 = phi i64 [ %102, %91 ], [ %90, %89 ]
%93 = add nsw i64 %92, %36
%94 = getelementptr inbounds double, double* %2, i64 %93
%95 = load double, double* %94
%96 = fadd double %17, %95
%97 = getelementptr inbounds double, double* %11, i64 %92
store double %96, double* %97
%98 = getelementptr inbounds double, double* %0, i64 %93
%99 = load double, double* %98
%100 = fmul double %17, %99
%101 = getelementptr inbounds double, double* %12, i64 %92
store double %100, double* %101
%102 = add nuw nsw i64 %92, 1
%103 = icmp eq i64 %102, %20
br i1 %103, label %104, label %91
104: ; preds = %91, %88, %34
%105 = getelementptr inbounds double, double* %1, i64 %36
%106 = getelementptr inbounds double, double* %3, i64 %36
%107 = getelementptr inbounds double, double* %0, i64 %36
%108 = tail call i32 @tridiag_premalloc(double* %105, double* %11, double* %106, double* %12, double* %107, i32 %6)
%109 = add nsw i64 %35, 1
%110 = trunc i64 %109 to i32
%111 = icmp eq i32 %110, %8
br i1 %111, label %112, label %34
112: ; preds = %104, %9
%113 = tail call i32 (...) @tridiag_free()
%114 = tail call i32 @free(double* %11)
%115 = tail call i32 @free(double* %12)
ret void
}