void inertial(struct vtx_data **graph, int nvtxs, int cube_or_mesh, int nsets,
              int igeom, float **coords, int *sets, double *goal,
              int using_vwgts) {
  extern int DEBUG_TRACE;
  extern int PROJECTION_AXIS;
  extern double inertial_time;
  double time;
  float *inert_coords[3];
  int i, j;
  double seconds();
  void inertial1d(), inertial2d(), inertial3d();
  time = seconds();
  if (DEBUG_TRACE > 0) {
    printf("<Entering inertial, nvtxs = %d>\n", nvtxs);
  }
  if (PROJECTION_AXIS == 0) {
    for (i = 0; i < igeom; i++) {
      inert_coords[i] = coords[i];
    }
  } else {
    j = 0;
    for (i = 0; i < igeom; i++) {
      if (PROJECTION_AXIS != i + 1) {
        inert_coords[j] = coords[i];
        j++;
      }
    }
    --igeom;
  }
  if (igeom == 1) {
    inertial1d(graph, nvtxs, cube_or_mesh, nsets, inert_coords[0], sets, goal,
               using_vwgts);
  } else if (igeom == 2) {
    inertial2d(graph, nvtxs, cube_or_mesh, nsets, inert_coords[0],
               inert_coords[1], sets, goal, using_vwgts);
  } else if (igeom == 3) {
    inertial3d(graph, nvtxs, cube_or_mesh, nsets, inert_coords[0],
               inert_coords[1], inert_coords[2], sets, goal, using_vwgts);
  }
  inertial_time += seconds() - time;
}


