#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*/ get_matrix(int, double *, double, double **, double **);
int /*<<< orphan*/ get_r_matrix(int, double *, double, double **, double *,
                                double *, int);
scalar_t__ gf_malloc(int);
int /*<<< orphan*/ lu(double **, int, double **);
int /*<<< orphan*/ lu_solve(double **, int, double *, double *);
void get_gf(int s, double **gf, int g, double *n, double theta, double **m) {
  double *fm1, *fs, **c, **clu, **a, **b;
  int i, j, k, l;
  fs = (double *)gf_malloc(sizeof(double) * g * (g + 1) / 2);
  c = (double **)gf_malloc(sizeof(double *) * g * (g + 1) / 2);
  for (i = 0; i < g * (g + 1) / 2; i++)
    c[i] = (double *)gf_malloc(sizeof(double) * g * (g + 1) / 2);
  clu = (double **)gf_malloc(sizeof(double *) * g * (g + 1) / 2);
  for (i = 0; i < g * (g + 1) / 2; i++)
    clu[i] = (double *)gf_malloc(sizeof(double) * g * (g + 1) / 2);
  get_matrix(g, n, theta, m, c);
  lu(c, g * (g + 1) / 2, clu);
  fm1 = NULL;
  for (k = 0; k <= s; k++) {
    get_r_matrix(g, n, theta, m, fm1, fs, k);
    lu_solve(clu, g * (g + 1) / 2, fs, gf[k]);
    fm1 = gf[k];
  }
}


