void map3d(struct vtx_data **graph, double **xvecs, int nvtxs, int *sets,
           double *goal, int vwgt_max) {
  extern int DEBUG_BPMATCH;
  extern int N_VTX_MOVES;
  extern int N_VTX_CHECKS;
  double *vals[8][8];
  double dist[8];
  double size[8];
  int *indices[8][8];
  int startvtx[8][8];
  int nsection = 3;
  int nsets = 8;
  void genvals3d(), sorts3d(), inits3d(), checkbp(), movevtxs();
  N_VTX_CHECKS = N_VTX_MOVES = 0;
  genvals3d(xvecs, vals, nvtxs);
  sorts3d(vals, indices, nvtxs);
  inits3d(graph, xvecs, vals, indices, nvtxs, dist, startvtx, size, sets);
  if (DEBUG_BPMATCH > 1) {
    printf(" Calling check before movevtxs\n");
    checkbp(graph, xvecs, sets, dist, nvtxs, nsection);
  }
  movevtxs(graph, nvtxs, nsets, dist, indices, vals, startvtx, sets, size, goal,
           vwgt_max);
  if (DEBUG_BPMATCH > 0) {
    printf(" N_VTX_CHECKS = %d, N_VTX_MOVES = %d\n", N_VTX_CHECKS, N_VTX_MOVES);
    checkbp(graph, xvecs, sets, dist, nvtxs, nsection);
  }
  free3d(vals, indices);
}


