void thermal_analysis_MM(design) struct Design *design;
{
  double *flux, **R;
  void set_up_tfield(), set_up_flux(), set_up_coef_matrix();
  void gauss_seidel(), LU_Decomp(), find_comp_temp(), find_contained_nodes();
  int i, j, node_dim[3], tot_nodes, hbw, width;
  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):
<thermal_analysis_MM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1080 <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   1050 <find_contained_nodes@plt>
movslq -0x30(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    120e <thermal_analysis_MM+0x8e>
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    11e4 <thermal_analysis_MM+0x64>
movslq -0x30(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    129a <thermal_analysis_MM+0x11a>
movslq -0x38(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <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    1287 <thermal_analysis_MM+0x107>
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    1255 <thermal_analysis_MM+0xd5>
jmp    128c <thermal_analysis_MM+0x10c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1226 <thermal_analysis_MM+0xa6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    $0x0,%al
call   1070 <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   1090 <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   1040 <LU_Decomp@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   10a0 <find_comp_temp@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1321 <thermal_analysis_MM+0x1a1>
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    12f6 <thermal_analysis_MM+0x176>
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):
<thermal_analysis_MM>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r12
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <set_up_tfield@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%r13d
imul   %edx,%r13d
mov    0xc(%rsp),%ebp
imul   %r13d,%ebp
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <find_contained_nodes@plt>
movslq %ebp,%rbx
lea    0x0(,%rbx,8),%rdi
mov    %rdi,0x18(%rsp)
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%r15d
test   %ebx,%ebx
jle    128e <thermal_analysis_MM+0xfe>
mov    %ebp,0x8(%rsp)
mov    %r12,0x28(%rsp)
mov    %r14,%rdi
lea    0x0(%r13,%r13,1),%r14d
mov    %r13,0x20(%rsp)
lea    0x1(%r13,%r13,1),%r12d
lea    0x0(,%r15,8),%rdx
xor    %r13d,%r13d
mov    %rdi,0x30(%rsp)
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x18(%rsp),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
movslq %r12d,%rbp
shl    $0x3,%rbp
mov    %r14d,%r14d
shl    $0x3,%r14
or     $0x8,%r14
jmp    1259 <thermal_analysis_MM+0xc9>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r13
cmp    %r13,%r15
je     1279 <thermal_analysis_MM+0xe9>
mov    %rbp,%rdi
call   1070 <malloc@plt>
mov    %rax,(%rbx,%r13,8)
test   %r12d,%r12d
jle    1250 <thermal_analysis_MM+0xc0>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
jmp    1250 <thermal_analysis_MM+0xc0>
mov    0x30(%rsp),%r14
mov    0x28(%rsp),%r12
mov    0x8(%rsp),%ebp
mov    0x20(%rsp),%r13
jmp    129b <thermal_analysis_MM+0x10b>
mov    0x18(%rsp),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <set_up_flux@plt>
mov    0x14(%rsp),%r9d
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   10a0 <set_up_coef_matrix@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1050 <LU_Decomp@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   10b0 <find_comp_temp@plt>
test   %ebp,%ebp
jle    1302 <thermal_analysis_MM+0x172>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    12f0 <thermal_analysis_MM+0x160>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%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
define void @thermal_analysis_MM(%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 = load %struct.Design*, %struct.Design** %2
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%16 = load i32, i32* %15
%17 = mul nsw i32 %14, %16
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = mul nsw i32 2, %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %10
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%22 = load i32, i32* %21
%23 = load i32, i32* %9
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %8
%25 = load %struct.Design*, %struct.Design** %2
%26 = load i32, i32* %9
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%28 = load i32, i32* %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = mul i64 8, %30
%32 = call i8* @malloc(i64 %31)
%33 = bitcast i8* %32 to double*
store double* %33, double** %3
store i32 0, i32* %5
br label %34
34: ; preds = %43, %1
%35 = load i32, i32* %5
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load double*, double** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double 0.000000e+00, double* %42
br label %43
43: ; preds = %38
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %34
46: ; preds = %34
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = mul i64 8, %48
%50 = call i8* @malloc(i64 %49)
%51 = bitcast i8* %50 to double**
store double** %51, double*** %4
store i32 0, i32* %5
br label %52
52: ; preds = %83, %46
%53 = load i32, i32* %5
%54 = load i32, i32* %8
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %86
56: ; preds = %52
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = mul i64 8, %58
%60 = call i8* @malloc(i64 %59)
%61 = bitcast i8* %60 to double*
%62 = load double**, double*** %4
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double*, double** %62, i64 %64
store double* %61, double** %65
store i32 0, i32* %6
br label %66
66: ; preds = %79, %56
%67 = load i32, i32* %6
%68 = load i32, i32* %10
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %82
70: ; preds = %66
%71 = load double**, double*** %4
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double*, double** %71, i64 %73
%75 = load double*, double** %74
%76 = load i32, i32* %6
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
store double 0.000000e+00, double* %78
br label %79
79: ; preds = %70
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %66
82: ; preds = %66
br label %83
83: ; preds = %82
%84 = load i32, i32* %5
%85 = add nsw i32 %84, 1
store i32 %85, i32* %5
br label %52
86: ; preds = %52
%87 = load %struct.Design*, %struct.Design** %2
%88 = load double*, double** %3
%89 = load i32, i32* %8
%90 = load %struct.Design*, %struct.Design** %2
%91 = load double*, double** %3
%92 = load double**, double*** %4
%93 = load i32, i32* %8
%94 = load i32, i32* %9
%95 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%96 = load i32, i32* %95
%97 = load %struct.Design*, %struct.Design** %2
%98 = load double**, double*** %4
%99 = load double*, double** %3
%100 = load i32, i32* %8
%101 = load i32, i32* %9
%102 = load %struct.Design*, %struct.Design** %2
store i32 0, i32* %5
br label %103
103: ; preds = %114, %86
%104 = load i32, i32* %5
%105 = load i32, i32* %8
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %117
107: ; preds = %103
%108 = load double**, double*** %4
%109 = load i32, i32* %5
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds double*, double** %108, i64 %110
%112 = load double*, double** %111
%113 = bitcast double* %112 to i8*
br label %114
114: ; preds = %107
%115 = load i32, i32* %5
%116 = add nsw i32 %115, 1
store i32 %116, i32* %5
br label %103
117: ; preds = %103
%118 = load double**, double*** %4
%119 = bitcast double** %118 to i8*
%120 = load double*, double** %3
%121 = bitcast double* %120 to i8*
ret void
}

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