x86 assembly (clang, -O0):
<get_gf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1070 <gf_malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1070 <gf_malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
cmp    %ecx,%eax
jge    1225 <get_gf+0xd5>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1070 <gf_malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11c1 <get_gf+0x71>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1070 <gf_malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cmp    %ecx,%eax
jge    12b4 <get_gf+0x164>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
shr    $0x1,%rax
mov    %eax,%edi
call   1070 <gf_malloc@plt>
mov    %rax,%rdx
mov    -0x50(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1250 <get_gf+0x100>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
call   1040 <get_matrix@plt>
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x50(%rbp),%rdx
call   1050 <lu@plt>
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1379 <get_gf+0x229>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x6c(%rbp),%r9d
call   1030 <get_r_matrix@plt>
mov    -0x50(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
call   1060 <lu_solve@plt>
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12ff <get_gf+0x1af>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r13
movsd  %xmm0,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rsi,%r15
mov    %rdi,0x40(%rsp)
lea    0x1(%rdx),%ebx
mov    %rdx,0x10(%rsp)
imul   %edx,%ebx
lea    0x0(,%rbx,4),%r12d
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %rax,%rbp
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %rax,0x8(%rsp)
mov    %ebx,%r14d
shr    $0x1f,%r14d
add    %ebx,%r14d
sar    %r14d
cmp    $0x1,%ebx
mov    %r13,(%rsp)
mov    %rbp,0x38(%rsp)
mov    %r15,0x30(%rsp)
jle    121c <get_gf+0xcc>
mov    %rbx,0x28(%rsp)
mov    %r14d,%r15d
xor    %ebp,%ebp
mov    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %rax,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11d0 <get_gf+0x80>
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %rax,%r13
cmpl   $0x2,0x28(%rsp)
mov    (%rsp),%rbp
jl     122a <get_gf+0xda>
xor    %ebp,%ebp
nopl   (%rax)
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <get_gf+0xb0>
mov    (%rsp),%rbp
jmp    122a <get_gf+0xda>
mov    %r12d,%edi
call   1070 <gf_malloc@plt>
mov    %r13,%rbp
mov    %rax,%r13
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
movsd  0x20(%rsp),%xmm0
mov    %rbp,%rdx
mov    0x8(%rsp),%r15
mov    %r15,%rcx
call   1040 <get_matrix@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r13,%rdx
call   1050 <lu@plt>
mov    0x40(%rsp),%rax
test   %eax,%eax
mov    %r14d,%r12d
mov    0x30(%rsp),%r14
mov    0x38(%rsp),%r15
js     12c4 <get_gf+0x174>
mov    %r13,%rbp
add    $0x1,%eax
xor    %ebx,%ebx
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %rax,%r13
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
movsd  0x20(%rsp),%xmm0
mov    (%rsp),%rdx
mov    %r15,%r8
mov    %ebx,%r9d
call   1030 <get_r_matrix@plt>
mov    (%r14,%rbx,8),%rcx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1060 <lu_solve@plt>
mov    %r13,%rax
mov    (%r14,%rbx,8),%rcx
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1280 <get_gf+0x130>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_gf(i32 %0, double** %1, i32 %2, double* %3, double %4, double** %5) {
%7 = alloca i32
%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 double**
%18 = alloca double**
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 %0, i32* %7
store double** %1, double*** %8
store i32 %2, i32* %9
store double* %3, double** %10
store double %4, double* %11
store double** %5, double*** %12
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = mul i64 8, %24
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 %25, %28
%30 = udiv i64 %29, 2
%31 = trunc i64 %30 to i32
%32 = call i64 @gf_malloc(i32 %31)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %14
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = mul i64 8, %35
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = mul i64 %36, %39
%41 = udiv i64 %40, 2
%42 = trunc i64 %41 to i32
%43 = call i64 @gf_malloc(i32 %42)
%44 = inttoptr i64 %43 to double**
store double** %44, double*** %15
store i32 0, i32* %19
br label %45
45: ; preds = %69, %6
%46 = load i32, i32* %19
%47 = load i32, i32* %9
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
%50 = mul nsw i32 %47, %49
%51 = sdiv i32 %50, 2
%52 = icmp slt i32 %46, %51
br i1 %52, label %53, label %72
53: ; preds = %45
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = mul i64 8, %55
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = mul i64 %56, %59
%61 = udiv i64 %60, 2
%62 = trunc i64 %61 to i32
%63 = call i64 @gf_malloc(i32 %62)
%64 = inttoptr i64 %63 to double*
%65 = load double**, double*** %15
%66 = load i32, i32* %19
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double*, double** %65, i64 %67
store double* %64, double** %68
br label %69
69: ; preds = %53
%70 = load i32, i32* %19
%71 = add nsw i32 %70, 1
store i32 %71, i32* %19
br label %45
72: ; preds = %45
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = mul i64 8, %74
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = mul i64 %75, %78
%80 = udiv i64 %79, 2
%81 = trunc i64 %80 to i32
%82 = call i64 @gf_malloc(i32 %81)
%83 = inttoptr i64 %82 to double**
store double** %83, double*** %16
store i32 0, i32* %19
br label %84
84: ; preds = %108, %72
%85 = load i32, i32* %19
%86 = load i32, i32* %9
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
%89 = mul nsw i32 %86, %88
%90 = sdiv i32 %89, 2
%91 = icmp slt i32 %85, %90
br i1 %91, label %92, label %111
92: ; preds = %84
%93 = load i32, i32* %9
%94 = sext i32 %93 to i64
%95 = mul i64 8, %94
%96 = load i32, i32* %9
%97 = add nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = mul i64 %95, %98
%100 = udiv i64 %99, 2
%101 = trunc i64 %100 to i32
%102 = call i64 @gf_malloc(i32 %101)
%103 = inttoptr i64 %102 to double*
%104 = load double**, double*** %16
%105 = load i32, i32* %19
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double*, double** %104, i64 %106
store double* %103, double** %107
br label %108
108: ; preds = %92
%109 = load i32, i32* %19
%110 = add nsw i32 %109, 1
store i32 %110, i32* %19
br label %84
111: ; preds = %84
%112 = load i32, i32* %9
%113 = load double*, double** %10
%114 = load double, double* %11
%115 = load double**, double*** %12
%116 = load double**, double*** %15
%117 = call i32 @get_matrix(i32 %112, double* %113, double %114, double** %115, double** %116)
%118 = load double**, double*** %15
%119 = load i32, i32* %9
%120 = load i32, i32* %9
%121 = add nsw i32 %120, 1
%122 = mul nsw i32 %119, %121
%123 = sdiv i32 %122, 2
%124 = load double**, double*** %16
%125 = call i32 @lu(double** %118, i32 %123, double** %124)
store double* null, double** %13
store i32 0, i32* %21
br label %126
126: ; preds = %157, %111
%127 = load i32, i32* %21
%128 = load i32, i32* %7
%129 = icmp sle i32 %127, %128
br i1 %129, label %130, label %160
130: ; preds = %126
%131 = load i32, i32* %9
%132 = load double*, double** %10
%133 = load double, double* %11
%134 = load double**, double*** %12
%135 = load double*, double** %13
%136 = load double*, double** %14
%137 = load i32, i32* %21
%138 = call i32 @get_r_matrix(i32 %131, double* %132, double %133, double** %134, double* %135, double* %136, i32 %137)
%139 = load double**, double*** %16
%140 = load i32, i32* %9
%141 = load i32, i32* %9
%142 = add nsw i32 %141, 1
%143 = mul nsw i32 %140, %142
%144 = sdiv i32 %143, 2
%145 = load double*, double** %14
%146 = load double**, double*** %8
%147 = load i32, i32* %21
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double*, double** %146, i64 %148
%150 = load double*, double** %149
%151 = call i32 @lu_solve(double** %139, i32 %144, double* %145, double* %150)
%152 = load double**, double*** %8
%153 = load i32, i32* %21
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double*, double** %152, i64 %154
%156 = load double*, double** %155
store double* %156, double** %13
br label %157
157: ; preds = %130
%158 = load i32, i32* %21
%159 = add nsw i32 %158, 1
store i32 %159, i32* %21
br label %126
160: ; preds = %126
ret void
}

LLVM IR (-O2):
define void @get_gf(i32 %0, double** nocapture %1, i32 %2, double* %3, double %4, double** %5) {
%7 = sext i32 %2 to i64
%8 = shl nsw i64 %7, 3
%9 = add nsw i32 %2, 1
%10 = sext i32 %9 to i64
%11 = mul i64 %8, %10
%12 = lshr exact i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = tail call i64 @gf_malloc(i32 %13)
%15 = inttoptr i64 %14 to double*
%16 = tail call i64 @gf_malloc(i32 %13)
%17 = inttoptr i64 %16 to double**
%18 = mul nsw i32 %9, %2
%19 = sdiv i32 %18, 2
%20 = icmp sgt i32 %18, 1
br i1 %20, label %24, label %21
21: ; preds = %6
%22 = tail call i64 @gf_malloc(i32 %13)
%23 = inttoptr i64 %22 to double**
br label %45
24: ; preds = %6
%25 = zext i32 %19 to i64
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ 0, %24 ], [ %31, %26 ]
%28 = tail call i64 @gf_malloc(i32 %13)
%29 = inttoptr i64 %28 to double*
%30 = getelementptr inbounds double*, double** %17, i64 %27
store double* %29, double** %30
%31 = add nuw nsw i64 %27, 1
%32 = icmp eq i64 %31, %25
br i1 %32, label %33, label %26
33: ; preds = %26
%34 = tail call i64 @gf_malloc(i32 %13)
%35 = inttoptr i64 %34 to double**
br i1 %20, label %36, label %45
36: ; preds = %33
%37 = zext i32 %19 to i64
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ 0, %36 ], [ %43, %38 ]
%40 = tail call i64 @gf_malloc(i32 %13)
%41 = inttoptr i64 %40 to double*
%42 = getelementptr inbounds double*, double** %35, i64 %39
store double* %41, double** %42
%43 = add nuw nsw i64 %39, 1
%44 = icmp eq i64 %43, %37
br i1 %44, label %45, label %38
45: ; preds = %38, %21, %33
%46 = phi double** [ %23, %21 ], [ %35, %33 ], [ %35, %38 ]
%47 = tail call i32 @get_matrix(i32 %2, double* %3, double %4, double** %5, double** %17)
%48 = tail call i32 @lu(double** %17, i32 %19, double** %46)
%49 = icmp slt i32 %0, 0
br i1 %49, label %64, label %50
50: ; preds = %45
%51 = add nuw i32 %0, 1
%52 = zext i32 %51 to i64
br label %53
53: ; preds = %50, %53
%54 = phi i64 [ 0, %50 ], [ %62, %53 ]
%55 = phi double* [ null, %50 ], [ %61, %53 ]
%56 = trunc i64 %54 to i32
%57 = tail call i32 @get_r_matrix(i32 %2, double* %3, double %4, double** %5, double* %55, double* %15, i32 %56)
%58 = getelementptr inbounds double*, double** %1, i64 %54
%59 = load double*, double** %58
%60 = tail call i32 @lu_solve(double** %46, i32 %19, double* %15, double* %59)
%61 = load double*, double** %58
%62 = add nuw nsw i64 %54, 1
%63 = icmp eq i64 %62, %52
br i1 %63, label %64, label %53
64: ; preds = %53, %45
ret void
}