int flatten(struct vtx_data **graph, int nvtxs, int nedges,
            struct vtx_data ***pcgraph, int *pcnvtxs, int *pcnedges,
            int **pv2cv, int using_ewgts, int igeom, float **coords,
            float **ccoords) {
  double Thresh;
  int *v2cv;
  int cnvtxs;
  void find_flat(), makefgraph();
  Thresh = .9;
  v2cv = smalloc((nvtxs + 1) * sizeof(int));
  find_flat(graph, nvtxs, &cnvtxs, v2cv);
  if (cnvtxs <= Thresh * nvtxs) {
    makefgraph(graph, nvtxs, nedges, pcgraph, cnvtxs, pcnedges, v2cv,
               using_ewgts, igeom, coords, ccoords);
    *pcnvtxs = cnvtxs;
    *pv2cv = v2cv;
    return (1);
  }
  sfree(v2cv);
  return (0);
}


x86 assembly (clang, -O0):
<flatten>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %edx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x2,%rdi
mov    $0x0,%al
call   1060 <smalloc@plt>
cltq
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x50(%rbp),%rcx
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   1050 <find_flat@plt>
cvtsi2sdl -0x54(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1234 <flatten+0xf4>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x54(%rbp),%r8d
mov    -0x40(%rbp),%r9
mov    -0x50(%rbp),%r14
mov    0x18(%rbp),%ebx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10
mov    0x30(%rbp),%rax
mov    %r14,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1040 <makefgraph@plt>
mov    -0x54(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x14(%rbp)
jmp    1246 <flatten+0x106>
mov    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1030 <sfree@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<flatten>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x10(%rsp)
mov    %edx,%r13d
mov    %esi,%ebp
mov    %rdi,%r15
movslq %esi,%r12
lea    0x4(,%r12,4),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <smalloc@plt>
movslq %eax,%rbx
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <find_flat@plt>
mov    0xc(%rsp),%r8d
cvtsi2sd %r8d,%xmm0
cvtsi2sd %r12d,%xmm1
mulsd  0xe57(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bb <flatten+0x7b>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sfree@plt>
jmp    1212 <flatten+0xd2>
mov    0x70(%rsp),%r10d
mov    0x68(%rsp),%r11d
mov    0x60(%rsp),%r14
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r9
xor    %eax,%eax
push   0x88(%rsp)
push   0x88(%rsp)
push   %r10
push   %r11
push   %rbx
call   1040 <makefgraph@plt>
add    $0x30,%rsp
mov    0xc(%rsp),%eax
mov    0x20(%rsp),%rcx
mov    %eax,(%rcx)
mov    %rbx,(%r14)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.vtx_data = type opaque
define i32 @flatten(%struct.vtx_data** %0, i32 %1, i32 %2, %struct.vtx_data*** %3, i32* %4, i32* %5, i32** %6, i32 %7, i32 %8, float** %9, float** %10) {
%12 = alloca i32
%13 = alloca %struct.vtx_data**
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.vtx_data***
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32**
%20 = alloca i32
%21 = alloca i32
%22 = alloca float**
%23 = alloca float**
%24 = alloca double
%25 = alloca i32*
%26 = alloca i32
store %struct.vtx_data** %0, %struct.vtx_data*** %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store %struct.vtx_data*** %3, %struct.vtx_data**** %16
store i32* %4, i32** %17
store i32* %5, i32** %18
store i32** %6, i32*** %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store float** %9, float*** %22
store float** %10, float*** %23
store double 9.000000e-01, double* %24
%27 = load i32, i32* %14
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 4
%31 = call i32 (i64, ...) bitcast (i32 (...)* @smalloc to i32 (i64, ...)*)(i64 %30)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
store i32* %33, i32** %25
%34 = load %struct.vtx_data**, %struct.vtx_data*** %13
%35 = load i32, i32* %14
%36 = load i32*, i32** %25
%37 = load i32, i32* %26
%38 = sitofp i32 %37 to double
%39 = load double, double* %24
%40 = load i32, i32* %14
%41 = sitofp i32 %40 to double
%42 = fmul double %39, %41
%43 = fcmp ole double %38, %42
br i1 %43, label %44, label %60
44: ; preds = %11
%45 = load %struct.vtx_data**, %struct.vtx_data*** %13
%46 = load i32, i32* %14
%47 = load i32, i32* %15
%48 = load %struct.vtx_data***, %struct.vtx_data**** %16
%49 = load i32, i32* %26
%50 = load i32*, i32** %18
%51 = load i32*, i32** %25
%52 = load i32, i32* %20
%53 = load i32, i32* %21
%54 = load float**, float*** %22
%55 = load float**, float*** %23
%56 = load i32, i32* %26
%57 = load i32*, i32** %17
store i32 %56, i32* %57
%58 = load i32*, i32** %25
%59 = load i32**, i32*** %19
store i32* %58, i32** %59
store i32 1, i32* %12
br label %63
60: ; preds = %11
%61 = load i32*, i32** %25
%62 = call i32 (i32*, ...) bitcast (i32 (...)* @sfree to i32 (i32*, ...)*)(i32* %61)
store i32 0, i32* %12
br label %63
63: ; preds = %60, %44
%64 = load i32, i32* %12
ret i32 %64
}

LLVM IR (-O2):
%struct.vtx_data = type opaque
define i32 @flatten(%struct.vtx_data** %0, i32 %1, i32 %2, %struct.vtx_data*** %3, i32* nocapture writeonly %4, i32* %5, i32** nocapture writeonly %6, i32 %7, i32 %8, float** %9, float** %10) {
%12 = alloca i32
%13 = bitcast i32* %12 to i8*
%14 = add nsw i32 %1, 1
%15 = sext i32 %14 to i64
%16 = shl nsw i64 %15, 2
%17 = tail call i32 (i64, ...) bitcast (i32 (...)* @smalloc to i32 (i64, ...)*)(i64 %16)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load i32, i32* %12
%21 = sitofp i32 %20 to double
%22 = sitofp i32 %1 to double
%23 = fmul double %22, 9.000000e-01
%24 = fcmp ult double %23, %21
br i1 %24, label %27, label %25
25: ; preds = %11
%26 = load i32, i32* %12
store i32 %26, i32* %4
store i32* %19, i32** %6
br label %29
27: ; preds = %11
%28 = call i32 (i32*, ...) bitcast (i32 (...)* @sfree to i32 (i32*, ...)*)(i32* %19)
br label %29
29: ; preds = %27, %25
%30 = phi i32 [ 1, %25 ], [ 0, %27 ]
ret i32 %30
}