void calc_thermal_matrix_LU(design) struct Design *design;
{
  double *flux, **R;
  void set_up_tfield(), set_up_flux(), set_up_coef_matrix();
  void LU_Decomp(), find_comp_temp(), find_contained_nodes();
  int i, j, node_dim[3], tot_nodes, hbw, width;
  printf("LU   ");
  set_up_tfield(design, node_dim);
  hbw = node_dim[1] * node_dim[2];
  width = 2 * hbw + 1;
  tot_nodes = node_dim[0] * hbw;
  find_contained_nodes(design, hbw, node_dim[2]);
  flux = (double *)malloc(sizeof(double) * tot_nodes);
  for (i = 0; i < tot_nodes; i++)
    flux[i] = 0.0;
  R = (double **)malloc(sizeof(double *) * tot_nodes);
  for (i = 0; i < tot_nodes; i++) {
    R[i] = (double *)malloc(sizeof(double) * width);
    for (j = 0; j < width; ++j)
      R[i][j] = 0.0;
  }
  set_up_flux(design, flux, tot_nodes);
  set_up_coef_matrix(design, flux, R, tot_nodes, hbw, node_dim[2]);
  LU_Decomp(design, R, flux, tot_nodes, hbw);
  find_comp_temp(design);
  for (i = 0; i < tot_nodes; i++)
    free(R[i]);
  free(R);
  free(flux);
}


x86 assembly (clang, -O0):
<calc_thermal_matrix_LU>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1090 <set_up_tfield@plt>
mov    -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1060 <find_contained_nodes@plt>
movslq -0x30(%rbp),%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    122c <calc_thermal_matrix_LU+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1202 <calc_thermal_matrix_LU+0x72>
movslq -0x30(%rbp),%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12b8 <calc_thermal_matrix_LU+0x128>
movslq -0x38(%rbp),%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    12a5 <calc_thermal_matrix_LU+0x115>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1273 <calc_thermal_matrix_LU+0xe3>
jmp    12aa <calc_thermal_matrix_LU+0x11a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1244 <calc_thermal_matrix_LU+0xb4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    $0x0,%al
call   1080 <set_up_flux@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    $0x0,%al
call   10a0 <set_up_coef_matrix@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    $0x0,%al
call   1050 <LU_Decomp@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   10b0 <find_comp_temp@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    133f <calc_thermal_matrix_LU+0x1af>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1314 <calc_thermal_matrix_LU+0x184>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_thermal_matrix_LU>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <set_up_tfield@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%r13d
imul   %edx,%r13d
mov    0xc(%rsp),%ebp
imul   %r13d,%ebp
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <find_contained_nodes@plt>
movslq %ebp,%rbx
lea    0x0(,%rbx,8),%rdi
mov    %rdi,0x18(%rsp)
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%r15d
test   %ebx,%ebx
jle    12ae <calc_thermal_matrix_LU+0x10e>
mov    %ebp,0x8(%rsp)
mov    %r14,0x30(%rsp)
lea    0x0(%r13,%r13,1),%r14d
mov    %r12,%rdi
mov    %r13,0x20(%rsp)
lea    0x1(%r13,%r13,1),%r12d
lea    0x0(,%r15,8),%rdx
xor    %r13d,%r13d
mov    %rdi,0x28(%rsp)
xor    %esi,%esi
call   1050 <memset@plt>
mov    0x18(%rsp),%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
movslq %r12d,%rbp
shl    $0x3,%rbp
mov    %r14d,%r14d
shl    $0x3,%r14
or     $0x8,%r14
jmp    1279 <calc_thermal_matrix_LU+0xd9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%r15
je     1299 <calc_thermal_matrix_LU+0xf9>
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,(%rbx,%r13,8)
test   %r12d,%r12d
jle    1270 <calc_thermal_matrix_LU+0xd0>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1050 <memset@plt>
jmp    1270 <calc_thermal_matrix_LU+0xd0>
mov    0x30(%rsp),%r14
mov    0x28(%rsp),%r12
mov    0x8(%rsp),%ebp
mov    0x20(%rsp),%r13
jmp    12bb <calc_thermal_matrix_LU+0x11b>
mov    0x18(%rsp),%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1090 <set_up_flux@plt>
mov    0x14(%rsp),%r9d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   10b0 <set_up_coef_matrix@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1060 <LU_Decomp@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   10c0 <find_comp_temp@plt>
test   %ebp,%ebp
jle    1322 <calc_thermal_matrix_LU+0x182>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1310 <calc_thermal_matrix_LU+0x170>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.Design = type opaque
@.str = [6 x i8] c"LU \00"
define void @calc_thermal_matrix_LU(%struct.Design* %0) {
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, %7
%11 = shl i32 %10, 1
%12 = or i32 %11, 1
%13 = load i32, i32* %5
%14 = mul i32 %13, %10
%15 = sext i32 %14 to i64
%16 = shl nsw i64 %15, 3
%17 = call i8* @malloc(i64 %16)
%18 = bitcast i8* %17 to double*
%19 = icmp sgt i32 %14, 0
br i1 %19, label %23, label %20
20: ; preds = %1
%21 = call i8* @malloc(i64 %16)
%22 = bitcast i8* %21 to double**
br label %44
23: ; preds = %1
%24 = zext i32 %14 to i64
%25 = shl nuw nsw i64 %24, 3
%26 = call i8* @malloc(i64 %16)
%27 = bitcast i8* %26 to double**
%28 = sext i32 %12 to i64
%29 = shl nsw i64 %28, 3
%30 = icmp sgt i32 %12, 0
%31 = zext i32 %11 to i64
%32 = shl nuw nsw i64 %31, 3
%33 = or i64 %32, 8
%34 = zext i32 %14 to i64
br label %35
35: ; preds = %23, %41
%36 = phi i64 [ 0, %23 ], [ %42, %41 ]
%37 = call i8* @malloc(i64 %29)
%38 = getelementptr inbounds double*, double** %27, i64 %36
%39 = bitcast double** %38 to i8**
store i8* %37, i8** %39
br i1 %30, label %40, label %41
40: ; preds = %35
br label %41
41: ; preds = %40, %35
%42 = add nuw nsw i64 %36, 1
%43 = icmp eq i64 %42, %34
br i1 %43, label %44, label %35
44: ; preds = %41, %20
%45 = phi double** [ %22, %20 ], [ %27, %41 ]
%46 = phi i8* [ %21, %20 ], [ %26, %41 ]
%47 = load i32, i32* %8
br i1 %19, label %48, label %57
48: ; preds = %44
%49 = zext i32 %14 to i64
br label %50
50: ; preds = %48, %50
%51 = phi i64 [ 0, %48 ], [ %55, %50 ]
%52 = getelementptr inbounds double*, double** %45, i64 %51
%53 = bitcast double** %52 to i8**
%54 = load i8*, i8** %53
%55 = add nuw nsw i64 %51, 1
%56 = icmp eq i64 %55, %49
br i1 %56, label %57, label %50
57: ; preds = %50, %44
ret void
}