#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_matrix(int **, int, int);
int /*<<< orphan*/ mark_cluster_numbers(int **, int **, int **, int, int,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ plot_all_clusters_compactly(int **, int **, int **, int, int,
                                               int *, int *, char *);
int /*<<< orphan*/ plot_lattice_and_all_clusters(int **, int **, int **, int,
                                                 int, int *, int *, char *);
int /*<<< orphan*/ populate_bonds(int **, int **, int, int, double);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, ...);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ usage(char *, char *, int);
void test_plot_clusters(int argc, char **argv) {
  int M = 200;
  int N = 200;
  double p = 0.6;
  int argi;
  int **vbonds;
  int **hbonds;
  int **site_marks;
  int A1[2] = {-1, -1};
  int A2[2] = {-1, -1};
  char *image_file_name = "p2.ppm";
  int compact = 1;
  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 (strncmp(argv[argi], "f=", 2) == 0)
      image_file_name = &argv[argi][2];
    else if (sscanf(argv[argi], "c=%d", &compact) == 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, 0);
  if (compact)
    plot_all_clusters_compactly(site_marks, vbonds, hbonds, M, N, A1, A2,
                                image_file_name);
  else
    plot_lattice_and_all_clusters(site_marks, vbonds, hbonds, M, N, A1, A2,
                                  image_file_name);
  printf("Wrote %s.\n", image_file_name);
  free_matrix(vbonds, M, N);
  free_matrix(hbonds, M, N);
  free_matrix(site_marks, M, N);
}