x86 assembly (clang, -O0):
<map3d>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x5e0,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movl   $0x3,-0x5c4(%rbp)
movl   $0x8,-0x5c8(%rbp)
mov    0x2e38(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e1b(%rip),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    -0x240(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1080 <genvals3d@plt>
lea    -0x240(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1070 <sorts3d@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x240(%rbp),%rdx
lea    -0x4c0(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    -0x280(%rbp),%r9
lea    -0x5c0(%rbp),%r11
lea    -0x2c0(%rbp),%r10
mov    -0x30(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1060 <inits3d@plt>
mov    0x2d91(%rip),%rax
cmpl   $0x1,(%rax)
jle    127b <map3d+0x10b>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x280(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x5c4(%rbp),%r9d
mov    $0x0,%al
call   1030 <checkbp@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x5c8(%rbp),%edx
lea    -0x280(%rbp),%rcx
lea    -0x4c0(%rbp),%r8
lea    -0x240(%rbp),%r9
lea    -0x5c0(%rbp),%r14
mov    -0x30(%rbp),%rbx
lea    -0x2c0(%rbp),%r11
mov    -0x38(%rbp),%r10
mov    -0x3c(%rbp),%eax
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %eax,0x20(%rsp)
mov    $0x0,%al
call   1050 <movevtxs@plt>
mov    0x2cf5(%rip),%rax
cmpl   $0x0,(%rax)
jle    1329 <map3d+0x1b9>
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    0x2cf4(%rip),%rax
mov    (%rax),%edx
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    -0x280(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x5c4(%rbp),%r9d
mov    $0x0,%al
call   1030 <checkbp@plt>
lea    -0x240(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
mov    $0x0,%al
call   1090 <free3d@plt>
add    $0x5e0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<map3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x598,%rsp
mov    %r9,(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%rbp
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r12
mov    0x2e3b(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e1e(%rip),%rax
movl   $0x0,(%rax)
lea    0x390(%rsp),%r13
mov    %rsi,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <genvals3d@plt>
lea    0x190(%rsp),%r14
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1080 <sorts3d@plt>
sub    $0x8,%rsp
lea    0x58(%rsp),%r10
lea    0x98(%rsp),%r11
lea    0x18(%rsp),%r9
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
xor    %eax,%eax
mov    %rbp,%r14
push   %rbp
push   %r10
push   %r11
call   1070 <inits3d@plt>
add    $0x20,%rsp
mov    0x2da4(%rip),%r13
cmpl   $0x2,0x0(%r13)
jl     125d <map3d+0xdd>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rcx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15d,%r8d
mov    $0x3,%r9d
xor    %eax,%eax
call   1040 <checkbp@plt>
sub    $0x8,%rsp
lea    0x18(%rsp),%rcx
lea    0x198(%rsp),%r8
lea    0x398(%rsp),%r9
mov    %r12,%rdi
mov    %r15d,%esi
mov    $0x8,%edx
mov    $0x0,%eax
push   0x8(%rsp)
push   0x18(%rsp)
lea    0x68(%rsp),%rbp
push   %rbp
push   %r14
lea    0xb8(%rsp),%rbp
push   %rbp
call   1060 <movevtxs@plt>
add    $0x30,%rsp
cmpl   $0x0,0x0(%r13)
jle    12ed <map3d+0x16d>
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
lea    0xd38(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rcx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15d,%r8d
mov    $0x3,%r9d
xor    %eax,%eax
call   1040 <checkbp@plt>
lea    0x390(%rsp),%rdi
lea    0x190(%rsp),%rsi
xor    %eax,%eax
call   10a0 <free3d@plt>
add    $0x598,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.vtx_data = type opaque
@N_VTX_MOVES = external global i32
@N_VTX_CHECKS = external global i32
@DEBUG_BPMATCH = external global i32
@.str = [32 x i8] c" Calling check before movevtxs\0A\00"
@.str.1 = [38 x i8] c" N_VTX_CHECKS = %d, N_VTX_MOVES = %d\0A\00"
define void @map3d(%struct.vtx_data** %0, double** %1, i32 %2, i32* %3, double* %4, i32 %5) {
%7 = alloca %struct.vtx_data**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double*
%12 = alloca i32
%13 = alloca [8 x [8 x double*]]
%14 = alloca [8 x double]
%15 = alloca [8 x double]
%16 = alloca [8 x [8 x i32*]]
%17 = alloca [8 x [8 x i32]]
%18 = alloca i32
%19 = alloca i32
store %struct.vtx_data** %0, %struct.vtx_data*** %7
store double** %1, double*** %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store double* %4, double** %11
store i32 %5, i32* %12
store i32 3, i32* %18
store i32 8, i32* %19
store i32 0, i32* @N_VTX_MOVES
store i32 0, i32* @N_VTX_CHECKS
%20 = load double**, double*** %8
%21 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %13, i64 0, i64 0
%22 = load i32, i32* %9
%23 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %13, i64 0, i64 0
%24 = getelementptr inbounds [8 x [8 x i32*]], [8 x [8 x i32*]]* %16, i64 0, i64 0
%25 = load i32, i32* %9
%26 = load %struct.vtx_data**, %struct.vtx_data*** %7
%27 = load double**, double*** %8
%28 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %13, i64 0, i64 0
%29 = getelementptr inbounds [8 x [8 x i32*]], [8 x [8 x i32*]]* %16, i64 0, i64 0
%30 = load i32, i32* %9
%31 = getelementptr inbounds [8 x double], [8 x double]* %14, i64 0, i64 0
%32 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %17, i64 0, i64 0
%33 = getelementptr inbounds [8 x double], [8 x double]* %15, i64 0, i64 0
%34 = load i32*, i32** %10
%35 = load i32, i32* @DEBUG_BPMATCH
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %45
37: ; preds = %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%39 = load %struct.vtx_data**, %struct.vtx_data*** %7
%40 = load double**, double*** %8
%41 = load i32*, i32** %10
%42 = getelementptr inbounds [8 x double], [8 x double]* %14, i64 0, i64 0
%43 = load i32, i32* %9
%44 = load i32, i32* %18
br label %45
45: ; preds = %37, %6
%46 = load %struct.vtx_data**, %struct.vtx_data*** %7
%47 = load i32, i32* %9
%48 = load i32, i32* %19
%49 = getelementptr inbounds [8 x double], [8 x double]* %14, i64 0, i64 0
%50 = getelementptr inbounds [8 x [8 x i32*]], [8 x [8 x i32*]]* %16, i64 0, i64 0
%51 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %13, i64 0, i64 0
%52 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %17, i64 0, i64 0
%53 = load i32*, i32** %10
%54 = getelementptr inbounds [8 x double], [8 x double]* %15, i64 0, i64 0
%55 = load double*, double** %11
%56 = load i32, i32* %12
%57 = load i32, i32* @DEBUG_BPMATCH
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %69
59: ; preds = %45
%60 = load i32, i32* @N_VTX_CHECKS
%61 = load i32, i32* @N_VTX_MOVES
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61)
%63 = load %struct.vtx_data**, %struct.vtx_data*** %7
%64 = load double**, double*** %8
%65 = load i32*, i32** %10
%66 = getelementptr inbounds [8 x double], [8 x double]* %14, i64 0, i64 0
%67 = load i32, i32* %9
%68 = load i32, i32* %18
br label %69
69: ; preds = %59, %45
%70 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %13, i64 0, i64 0
%71 = getelementptr inbounds [8 x [8 x i32*]], [8 x [8 x i32*]]* %16, i64 0, i64 0
%72 = call i32 ([8 x double*]*, [8 x i32*]*, ...) bitcast (i32 (...)* @free3d to i32 ([8 x double*]*, [8 x i32*]*, ...)*)([8 x double*]* %70, [8 x i32*]* %71)
ret void
}

LLVM IR (-O2):
%struct.vtx_data = type opaque
@N_VTX_MOVES = external global i32
@N_VTX_CHECKS = external global i32
@DEBUG_BPMATCH = external global i32
@.str.1 = [38 x i8] c" N_VTX_CHECKS = %d, N_VTX_MOVES = %d\0A\00"
@str = [31 x i8] c" Calling check before movevtxs\00"
define void @map3d(%struct.vtx_data** %0, double** %1, i32 %2, i32* %3, double* %4, i32 %5) {
%7 = alloca [8 x [8 x double*]]
%8 = alloca [8 x double]
%9 = alloca [8 x double]
%10 = alloca [8 x [8 x i32*]]
%11 = alloca [8 x [8 x i32]]
%12 = bitcast [8 x [8 x double*]]* %7 to i8*
%13 = bitcast [8 x double]* %8 to i8*
%14 = bitcast [8 x double]* %9 to i8*
%15 = bitcast [8 x [8 x i32*]]* %10 to i8*
%16 = bitcast [8 x [8 x i32]]* %11 to i8*
store i32 0, i32* @N_VTX_MOVES
store i32 0, i32* @N_VTX_CHECKS
%17 = getelementptr inbounds [8 x [8 x double*]], [8 x [8 x double*]]* %7, i64 0, i64 0
%18 = getelementptr inbounds [8 x [8 x i32*]], [8 x [8 x i32*]]* %10, i64 0, i64 0
%19 = getelementptr inbounds [8 x double], [8 x double]* %8, i64 0, i64 0
%20 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %11, i64 0, i64 0
%21 = getelementptr inbounds [8 x double], [8 x double]* %9, i64 0, i64 0
%22 = load i32, i32* @DEBUG_BPMATCH
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %6
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %24, %6
%27 = load i32, i32* @DEBUG_BPMATCH
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* @N_VTX_CHECKS
%31 = load i32, i32* @N_VTX_MOVES
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %31)
br label %33
33: ; preds = %29, %26
%34 = call i32 ([8 x double*]*, [8 x i32*]*, ...) bitcast (i32 (...)* @free3d to i32 ([8 x double*]*, [8 x i32*]*, ...)*)([8 x double*]* %17, [8 x i32*]* %18)
ret void
}