x86 assembly (clang, -O0):
<inertial>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    $0x0,%al
call   1050 <seconds@plt>
movsd  %xmm0,-0x30(%rbp)
mov    0x2e3c(%rip),%rax
cmpl   $0x0,(%rax)
jle    11a6 <inertial+0x56>
mov    -0x14(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e33(%rip),%rax
cmpl   $0x0,(%rax)
jne    11f1 <inertial+0xa1>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11ec <inertial+0x9c>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11bd <inertial+0x6d>
jmp    125c <inertial+0x10c>
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1253 <inertial+0x103>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    -0x54(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     1240 <inertial+0xf0>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x58(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1245 <inertial+0xf5>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ff <inertial+0xaf>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    1296 <inertial+0x146>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <inertial1d@plt>
jmp    132a <inertial+0x1da>
cmpl   $0x2,-0x20(%rbp)
jne    12d9 <inertial+0x189>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <inertial2d@plt>
jmp    1325 <inertial+0x1d5>
cmpl   $0x3,-0x20(%rbp)
jne    1320 <inertial+0x1d0>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    -0x40(%rbp),%rbx
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1070 <inertial3d@plt>
jmp    1325 <inertial+0x1d5>
jmp    132a <inertial+0x1da>
mov    $0x0,%al
call   1050 <seconds@plt>
subsd  -0x30(%rbp),%xmm0
mov    0x2c9b(%rip),%rax
addsd  (%rax),%xmm0
mov    0x2c90(%rip),%rax
movsd  %xmm0,(%rax)
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<inertial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%r13d
mov    %rdi,%r12
xor    %eax,%eax
call   1050 <seconds@plt>
movsd  %xmm0,0x20(%rsp)
mov    0x2e35(%rip),%rax
cmpl   $0x0,(%rax)
jle    11a9 <inertial+0x49>
lea    0xe61(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%r9d
test   %r9,%r9
je     11f4 <inertial+0x94>
mov    %ebp,%r10d
test   %r14d,%r14d
jle    11eb <inertial+0x8b>
mov    %r14d,%r8d
cmp    $0x1,%r14d
jne    12c6 <inertial+0x166>
xor    %ebp,%ebp
xor    %edx,%edx
test   $0x1,%r8b
je     11eb <inertial+0x8b>
lea    0x1(%rbp),%rax
cmp    %r9,%rax
je     11eb <inertial+0x8b>
mov    (%rbx,%rbp,8),%rax
movslq %edx,%rcx
mov    %rax,(%rsp,%rcx,8)
add    $0xffffffff,%r14d
mov    %r10d,%ebp
jmp    120b <inertial+0xab>
test   %r14d,%r14d
jle    120b <inertial+0xab>
mov    %r14d,%edx
shl    $0x3,%rdx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1070 <memcpy@plt>
mov    0x70(%rsp),%ebx
mov    0x68(%rsp),%r10
mov    0x60(%rsp),%r11
cmp    $0x3,%r14d
je     124d <inertial+0xed>
cmp    $0x2,%r14d
je     1273 <inertial+0x113>
cmp    $0x1,%r14d
jne    129b <inertial+0x13b>
mov    (%rsp),%r8
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r11,%r9
xor    %eax,%eax
push   %rbx
push   %r10
call   1030 <inertial1d@plt>
add    $0x10,%rsp
jmp    129b <inertial+0x13b>
mov    (%rsp),%r8
mov    0x8(%rsp),%r9
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
push   %rbx
push   %r10
push   %r11
push   0x28(%rsp)
call   1080 <inertial3d@plt>
jmp    1297 <inertial+0x137>
mov    (%rsp),%r8
mov    0x8(%rsp),%r9
sub    $0x8,%rsp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
push   %rbx
push   %r10
push   %r11
call   1040 <inertial2d@plt>
add    $0x20,%rsp
xor    %eax,%eax
call   1050 <seconds@plt>
subsd  0x20(%rsp),%xmm0
mov    0x2d29(%rip),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r8d,%esi
and    $0xfffffffe,%esi
lea    -0x1(%r9),%rdi
lea    -0x2(%r9),%rcx
xor    %eax,%eax
xor    %edx,%edx
jmp    12ec <inertial+0x18c>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rax
cmp    %rbp,%rsi
je     11d1 <inertial+0x71>
cmp    %rax,%rdi
je     12ff <inertial+0x19f>
mov    (%rbx,%rax,8),%rbp
movslq %edx,%rdx
mov    %rbp,(%rsp,%rdx,8)
add    $0x1,%edx
lea    0x2(%rax),%rbp
cmp    %rax,%rcx
je     12e0 <inertial+0x180>
mov    0x8(%rbx,%rax,8),%rax
movslq %edx,%rdx
mov    %rax,(%rsp,%rdx,8)
add    $0x1,%edx
jmp    12e0 <inertial+0x180>

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

LLVM IR (-O2):
%struct.vtx_data = type opaque
@DEBUG_TRACE = external global i32
@.str = [33 x i8] c"<Entering inertial, nvtxs = %d>\0A\00"
@PROJECTION_AXIS = external global i32
@inertial_time = external global double
define void @inertial(%struct.vtx_data** %0, i32 %1, i32 %2, i32 %3, i32 %4, float** nocapture %5, i32* %6, double* %7, i32 %8) {
%10 = bitcast float** %5 to i8*
%11 = alloca [3 x float*]
%12 = bitcast [3 x float*]* %11 to i8*
%13 = tail call double (...) @seconds()
%14 = load i32, i32* @DEBUG_TRACE
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %18
18: ; preds = %16, %9
%19 = load i32, i32* @PROJECTION_AXIS
%20 = icmp eq i32 %19, 0
%21 = icmp sgt i32 %4, 0
br i1 %20, label %30, label %22
22: ; preds = %18
br i1 %21, label %23, label %72
23: ; preds = %22
%24 = zext i32 %19 to i64
%25 = zext i32 %4 to i64
%26 = and i64 %25, 1
%27 = icmp eq i32 %4, 1
br i1 %27, label %60, label %28
28: ; preds = %23
%29 = and i64 %25, 4294967294
br label %34
30: ; preds = %18
br i1 %21, label %31, label %74
31: ; preds = %30
%32 = zext i32 %4 to i64
%33 = shl nuw nsw i64 %32, 3
br label %74
34: ; preds = %56, %28
%35 = phi i64 [ 0, %28 ], [ %48, %56 ]
%36 = phi i32 [ 0, %28 ], [ %57, %56 ]
%37 = phi i64 [ 0, %28 ], [ %58, %56 ]
%38 = or i64 %35, 1
%39 = icmp eq i64 %38, %24
br i1 %39, label %46, label %40
40: ; preds = %34
%41 = getelementptr inbounds float*, float** %5, i64 %35
%42 = load float*, float** %41
%43 = sext i32 %36 to i64
%44 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 %43
store float* %42, float** %44
%45 = add nsw i32 %36, 1
br label %46
46: ; preds = %34, %40
%47 = phi i32 [ %45, %40 ], [ %36, %34 ]
%48 = add nuw nsw i64 %35, 2
%49 = icmp eq i64 %48, %24
br i1 %49, label %56, label %50
50: ; preds = %46
%51 = getelementptr inbounds float*, float** %5, i64 %38
%52 = load float*, float** %51
%53 = sext i32 %47 to i64
%54 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 %53
store float* %52, float** %54
%55 = add nsw i32 %47, 1
br label %56
56: ; preds = %50, %46
%57 = phi i32 [ %55, %50 ], [ %47, %46 ]
%58 = add i64 %37, 2
%59 = icmp eq i64 %58, %29
br i1 %59, label %60, label %34
60: ; preds = %56, %23
%61 = phi i64 [ 0, %23 ], [ %48, %56 ]
%62 = phi i32 [ 0, %23 ], [ %57, %56 ]
%63 = icmp eq i64 %26, 0
%64 = add nuw nsw i64 %61, 1
%65 = icmp eq i64 %64, %24
%66 = select i1 %63, i1 true, i1 %65
br i1 %66, label %72, label %67
67: ; preds = %60
%68 = getelementptr inbounds float*, float** %5, i64 %61
%69 = load float*, float** %68
%70 = sext i32 %62 to i64
%71 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 %70
store float* %69, float** %71
br label %72
72: ; preds = %60, %67, %22
%73 = add nsw i32 %4, -1
br label %74
74: ; preds = %31, %30, %72
%75 = phi i32 [ %73, %72 ], [ %4, %30 ], [ %4, %31 ]
switch i32 %75, label %91 [
i32 1, label %76
i32 2, label %79
i32 3, label %84
]
76: ; preds = %74
%77 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 0
%78 = load float*, float** %77
tail call void (%struct.vtx_data**, i32, i32, i32, float*, i32*, double*, i32, ...) bitcast (void (...)* @inertial1d to void (%struct.vtx_data**, i32, i32, i32, float*, i32*, double*, i32, ...)*)(%struct.vtx_data** %0, i32 %1, i32 %2, i32 %3, float* %78, i32* %6, double* %7, i32 %8)
br label %91
79: ; preds = %74
%80 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 0
%81 = load float*, float** %80
%82 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 1
%83 = load float*, float** %82
tail call void (%struct.vtx_data**, i32, i32, i32, float*, float*, i32*, double*, i32, ...) bitcast (void (...)* @inertial2d to void (%struct.vtx_data**, i32, i32, i32, float*, float*, i32*, double*, i32, ...)*)(%struct.vtx_data** %0, i32 %1, i32 %2, i32 %3, float* %81, float* %83, i32* %6, double* %7, i32 %8)
br label %91
84: ; preds = %74
%85 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 0
%86 = load float*, float** %85
%87 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 1
%88 = load float*, float** %87
%89 = getelementptr inbounds [3 x float*], [3 x float*]* %11, i64 0, i64 2
%90 = load float*, float** %89
tail call void (%struct.vtx_data**, i32, i32, i32, float*, float*, float*, i32*, double*, i32, ...) bitcast (void (...)* @inertial3d to void (%struct.vtx_data**, i32, i32, i32, float*, float*, float*, i32*, double*, i32, ...)*)(%struct.vtx_data** %0, i32 %1, i32 %2, i32 %3, float* %86, float* %88, float* %90, i32* %6, double* %7, i32 %8)
br label %91
91: ; preds = %74, %79, %84, %76
%92 = tail call double (...) @seconds()
%93 = fsub double %92, %13
%94 = load double, double* @inertial_time
%95 = fadd double %94, %93
store double %95, double* @inertial_time
ret void
}