x86 assembly (clang, -O0):
<test_plot_clusters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc8,-0x14(%rbp)
movl   $0xc8,-0x18(%rbp)
movsd  0xe3b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0xe37(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe2c(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe29(%rip),%rax
mov    %rax,-0x58(%rbp)
movl   $0x1,-0x5c(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1369 <test_plot_clusters+0x1c9>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdff(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    1231 <test_plot_clusters+0x91>
jmp    1356 <test_plot_clusters+0x1b6>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdd9(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    125d <test_plot_clusters+0xbd>
jmp    1351 <test_plot_clusters+0x1b1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdac(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    128f <test_plot_clusters+0xef>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    134c <test_plot_clusters+0x1ac>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd80(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    12bb <test_plot_clusters+0x11b>
jmp    1347 <test_plot_clusters+0x1a7>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12fb <test_plot_clusters+0x15b>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
jmp    1342 <test_plot_clusters+0x1a2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd1d(%rip),%rsi
lea    -0x5c(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    1327 <test_plot_clusters+0x187>
jmp    133d <test_plot_clusters+0x19d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %edx,%edx
call   10c0 <usage@plt>
jmp    1342 <test_plot_clusters+0x1a2>
jmp    1347 <test_plot_clusters+0x1a7>
jmp    134c <test_plot_clusters+0x1ac>
jmp    1351 <test_plot_clusters+0x1b1>
jmp    1356 <test_plot_clusters+0x1b6>
jmp    135b <test_plot_clusters+0x1bb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f9 <test_plot_clusters+0x59>
cmpl   $0x3,-0x14(%rbp)
jl     137d <test_plot_clusters+0x1dd>
cmpl   $0x3,-0x18(%rbp)
jge    1396 <test_plot_clusters+0x1f6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1,%edx
call   10c0 <usage@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   1090 <allocate_matrix@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   1090 <allocate_matrix@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2e,%edx
call   1090 <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   1080 <populate_bonds@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
call   1060 <mark_cluster_numbers@plt>
cmpl   $0x0,-0x5c(%rbp)
je     143b <test_plot_clusters+0x29b>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    -0x48(%rbp),%r9
lea    -0x50(%rbp),%r10
mov    -0x58(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <plot_all_clusters_compactly@plt>
jmp    1468 <test_plot_clusters+0x2c8>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    -0x48(%rbp),%r9
lea    -0x50(%rbp),%r10
mov    -0x58(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   10b0 <plot_lattice_and_all_clusters@plt>
mov    -0x58(%rbp),%rsi
lea    0xbbd(%rip),%rdi
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <free_matrix@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <free_matrix@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <free_matrix@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_plot_clusters>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
movl   $0xc8,0x10(%rsp)
movl   $0xc8,0xc(%rsp)
movabs $0x3fe3333333333333,%rax
33 e3 3f
mov    %rax,0x30(%rsp)
movq   $0xffffffffffffffff,0x28(%rsp)
ff ff
movq   $0xffffffffffffffff,0x20(%rsp)
ff ff
movl   $0x1,0x14(%rsp)
cmp    $0x3,%edi
jl     12fe <test_plot_clusters+0x15e>
mov    %edi,%r14d
lea    0xe03(%rip),%rax
mov    %rax,0x18(%rsp)
mov    $0x2,%r13d
lea    0xdf8(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%rbp
jmp    123d <test_plot_clusters+0x9d>
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
cmp    %r13,%r14
je     1316 <test_plot_clusters+0x176>
mov    (%rbx,%r13,8),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1230 <test_plot_clusters+0x90>
mov    (%rbx,%r13,8),%rdi
lea    0xdaf(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1230 <test_plot_clusters+0x90>
mov    (%rbx,%r13,8),%rdi
lea    0xd94(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     121b <test_plot_clusters+0x7b>
mov    (%rbx,%r13,8),%rdi
lea    0xd80(%rip),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1230 <test_plot_clusters+0x90>
mov    (%rbx,%r13,8),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
mov    (%rbx,%r13,8),%rdi
test   %rax,%rax
je     12f0 <test_plot_clusters+0x150>
lea    0xd53(%rip),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1230 <test_plot_clusters+0x90>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
xor    %edx,%edx
call   10c0 <usage@plt>
jmp    1230 <test_plot_clusters+0x90>
add    $0x2,%rdi
mov    %rdi,0x18(%rsp)
jmp    1230 <test_plot_clusters+0x90>
lea    0xcfb(%rip),%r15
mov    $0xc8,%esi
mov    $0xc8,%edi
cmp    $0x3,%edi
jge    1328 <test_plot_clusters+0x188>
jmp    132d <test_plot_clusters+0x18d>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x18(%rsp),%r15
cmp    $0x3,%edi
jl     132d <test_plot_clusters+0x18d>
cmp    $0x2,%esi
jg     1346 <test_plot_clusters+0x1a6>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
mov    $0x1,%edx
call   10c0 <usage@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   1090 <allocate_matrix@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   1090 <allocate_matrix@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    $0x2e,%edx
call   1090 <allocate_matrix@plt>
mov    %rax,%r14
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <populate_bonds@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %r9d,%r9d
call   1060 <mark_cluster_numbers@plt>
cmpl   $0x0,0x14(%rsp)
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0x20(%rsp),%rax
lea    0x28(%rsp),%r9
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
je     13d7 <test_plot_clusters+0x237>
push   %r15
push   %rax
call   1030 <plot_all_clusters_compactly@plt>
jmp    13df <test_plot_clusters+0x23f>
push   %r15
push   %rax
call   10b0 <plot_lattice_and_all_clusters@plt>
add    $0x10,%rsp
lea    0xc36(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1050 <free_matrix@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_plot_clusters.A1 = [2 x i32] [i32 -1, i32 -1]
@__const.test_plot_clusters.A2 = [2 x i32] [i32 -1, i32 -1]
@.str = [7 x i8] c"p2.ppm\00"
@.str.1 = [5 x i8] c"M=%d\00"
@.str.2 = [5 x i8] c"N=%d\00"
@.str.3 = [6 x i8] c"MN=%d\00"
@.str.4 = [6 x i8] c"p=%lf\00"
@.str.5 = [3 x i8] c"f=\00"
@.str.6 = [5 x i8] c"c=%d\00"
@.str.7 = [11 x i8] c"Wrote %s.\0A\00"
define void @test_plot_clusters(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 [2 x i32]
%13 = alloca [2 x i32]
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 200, i32* %5
store i32 200, i32* %6
store double 6.000000e-01, double* %7
%16 = bitcast [2 x i32]* %12 to i8*
%17 = bitcast [2 x i32]* %13 to i8*
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %14
store i32 1, i32* %15
store i32 2, i32* %8
br label %18
18: ; preds = %97, %2
%19 = load i32, i32* %8
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %100
22: ; preds = %18
%23 = load i8**, i8*** %4
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %31
30: ; preds = %22
br label %96
31: ; preds = %22
%32 = load i8**, i8*** %4
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %40
39: ; preds = %31
br label %95
40: ; preds = %31
%41 = load i8**, i8*** %4
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i8*, ...) @sscanf(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %40
%49 = load i32, i32* %5
store i32 %49, i32* %6
br label %94
50: ; preds = %40
%51 = load i8**, i8*** %4
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i8*, ...) @sscanf(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double* %7)
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %59
58: ; preds = %50
br label %93
59: ; preds = %50
%60 = load i8**, i8*** %4
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %74
67: ; preds = %59
%68 = load i8**, i8*** %4
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = getelementptr inbounds i8, i8* %72, i64 2
store i8* %73, i8** %14
br label %92
74: ; preds = %59
%75 = load i8**, i8*** %4
%76 = load i32, i32* %8
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 (i8*, i8*, ...) @sscanf(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %15)
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %83
82: ; preds = %74
br label %91
83: ; preds = %74
%84 = load i8**, i8*** %4
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = load i8**, i8*** %4
%88 = getelementptr inbounds i8*, i8** %87, i64 1
%89 = load i8*, i8** %88
%90 = call i32 @usage(i8* %86, i8* %89, i32 0)
br label %91
91: ; preds = %83, %82
br label %92
92: ; preds = %91, %67
br label %93
93: ; preds = %92, %58
br label %94
94: ; preds = %93, %48
br label %95
95: ; preds = %94, %39
br label %96
96: ; preds = %95, %30
br label %97
97: ; preds = %96
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
br label %18
100: ; preds = %18
%101 = load i32, i32* %5
%102 = icmp slt i32 %101, 3
br i1 %102, label %106, label %103
103: ; preds = %100
%104 = load i32, i32* %6
%105 = icmp slt i32 %104, 3
br i1 %105, label %106, label %114
106: ; preds = %103, %100
%107 = load i8**, i8*** %4
%108 = getelementptr inbounds i8*, i8** %107, i64 0
%109 = load i8*, i8** %108
%110 = load i8**, i8*** %4
%111 = getelementptr inbounds i8*, i8** %110, i64 1
%112 = load i8*, i8** %111
%113 = call i32 @usage(i8* %109, i8* %112, i32 1)
br label %114
114: ; preds = %106, %103
%115 = load i32, i32* %5
%116 = load i32, i32* %6
%117 = call i32** @allocate_matrix(i32 %115, i32 %116, i8 signext 0)
store i32** %117, i32*** %9
%118 = load i32, i32* %5
%119 = load i32, i32* %6
%120 = call i32** @allocate_matrix(i32 %118, i32 %119, i8 signext 0)
store i32** %120, i32*** %10
%121 = load i32, i32* %5
%122 = load i32, i32* %6
%123 = call i32** @allocate_matrix(i32 %121, i32 %122, i8 signext 46)
store i32** %123, i32*** %11
%124 = load i32**, i32*** %9
%125 = load i32**, i32*** %10
%126 = load i32, i32* %5
%127 = load i32, i32* %6
%128 = load double, double* %7
%129 = call i32 @populate_bonds(i32** %124, i32** %125, i32 %126, i32 %127, double %128)
%130 = load i32**, i32*** %11
%131 = load i32**, i32*** %9
%132 = load i32**, i32*** %10
%133 = load i32, i32* %5
%134 = load i32, i32* %6
%135 = call i32 @mark_cluster_numbers(i32** %130, i32** %131, i32** %132, i32 %133, i32 %134, i32 0)
%136 = load i32, i32* %15
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %148
138: ; preds = %114
%139 = load i32**, i32*** %11
%140 = load i32**, i32*** %9
%141 = load i32**, i32*** %10
%142 = load i32, i32* %5
%143 = load i32, i32* %6
%144 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%145 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%146 = load i8*, i8** %14
%147 = call i32 @plot_all_clusters_compactly(i32** %139, i32** %140, i32** %141, i32 %142, i32 %143, i32* %144, i32* %145, i8* %146)
br label %158
148: ; preds = %114
%149 = load i32**, i32*** %11
%150 = load i32**, i32*** %9
%151 = load i32**, i32*** %10
%152 = load i32, i32* %5
%153 = load i32, i32* %6
%154 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%155 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%156 = load i8*, i8** %14
%157 = call i32 @plot_lattice_and_all_clusters(i32** %149, i32** %150, i32** %151, i32 %152, i32 %153, i32* %154, i32* %155, i8* %156)
br label %158
158: ; preds = %148, %138
%159 = load i8*, i8** %14
%160 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %159)
%161 = load i32**, i32*** %9
%162 = load i32, i32* %5
%163 = load i32, i32* %6
%164 = call i32 @free_matrix(i32** %161, i32 %162, i32 %163)
%165 = load i32**, i32*** %10
%166 = load i32, i32* %5
%167 = load i32, i32* %6
%168 = call i32 @free_matrix(i32** %165, i32 %166, i32 %167)
%169 = load i32**, i32*** %11
%170 = load i32, i32* %5
%171 = load i32, i32* %6
%172 = call i32 @free_matrix(i32** %169, i32 %170, i32 %171)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"p2.ppm\00"
@.str.1 = [5 x i8] c"M=%d\00"
@.str.2 = [5 x i8] c"N=%d\00"
@.str.3 = [6 x i8] c"MN=%d\00"
@.str.4 = [6 x i8] c"p=%lf\00"
@.str.5 = [3 x i8] c"f=\00"
@.str.6 = [5 x i8] c"c=%d\00"
@.str.7 = [11 x i8] c"Wrote %s.\0A\00"
define void @test_plot_clusters(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 200, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 200, i32* %4
%11 = bitcast double* %5 to i8*
store double 6.000000e-01, double* %5
%12 = bitcast i64* %6 to i8*
store i64 -1, i64* %6
%13 = bitcast i64* %7 to i8*
store i64 -1, i64* %7
%14 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%15 = icmp sgt i32 %0, 2
br i1 %15, label %16, label %61
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %16, %54
%20 = phi i64 [ 2, %16 ], [ %56, %54 ]
%21 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %16 ], [ %55, %54 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %20
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i8*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%25 = icmp eq i32 %24, 1
br i1 %25, label %54, label %26
26: ; preds = %19
%27 = load i8*, i8** %22
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%29 = icmp eq i32 %28, 1
br i1 %29, label %54, label %30
30: ; preds = %26
%31 = load i8*, i8** %22
%32 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %3
store i32 %35, i32* %4
br label %54
36: ; preds = %30
%37 = load i8*, i8** %22
%38 = call i32 (i8*, i8*, ...) @sscanf(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double* %5)
%39 = icmp eq i32 %38, 1
br i1 %39, label %54, label %40
40: ; preds = %36
%41 = load i8*, i8** %22
%42 = call i64 @strncmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%43 = icmp eq i64 %42, 0
%44 = load i8*, i8** %22
br i1 %43, label %45, label %47
45: ; preds = %40
%46 = getelementptr inbounds i8, i8* %44, i64 2
br label %54
47: ; preds = %40
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%49 = icmp eq i32 %48, 1
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = load i8*, i8** %1
%52 = load i8*, i8** %17
%53 = call i32 @usage(i8* %51, i8* %52, i32 0)
br label %54
54: ; preds = %19, %34, %45, %47, %50, %36, %26
%55 = phi i8* [ %21, %19 ], [ %21, %26 ], [ %21, %34 ], [ %21, %36 ], [ %46, %45 ], [ %21, %47 ], [ %21, %50 ]
%56 = add nuw nsw i64 %20, 1
%57 = icmp eq i64 %56, %18
br i1 %57, label %58, label %19
58: ; preds = %54
%59 = load i32, i32* %3
%60 = load i32, i32* %4
br label %61
61: ; preds = %58, %2
%62 = phi i32 [ 200, %2 ], [ %60, %58 ]
%63 = phi i32 [ 200, %2 ], [ %59, %58 ]
%64 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ], [ %55, %58 ]
%65 = icmp slt i32 %63, 3
%66 = icmp slt i32 %62, 3
%67 = select i1 %65, i1 true, i1 %66
br i1 %67, label %68, label %75
68: ; preds = %61
%69 = load i8*, i8** %1
%70 = getelementptr inbounds i8*, i8** %1, i64 1
%71 = load i8*, i8** %70
%72 = call i32 @usage(i8* %69, i8* %71, i32 1)
%73 = load i32, i32* %3
%74 = load i32, i32* %4
br label %75
75: ; preds = %61, %68
%76 = phi i32 [ %62, %61 ], [ %74, %68 ]
%77 = phi i32 [ %63, %61 ], [ %73, %68 ]
%78 = call i32** @allocate_matrix(i32 %77, i32 %76, i8 signext 0)
%79 = load i32, i32* %3
%80 = load i32, i32* %4
%81 = call i32** @allocate_matrix(i32 %79, i32 %80, i8 signext 0)
%82 = load i32, i32* %3
%83 = load i32, i32* %4
%84 = call i32** @allocate_matrix(i32 %82, i32 %83, i8 signext 46)
%85 = load i32, i32* %3
%86 = load i32, i32* %4
%87 = load double, double* %5
%88 = call i32 @populate_bonds(i32** %78, i32** %81, i32 %85, i32 %86, double %87)
%89 = load i32, i32* %3
%90 = load i32, i32* %4
%91 = call i32 @mark_cluster_numbers(i32** %84, i32** %78, i32** %81, i32 %89, i32 %90, i32 0)
%92 = load i32, i32* %8
%93 = icmp eq i32 %92, 0
%94 = load i32, i32* %3
%95 = load i32, i32* %4
%96 = bitcast i64* %6 to i32*
%97 = bitcast i64* %7 to i32*
br i1 %93, label %100, label %98
98: ; preds = %75
%99 = call i32 @plot_all_clusters_compactly(i32** %84, i32** %78, i32** %81, i32 %94, i32 %95, i32* %96, i32* %97, i8* %64)
br label %102
100: ; preds = %75
%101 = call i32 @plot_lattice_and_all_clusters(i32** %84, i32** %78, i32** %81, i32 %94, i32 %95, i32* %96, i32* %97, i8* %64)
br label %102
102: ; preds = %100, %98
%103 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %64)
%104 = load i32, i32* %3
%105 = load i32, i32* %4
%106 = call i32 @free_matrix(i32** %78, i32 %104, i32 %105)
%107 = load i32, i32* %3
%108 = load i32, i32* %4
%109 = call i32 @free_matrix(i32** %81, i32 %107, i32 %108)
%110 = load i32, i32* %3
%111 = load i32, i32* %4
%112 = call i32 @free_matrix(i32** %84, i32 %110, i32 %111)
ret void
}