#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int **allocate_matrix(int, int, char);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ free_matrix(int **, int, int);
int /*<<< orphan*/ get_cluster_sizes(int **, int, int, int, int *, int *);
scalar_t__ malloc_or_die(int);
int /*<<< orphan*/ mark_cluster_numbers(int **, int **, int **, int, int,
                                        int *);
int /*<<< orphan*/ populate_bonds(int **, int **, int, int, double);
int /*<<< orphan*/ print_lattice_and_cluster_numbers(int **, int **, int **,
                                                     int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sanity_check_cluster_numbers(int **, int **, int **, int,
                                                int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ usage(char *, char *, int);
void test_cluster_sizes(int argc, char **argv) {
  int M = 18;
  int N = 18;
  double p = 0.6;
  int print_lattice = 0;
  int argi;
  int **vbonds;
  int **hbonds;
  int **site_marks;
  int num_clusters;
  int *cluster_sizes;
  int C_clno;
  int k;
  for (argi = 2; argi < argc; argi++) {
    if (sscanf(argv[argi], "M=%d", &M) == 1)
      ;
    else if (sscanf(argv[argi], "N=%d", &N) == 1)
      ;
    else if (sscanf(argv[argi], "MN=%d", &M) == 1)
      N = M;
    else if (sscanf(argv[argi], "p=%lf", &p) == 1)
      ;
    else if (sscanf(argv[argi], "pl=%d", &print_lattice) == 1)
      ;
    else
      usage(argv[0], argv[1], 0);
  }
  if ((M < 3) || (N < 3))
    usage(argv[0], argv[1], 1);
  vbonds = allocate_matrix(M, N, 0);
  hbonds = allocate_matrix(M, N, 0);
  site_marks = allocate_matrix(M, N, '.');
  populate_bonds(vbonds, hbonds, M, N, p);
  mark_cluster_numbers(site_marks, vbonds, hbonds, M, N, &num_clusters);
  if (print_lattice)
    print_lattice_and_cluster_numbers(site_marks, vbonds, hbonds, M, N);
  sanity_check_cluster_numbers(site_marks, vbonds, hbonds, M, N);
  cluster_sizes = (int *)malloc_or_die(sizeof(int) * num_clusters);
  get_cluster_sizes(site_marks, M, N, num_clusters, cluster_sizes, &C_clno);
  for (k = 0; k < num_clusters; k++) {
    printf("Cluster    %3d", k);
    printf(" size %6d %7.4lf", cluster_sizes[k],
           (double)cluster_sizes[k] / (double)M / (double)N);
    if (k == C_clno)
      printf(" *");
    printf("\n");
  }
  free_matrix(vbonds, M, N);
  free_matrix(hbonds, M, N);
  free_matrix(site_marks, M, N);
  free(cluster_sizes);
}


x86 assembly (clang, -O0):
<test_cluster_sizes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x12,-0x14(%rbp)
movl   $0x12,-0x18(%rbp)
movsd  0xe1b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1323 <test_cluster_sizes+0x163>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf1(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    1230 <test_cluster_sizes+0x70>
jmp    1310 <test_cluster_sizes+0x150>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdcb(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    125c <test_cluster_sizes+0x9c>
jmp    130b <test_cluster_sizes+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd9e(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    128e <test_cluster_sizes+0xce>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1306 <test_cluster_sizes+0x146>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd72(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    12ba <test_cluster_sizes+0xfa>
jmp    1301 <test_cluster_sizes+0x141>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd4c(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
jne    12e6 <test_cluster_sizes+0x126>
jmp    12fc <test_cluster_sizes+0x13c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %edx,%edx
call   10d0 <usage@plt>
jmp    1301 <test_cluster_sizes+0x141>
jmp    1306 <test_cluster_sizes+0x146>
jmp    130b <test_cluster_sizes+0x14b>
jmp    1310 <test_cluster_sizes+0x150>
jmp    1315 <test_cluster_sizes+0x155>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f8 <test_cluster_sizes+0x38>
cmpl   $0x3,-0x14(%rbp)
jl     1337 <test_cluster_sizes+0x177>
cmpl   $0x3,-0x18(%rbp)
jge    1350 <test_cluster_sizes+0x190>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1,%edx
call   10d0 <usage@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   10a0 <allocate_matrix@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   10a0 <allocate_matrix@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2e,%edx
call   10a0 <allocate_matrix@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
movsd  -0x20(%rbp),%xmm0
call   1090 <populate_bonds@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    -0x44(%rbp),%r9
call   1060 <mark_cluster_numbers@plt>
cmpl   $0x0,-0x24(%rbp)
je     13dc <test_cluster_sizes+0x21c>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1080 <print_lattice_and_cluster_numbers@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <sanity_check_cluster_numbers@plt>
movslq -0x44(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10c0 <malloc_or_die@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    -0x50(%rbp),%r8
lea    -0x54(%rbp),%r9
call   10e0 <get_cluster_sizes@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    14b3 <test_cluster_sizes+0x2f3>
mov    -0x58(%rbp),%esi
lea    0xbe1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x50(%rbp),%rax
movslq -0x58(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xbb8(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jne    1497 <test_cluster_sizes+0x2d7>
lea    0xbaf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1428 <test_cluster_sizes+0x268>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <free_matrix@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <free_matrix@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <free_matrix@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_cluster_sizes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%eax
movl   $0x12,0x10(%rsp)
movl   $0x12,0xc(%rsp)
movabs $0x3fe3333333333333,%rcx
33 e3 3f
mov    %rcx,0x20(%rsp)
movl   $0x0,0x18(%rsp)
mov    $0x12,%esi
mov    $0x12,%edi
cmp    $0x3,%eax
jl     12ee <test_cluster_sizes+0x11e>
mov    %eax,%ebp
mov    $0x2,%r12d
lea    0xdd4(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r13
jmp    124d <test_cluster_sizes+0x7d>
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
add    $0x1,%r12
cmp    %r12,%rbp
je     12e6 <test_cluster_sizes+0x116>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
je     1240 <test_cluster_sizes+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd98(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
je     1240 <test_cluster_sizes+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd7d(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
je     1238 <test_cluster_sizes+0x68>
mov    (%rbx,%r12,8),%rdi
lea    0xd69(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
je     1240 <test_cluster_sizes+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd53(%rip),%rsi
lea    0x18(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
je     1240 <test_cluster_sizes+0x70>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
xor    %edx,%edx
call   10e0 <usage@plt>
jmp    1240 <test_cluster_sizes+0x70>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
cmp    $0x3,%edi
jl     12f8 <test_cluster_sizes+0x128>
cmp    $0x2,%esi
jg     1311 <test_cluster_sizes+0x141>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
mov    $0x1,%edx
call   10e0 <usage@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    $0x2e,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,%r12
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
movsd  0x20(%rsp),%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10a0 <populate_bonds@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0x14(%rsp),%r9
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <mark_cluster_numbers@plt>
cmpl   $0x0,0x18(%rsp)
je     1395 <test_cluster_sizes+0x1c5>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1090 <print_lattice_and_cluster_numbers@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r12,%rdi
mov    %rbx,0x30(%rsp)
mov    %rbx,%rsi
mov    %rbp,0x28(%rsp)
mov    %rbp,%rdx
call   1060 <sanity_check_cluster_numbers@plt>
mov    0x14(%rsp),%edi
shl    $0x2,%edi
call   10d0 <malloc_or_die@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0x1c(%rsp),%r9
mov    %r12,%rdi
mov    %rax,%r8
call   10f0 <get_cluster_sizes@plt>
cmpl   $0x0,0x14(%rsp)
jle    1479 <test_cluster_sizes+0x2a9>
lea    0xc24(%rip),%r13
lea    0xc2c(%rip),%rbp
lea    0xc36(%rip),%r14
xor    %r15d,%r15d
jmp    1428 <test_cluster_sizes+0x258>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r15
movslq 0x14(%rsp),%rax
cmp    %rax,%r15
jge    1479 <test_cluster_sizes+0x2a9>
mov    %r13,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx,%r15,4),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x10(%rsp),%xmm1
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divsd  %xmm1,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    0x1c(%rsp),%eax
cmp    %rax,%r15
jne    1410 <test_cluster_sizes+0x240>
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1410 <test_cluster_sizes+0x240>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x30(%rsp),%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x28(%rsp),%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r12,%rdi
call   1050 <free_matrix@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"M=%d\00"
@.str.1 = [5 x i8] c"N=%d\00"
@.str.2 = [6 x i8] c"MN=%d\00"
@.str.3 = [6 x i8] c"p=%lf\00"
@.str.4 = [6 x i8] c"pl=%d\00"
@.str.5 = [15 x i8] c"Cluster %3d\00"
@.str.6 = [17 x i8] c" size %6d %7.4lf\00"
@.str.7 = [3 x i8] c" *\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @test_cluster_sizes(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i32**
%12 = alloca i32**
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 18, i32* %5
store i32 18, i32* %6
store double 6.000000e-01, double* %7
store i32 0, i32* %8
store i32 2, i32* %9
br label %17
17: ; preds = %80, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %83
21: ; preds = %17
%22 = load i8**, i8*** %4
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %5)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %21
br label %79
30: ; preds = %21
%31 = load i8**, i8*** %4
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %39
38: ; preds = %30
br label %78
39: ; preds = %30
%40 = load i8**, i8*** %4
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i8*, i8*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %39
%48 = load i32, i32* %5
store i32 %48, i32* %6
br label %77
49: ; preds = %39
%50 = load i8**, i8*** %4
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 (i8*, i8*, ...) @sscanf(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %7)
%56 = icmp eq i32 %55, 1
br i1 %56, label %57, label %58
57: ; preds = %49
br label %76
58: ; preds = %49
%59 = load i8**, i8*** %4
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, ...) @sscanf(i8* %63, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %67
66: ; preds = %58
br label %75
67: ; preds = %58
%68 = load i8**, i8*** %4
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = load i8**, i8*** %4
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i32 @usage(i8* %70, i8* %73, i32 0)
br label %75
75: ; preds = %67, %66
br label %76
76: ; preds = %75, %57
br label %77
77: ; preds = %76, %47
br label %78
78: ; preds = %77, %38
br label %79
79: ; preds = %78, %29
br label %80
80: ; preds = %79
%81 = load i32, i32* %9
%82 = add nsw i32 %81, 1
store i32 %82, i32* %9
br label %17
83: ; preds = %17
%84 = load i32, i32* %5
%85 = icmp slt i32 %84, 3
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = load i32, i32* %6
%88 = icmp slt i32 %87, 3
br i1 %88, label %89, label %97
89: ; preds = %86, %83
%90 = load i8**, i8*** %4
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = load i8**, i8*** %4
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i32 @usage(i8* %92, i8* %95, i32 1)
br label %97
97: ; preds = %89, %86
%98 = load i32, i32* %5
%99 = load i32, i32* %6
%100 = call i32** @allocate_matrix(i32 %98, i32 %99, i8 signext 0)
store i32** %100, i32*** %10
%101 = load i32, i32* %5
%102 = load i32, i32* %6
%103 = call i32** @allocate_matrix(i32 %101, i32 %102, i8 signext 0)
store i32** %103, i32*** %11
%104 = load i32, i32* %5
%105 = load i32, i32* %6
%106 = call i32** @allocate_matrix(i32 %104, i32 %105, i8 signext 46)
store i32** %106, i32*** %12
%107 = load i32**, i32*** %10
%108 = load i32**, i32*** %11
%109 = load i32, i32* %5
%110 = load i32, i32* %6
%111 = load double, double* %7
%112 = call i32 @populate_bonds(i32** %107, i32** %108, i32 %109, i32 %110, double %111)
%113 = load i32**, i32*** %12
%114 = load i32**, i32*** %10
%115 = load i32**, i32*** %11
%116 = load i32, i32* %5
%117 = load i32, i32* %6
%118 = call i32 @mark_cluster_numbers(i32** %113, i32** %114, i32** %115, i32 %116, i32 %117, i32* %13)
%119 = load i32, i32* %8
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %128
121: ; preds = %97
%122 = load i32**, i32*** %12
%123 = load i32**, i32*** %10
%124 = load i32**, i32*** %11
%125 = load i32, i32* %5
%126 = load i32, i32* %6
%127 = call i32 @print_lattice_and_cluster_numbers(i32** %122, i32** %123, i32** %124, i32 %125, i32 %126)
br label %128
128: ; preds = %121, %97
%129 = load i32**, i32*** %12
%130 = load i32**, i32*** %10
%131 = load i32**, i32*** %11
%132 = load i32, i32* %5
%133 = load i32, i32* %6
%134 = call i32 @sanity_check_cluster_numbers(i32** %129, i32** %130, i32** %131, i32 %132, i32 %133)
%135 = load i32, i32* %13
%136 = sext i32 %135 to i64
%137 = mul i64 4, %136
%138 = trunc i64 %137 to i32
%139 = call i64 @malloc_or_die(i32 %138)
%140 = inttoptr i64 %139 to i32*
store i32* %140, i32** %14
%141 = load i32**, i32*** %12
%142 = load i32, i32* %5
%143 = load i32, i32* %6
%144 = load i32, i32* %13
%145 = load i32*, i32** %14
%146 = call i32 @get_cluster_sizes(i32** %141, i32 %142, i32 %143, i32 %144, i32* %145, i32* %15)
store i32 0, i32* %16
br label %147
147: ; preds = %179, %128
%148 = load i32, i32* %16
%149 = load i32, i32* %13
%150 = icmp slt i32 %148, %149
br i1 %150, label %151, label %182
151: ; preds = %147
%152 = load i32, i32* %16
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %152)
%154 = load i32*, i32** %14
%155 = load i32, i32* %16
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i32, i32* %154, i64 %156
%158 = load i32, i32* %157
%159 = load i32*, i32** %14
%160 = load i32, i32* %16
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i32, i32* %159, i64 %161
%163 = load i32, i32* %162
%164 = sitofp i32 %163 to double
%165 = load i32, i32* %5
%166 = sitofp i32 %165 to double
%167 = fdiv double %164, %166
%168 = load i32, i32* %6
%169 = sitofp i32 %168 to double
%170 = fdiv double %167, %169
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %158, double %170)
%172 = load i32, i32* %16
%173 = load i32, i32* %15
%174 = icmp eq i32 %172, %173
br i1 %174, label %175, label %177
175: ; preds = %151
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %177
177: ; preds = %175, %151
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %179
179: ; preds = %177
%180 = load i32, i32* %16
%181 = add nsw i32 %180, 1
store i32 %181, i32* %16
br label %147
182: ; preds = %147
%183 = load i32**, i32*** %10
%184 = load i32, i32* %5
%185 = load i32, i32* %6
%186 = call i32 @free_matrix(i32** %183, i32 %184, i32 %185)
%187 = load i32**, i32*** %11
%188 = load i32, i32* %5
%189 = load i32, i32* %6
%190 = call i32 @free_matrix(i32** %187, i32 %188, i32 %189)
%191 = load i32**, i32*** %12
%192 = load i32, i32* %5
%193 = load i32, i32* %6
%194 = call i32 @free_matrix(i32** %191, i32 %192, i32 %193)
%195 = load i32*, i32** %14
%196 = call i32 @free(i32* %195)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"M=%d\00"
@.str.1 = [5 x i8] c"N=%d\00"
@.str.2 = [6 x i8] c"MN=%d\00"
@.str.3 = [6 x i8] c"p=%lf\00"
@.str.4 = [6 x i8] c"pl=%d\00"
@.str.5 = [15 x i8] c"Cluster %3d\00"
@.str.6 = [17 x i8] c" size %6d %7.4lf\00"
@.str.7 = [3 x i8] c" *\00"
define void @test_cluster_sizes(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 18, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 18, i32* %4
%11 = bitcast double* %5 to i8*
store double 6.000000e-01, double* %5
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = icmp sgt i32 %0, 2
br i1 %15, label %16, label %53
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %16, %47
%20 = phi i64 [ 2, %16 ], [ %48, %47 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%24 = icmp eq i32 %23, 1
br i1 %24, label %47, label %25
25: ; preds = %19
%26 = load i8*, i8** %21
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%28 = icmp eq i32 %27, 1
br i1 %28, label %47, label %29
29: ; preds = %25
%30 = load i8*, i8** %21
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %3
store i32 %34, i32* %4
br label %47
35: ; preds = %29
%36 = load i8*, i8** %21
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %5)
%38 = icmp eq i32 %37, 1
br i1 %38, label %47, label %39
39: ; preds = %35
%40 = load i8*, i8** %21
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%42 = icmp eq i32 %41, 1
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i8*, i8** %1
%45 = load i8*, i8** %17
%46 = call i32 @usage(i8* %44, i8* %45, i32 0)
br label %47
47: ; preds = %19, %33, %43, %39, %35, %25
%48 = add nuw nsw i64 %20, 1
%49 = icmp eq i64 %48, %18
br i1 %49, label %50, label %19
50: ; preds = %47
%51 = load i32, i32* %3
%52 = load i32, i32* %4
br label %53
53: ; preds = %50, %2
%54 = phi i32 [ %52, %50 ], [ 18, %2 ]
%55 = phi i32 [ %51, %50 ], [ 18, %2 ]
%56 = icmp slt i32 %55, 3
%57 = icmp slt i32 %54, 3
%58 = select i1 %56, i1 true, i1 %57
br i1 %58, label %59, label %66
59: ; preds = %53
%60 = load i8*, i8** %1
%61 = getelementptr inbounds i8*, i8** %1, i64 1
%62 = load i8*, i8** %61
%63 = call i32 @usage(i8* %60, i8* %62, i32 1)
%64 = load i32, i32* %3
%65 = load i32, i32* %4
br label %66
66: ; preds = %53, %59
%67 = phi i32 [ %54, %53 ], [ %65, %59 ]
%68 = phi i32 [ %55, %53 ], [ %64, %59 ]
%69 = call i32** @allocate_matrix(i32 %68, i32 %67, i8 signext 0)
%70 = load i32, i32* %3
%71 = load i32, i32* %4
%72 = call i32** @allocate_matrix(i32 %70, i32 %71, i8 signext 0)
%73 = load i32, i32* %3
%74 = load i32, i32* %4
%75 = call i32** @allocate_matrix(i32 %73, i32 %74, i8 signext 46)
%76 = load i32, i32* %3
%77 = load i32, i32* %4
%78 = load double, double* %5
%79 = call i32 @populate_bonds(i32** %69, i32** %72, i32 %76, i32 %77, double %78)
%80 = load i32, i32* %3
%81 = load i32, i32* %4
%82 = call i32 @mark_cluster_numbers(i32** %75, i32** %69, i32** %72, i32 %80, i32 %81, i32* %7)
%83 = load i32, i32* %6
%84 = icmp eq i32 %83, 0
br i1 %84, label %89, label %85
85: ; preds = %66
%86 = load i32, i32* %3
%87 = load i32, i32* %4
%88 = call i32 @print_lattice_and_cluster_numbers(i32** %75, i32** %69, i32** %72, i32 %86, i32 %87)
br label %89
89: ; preds = %85, %66
%90 = load i32, i32* %3
%91 = load i32, i32* %4
%92 = call i32 @sanity_check_cluster_numbers(i32** %75, i32** %69, i32** %72, i32 %90, i32 %91)
%93 = load i32, i32* %7
%94 = shl i32 %93, 2
%95 = call i64 @malloc_or_die(i32 %94)
%96 = inttoptr i64 %95 to i32*
%97 = load i32, i32* %3
%98 = load i32, i32* %4
%99 = load i32, i32* %7
%100 = call i32 @get_cluster_sizes(i32** %75, i32 %97, i32 %98, i32 %99, i32* %96, i32* %8)
%101 = load i32, i32* %7
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %128
103: ; preds = %89, %122
%104 = phi i64 [ %124, %122 ], [ 0, %89 ]
%105 = trunc i64 %104 to i32
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %105)
%107 = getelementptr inbounds i32, i32* %96, i64 %104
%108 = load i32, i32* %107
%109 = sitofp i32 %108 to double
%110 = load i32, i32* %3
%111 = sitofp i32 %110 to double
%112 = fdiv double %109, %111
%113 = load i32, i32* %4
%114 = sitofp i32 %113 to double
%115 = fdiv double %112, %114
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %108, double %115)
%117 = load i32, i32* %8
%118 = zext i32 %117 to i64
%119 = icmp eq i64 %104, %118
br i1 %119, label %120, label %122
120: ; preds = %103
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %122
122: ; preds = %120, %103
%123 = call i32 @putchar(i32 10)
%124 = add nuw nsw i64 %104, 1
%125 = load i32, i32* %7
%126 = sext i32 %125 to i64
%127 = icmp slt i64 %124, %126
br i1 %127, label %103, label %128
128: ; preds = %122, %89
%129 = load i32, i32* %3
%130 = load i32, i32* %4
%131 = call i32 @free_matrix(i32** %69, i32 %129, i32 %130)
%132 = load i32, i32* %3
%133 = load i32, i32* %4
%134 = call i32 @free_matrix(i32** %72, i32 %132, i32 %133)
%135 = load i32, i32* %3
%136 = load i32, i32* %4
%137 = call i32 @free_matrix(i32** %75, i32 %135, i32 %136)
%138 = call i32 @free(i32* %96)
ret void
}