#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 /*<<< orphan*/ set_A1_A2(int *, int *, int, int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ usage(char *, char *, int);
void test_A1_or_A2_in_C(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 A1[2], A1_clno;
  int A2[2], A2_clno;
  int yes = 0;
  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, '.');
  set_A1_A2(A1, A2, 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);
  A1_clno = site_marks[A1[0]][A1[1]];
  A2_clno = site_marks[A2[0]][A2[1]];
  if (print_lattice) {
    printf("A1 at %d, %d\n", A1[0], A1[1]);
    printf("A2 at %d, %d\n", A2[0], A2[1]);
    printf("A1 cluster number = %d\n", A1_clno);
    printf("A2 cluster number = %d\n", A2_clno);
    printf("Largest cluster  = %d\n", C_clno);
  }
  yes = 0;
  if ((A1_clno == C_clno) || (A2_clno == C_clno))
    yes = 1;
  printf("%s\n", yes ? "Yes" : "No");
  free_matrix(vbonds, M, N);
  free_matrix(hbonds, M, N);
  free_matrix(site_marks, M, N);
  free(cluster_sizes);
}


x86 assembly (clang, -O0):
<test_A1_or_A2_in_C>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x12,-0x14(%rbp)
movl   $0x12,-0x18(%rbp)
movsd  0xe0b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    133a <test_A1_or_A2_in_C+0x16a>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdda(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    1247 <test_A1_or_A2_in_C+0x77>
jmp    1327 <test_A1_or_A2_in_C+0x157>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb4(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    1273 <test_A1_or_A2_in_C+0xa3>
jmp    1322 <test_A1_or_A2_in_C+0x152>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd87(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12a5 <test_A1_or_A2_in_C+0xd5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    131d <test_A1_or_A2_in_C+0x14d>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd5b(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12d1 <test_A1_or_A2_in_C+0x101>
jmp    1318 <test_A1_or_A2_in_C+0x148>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd35(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12fd <test_A1_or_A2_in_C+0x12d>
jmp    1313 <test_A1_or_A2_in_C+0x143>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %edx,%edx
call   10e0 <usage@plt>
jmp    1318 <test_A1_or_A2_in_C+0x148>
jmp    131d <test_A1_or_A2_in_C+0x14d>
jmp    1322 <test_A1_or_A2_in_C+0x152>
jmp    1327 <test_A1_or_A2_in_C+0x157>
jmp    132c <test_A1_or_A2_in_C+0x15c>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120f <test_A1_or_A2_in_C+0x3f>
cmpl   $0x3,-0x14(%rbp)
jl     134e <test_A1_or_A2_in_C+0x17e>
cmpl   $0x3,-0x18(%rbp)
jge    1367 <test_A1_or_A2_in_C+0x197>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1,%edx
call   10e0 <usage@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2e,%edx
call   10b0 <allocate_matrix@plt>
mov    %rax,-0x40(%rbp)
lea    -0x5c(%rbp),%rdi
lea    -0x68(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1070 <set_A1_A2@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
movsd  -0x20(%rbp),%xmm0
call   10a0 <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     1406 <test_A1_or_A2_in_C+0x236>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1090 <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   10d0 <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   10f0 <get_cluster_sizes@plt>
mov    -0x40(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x60(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     14dc <test_A1_or_A2_in_C+0x30c>
mov    -0x5c(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x68(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xb8b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x60(%rbp),%esi
lea    0xb88(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x6c(%rbp),%esi
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x54(%rbp),%esi
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x70(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x54(%rbp),%eax
je     14fb <test_A1_or_A2_in_C+0x32b>
mov    -0x6c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jne    1502 <test_A1_or_A2_in_C+0x332>
movl   $0x1,-0x70(%rbp)
mov    -0x70(%rbp),%ecx
lea    0xb7e(%rip),%rsi
lea    0xb73(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xb61(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
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    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_A1_or_A2_in_C>:
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,0x28(%rsp)
movl   $0x0,0x14(%rsp)
mov    $0x12,%esi
mov    $0x12,%edi
cmp    $0x3,%eax
jl     12fe <test_A1_or_A2_in_C+0x11e>
mov    %eax,%ebp
mov    $0x2,%r12d
lea    0xdc4(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r13
jmp    125d <test_A1_or_A2_in_C+0x7d>
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
add    $0x1,%r12
cmp    %r12,%rbp
je     12f6 <test_A1_or_A2_in_C+0x116>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1250 <test_A1_or_A2_in_C+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd88(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1250 <test_A1_or_A2_in_C+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd6d(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1248 <test_A1_or_A2_in_C+0x68>
mov    (%rbx,%r12,8),%rdi
lea    0xd59(%rip),%rsi
lea    0x28(%rsp),%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1250 <test_A1_or_A2_in_C+0x70>
mov    (%rbx,%r12,8),%rdi
lea    0xd43(%rip),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
cmp    $0x1,%eax
je     1250 <test_A1_or_A2_in_C+0x70>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
xor    %edx,%edx
call   10f0 <usage@plt>
jmp    1250 <test_A1_or_A2_in_C+0x70>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
cmp    $0x3,%edi
jl     1308 <test_A1_or_A2_in_C+0x128>
cmp    $0x2,%esi
jg     1321 <test_A1_or_A2_in_C+0x141>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rsi
mov    $0x1,%edx
call   10f0 <usage@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   10c0 <allocate_matrix@plt>
mov    %rax,%r14
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
xor    %edx,%edx
call   10c0 <allocate_matrix@plt>
mov    %rax,%r15
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    $0x2e,%edx
call   10c0 <allocate_matrix@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0x30(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1080 <set_A1_A2@plt>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
movsd  0x28(%rsp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <populate_bonds@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0x1c(%rsp),%r9
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <mark_cluster_numbers@plt>
cmpl   $0x0,0x14(%rsp)
je     13bc <test_A1_or_A2_in_C+0x1dc>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   10a0 <print_lattice_and_cluster_numbers@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <sanity_check_cluster_numbers@plt>
mov    0x1c(%rsp),%edi
shl    $0x2,%edi
call   10e0 <malloc_or_die@plt>
mov    %rax,%r12
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x1c(%rsp),%ecx
lea    0x18(%rsp),%r9
mov    %rbx,%rdi
mov    %rax,%r8
call   1100 <get_cluster_sizes@plt>
movslq 0x30(%rsp),%rsi
mov    (%rbx,%rsi,8),%rax
movslq 0x34(%rsp),%rdx
mov    (%rax,%rdx,4),%r13d
movslq 0x20(%rsp),%rax
mov    (%rbx,%rax,8),%rax
movslq 0x24(%rsp),%rcx
mov    (%rax,%rcx,4),%ebp
cmpl   $0x0,0x14(%rsp)
je     147f <test_A1_or_A2_in_C+0x29f>
lea    0xbe8(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%edx
lea    0xbe0(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xbe0(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xbe7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xbeb(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x18(%rsp),%eax
cmp    %eax,%ebp
lea    0xbee(%rip),%rcx
lea    0xbeb(%rip),%rdi
cmove  %rcx,%rdi
cmp    %eax,%r13d
cmove  %rcx,%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r15,%rdi
call   1050 <free_matrix@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1050 <free_matrix@plt>
mov    %r12,%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 = [14 x i8] c"A1 at %d, %d\0A\00"
@.str.6 = [14 x i8] c"A2 at %d, %d\0A\00"
@.str.7 = [24 x i8] c"A1 cluster number = %d\0A\00"
@.str.8 = [24 x i8] c"A2 cluster number = %d\0A\00"
@.str.9 = [23 x i8] c"Largest cluster = %d\0A\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [4 x i8] c"Yes\00"
@.str.12 = [3 x i8] c"No\00"
define void @test_A1_or_A2_in_C(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 [2 x i32]
%17 = alloca i32
%18 = alloca [2 x i32]
%19 = alloca i32
%20 = 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 0, i32* %20
store i32 2, i32* %9
br label %21
21: ; preds = %84, %2
%22 = load i32, i32* %9
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %87
25: ; preds = %21
%26 = load i8**, i8*** %4
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %5)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %25
br label %83
34: ; preds = %25
%35 = load i8**, i8*** %4
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %43
42: ; preds = %34
br label %82
43: ; preds = %34
%44 = load i8**, i8*** %4
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i8*, i8*, ...) @sscanf(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = load i32, i32* %5
store i32 %52, i32* %6
br label %81
53: ; preds = %43
%54 = load i8**, i8*** %4
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 (i8*, i8*, ...) @sscanf(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %7)
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %62
61: ; preds = %53
br label %80
62: ; preds = %53
%63 = load i8**, i8*** %4
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 (i8*, i8*, ...) @sscanf(i8* %67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %71
70: ; preds = %62
br label %79
71: ; preds = %62
%72 = load i8**, i8*** %4
%73 = getelementptr inbounds i8*, i8** %72, i64 0
%74 = load i8*, i8** %73
%75 = load i8**, i8*** %4
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i32 @usage(i8* %74, i8* %77, i32 0)
br label %79
79: ; preds = %71, %70
br label %80
80: ; preds = %79, %61
br label %81
81: ; preds = %80, %51
br label %82
82: ; preds = %81, %42
br label %83
83: ; preds = %82, %33
br label %84
84: ; preds = %83
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 1
store i32 %86, i32* %9
br label %21
87: ; preds = %21
%88 = load i32, i32* %5
%89 = icmp slt i32 %88, 3
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = load i32, i32* %6
%92 = icmp slt i32 %91, 3
br i1 %92, label %93, label %101
93: ; preds = %90, %87
%94 = load i8**, i8*** %4
%95 = getelementptr inbounds i8*, i8** %94, i64 0
%96 = load i8*, i8** %95
%97 = load i8**, i8*** %4
%98 = getelementptr inbounds i8*, i8** %97, i64 1
%99 = load i8*, i8** %98
%100 = call i32 @usage(i8* %96, i8* %99, i32 1)
br label %101
101: ; preds = %93, %90
%102 = load i32, i32* %5
%103 = load i32, i32* %6
%104 = call i32** @allocate_matrix(i32 %102, i32 %103, i8 signext 0)
store i32** %104, i32*** %10
%105 = load i32, i32* %5
%106 = load i32, i32* %6
%107 = call i32** @allocate_matrix(i32 %105, i32 %106, i8 signext 0)
store i32** %107, i32*** %11
%108 = load i32, i32* %5
%109 = load i32, i32* %6
%110 = call i32** @allocate_matrix(i32 %108, i32 %109, i8 signext 46)
store i32** %110, i32*** %12
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%112 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%113 = load i32, i32* %5
%114 = load i32, i32* %6
%115 = call i32 @set_A1_A2(i32* %111, i32* %112, i32 %113, i32 %114)
%116 = load i32**, i32*** %10
%117 = load i32**, i32*** %11
%118 = load i32, i32* %5
%119 = load i32, i32* %6
%120 = load double, double* %7
%121 = call i32 @populate_bonds(i32** %116, i32** %117, i32 %118, i32 %119, double %120)
%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 @mark_cluster_numbers(i32** %122, i32** %123, i32** %124, i32 %125, i32 %126, i32* %13)
%128 = load i32, i32* %8
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %137
130: ; preds = %101
%131 = load i32**, i32*** %12
%132 = load i32**, i32*** %10
%133 = load i32**, i32*** %11
%134 = load i32, i32* %5
%135 = load i32, i32* %6
%136 = call i32 @print_lattice_and_cluster_numbers(i32** %131, i32** %132, i32** %133, i32 %134, i32 %135)
br label %137
137: ; preds = %130, %101
%138 = load i32**, i32*** %12
%139 = load i32**, i32*** %10
%140 = load i32**, i32*** %11
%141 = load i32, i32* %5
%142 = load i32, i32* %6
%143 = call i32 @sanity_check_cluster_numbers(i32** %138, i32** %139, i32** %140, i32 %141, i32 %142)
%144 = load i32, i32* %13
%145 = sext i32 %144 to i64
%146 = mul i64 4, %145
%147 = trunc i64 %146 to i32
%148 = call i64 @malloc_or_die(i32 %147)
%149 = inttoptr i64 %148 to i32*
store i32* %149, i32** %14
%150 = load i32**, i32*** %12
%151 = load i32, i32* %5
%152 = load i32, i32* %6
%153 = load i32, i32* %13
%154 = load i32*, i32** %14
%155 = call i32 @get_cluster_sizes(i32** %150, i32 %151, i32 %152, i32 %153, i32* %154, i32* %15)
%156 = load i32**, i32*** %12
%157 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%158 = load i32, i32* %157
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i32*, i32** %156, i64 %159
%161 = load i32*, i32** %160
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%163 = load i32, i32* %162
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32, i32* %161, i64 %164
%166 = load i32, i32* %165
store i32 %166, i32* %17
%167 = load i32**, i32*** %12
%168 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%169 = load i32, i32* %168
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i32*, i32** %167, i64 %170
%172 = load i32*, i32** %171
%173 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%174 = load i32, i32* %173
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i32, i32* %172, i64 %175
%177 = load i32, i32* %176
store i32 %177, i32* %19
%178 = load i32, i32* %8
%179 = icmp ne i32 %178, 0
br i1 %179, label %180, label %197
180: ; preds = %137
%181 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%182 = load i32, i32* %181
%183 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%184 = load i32, i32* %183
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %182, i32 %184)
%186 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 0
%187 = load i32, i32* %186
%188 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%189 = load i32, i32* %188
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %187, i32 %189)
%191 = load i32, i32* %17
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %191)
%193 = load i32, i32* %19
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %193)
%195 = load i32, i32* %15
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %195)
br label %197
197: ; preds = %180, %137
store i32 0, i32* %20
%198 = load i32, i32* %17
%199 = load i32, i32* %15
%200 = icmp eq i32 %198, %199
br i1 %200, label %205, label %201
201: ; preds = %197
%202 = load i32, i32* %19
%203 = load i32, i32* %15
%204 = icmp eq i32 %202, %203
br i1 %204, label %205, label %206
205: ; preds = %201, %197
store i32 1, i32* %20
br label %206
206: ; preds = %205, %201
%207 = load i32, i32* %20
%208 = icmp ne i32 %207, 0
%209 = zext i1 %208 to i64
%210 = select i1 %208, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0)
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %210)
%212 = load i32**, i32*** %10
%213 = load i32, i32* %5
%214 = load i32, i32* %6
%215 = call i32 @free_matrix(i32** %212, i32 %213, i32 %214)
%216 = load i32**, i32*** %11
%217 = load i32, i32* %5
%218 = load i32, i32* %6
%219 = call i32 @free_matrix(i32** %216, i32 %217, i32 %218)
%220 = load i32**, i32*** %12
%221 = load i32, i32* %5
%222 = load i32, i32* %6
%223 = call i32 @free_matrix(i32** %220, i32 %221, i32 %222)
%224 = load i32*, i32** %14
%225 = call i32 @free(i32* %224)
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 = [14 x i8] c"A1 at %d, %d\0A\00"
@.str.6 = [14 x i8] c"A2 at %d, %d\0A\00"
@.str.7 = [24 x i8] c"A1 cluster number = %d\0A\00"
@.str.8 = [24 x i8] c"A2 cluster number = %d\0A\00"
@.str.9 = [23 x i8] c"Largest cluster = %d\0A\00"
@.str.11 = [4 x i8] c"Yes\00"
@.str.12 = [3 x i8] c"No\00"
define void @test_A1_or_A2_in_C(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = alloca [2 x i32]
%11 = bitcast i32* %3 to i8*
store i32 18, i32* %3
%12 = bitcast i32* %4 to i8*
store i32 18, i32* %4
%13 = bitcast double* %5 to i8*
store double 6.000000e-01, double* %5
%14 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast [2 x i32]* %9 to i8*
%18 = bitcast [2 x i32]* %10 to i8*
%19 = icmp sgt i32 %0, 2
br i1 %19, label %20, label %57
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = zext i32 %0 to i64
br label %23
23: ; preds = %20, %51
%24 = phi i64 [ 2, %20 ], [ %52, %51 ]
%25 = getelementptr inbounds i8*, i8** %1, 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* %3)
%28 = icmp eq i32 %27, 1
br i1 %28, label %51, label %29
29: ; preds = %23
%30 = load i8*, i8** %25
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%32 = icmp eq i32 %31, 1
br i1 %32, label %51, label %33
33: ; preds = %29
%34 = load i8*, i8** %25
%35 = call i32 (i8*, i8*, ...) @sscanf(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32, i32* %3
store i32 %38, i32* %4
br label %51
39: ; preds = %33
%40 = load i8*, i8** %25
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double* %5)
%42 = icmp eq i32 %41, 1
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = load i8*, i8** %25
%45 = call i32 (i8*, i8*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%46 = icmp eq i32 %45, 1
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i8*, i8** %1
%49 = load i8*, i8** %21
%50 = call i32 @usage(i8* %48, i8* %49, i32 0)
br label %51
51: ; preds = %23, %37, %47, %43, %39, %29
%52 = add nuw nsw i64 %24, 1
%53 = icmp eq i64 %52, %22
br i1 %53, label %54, label %23
54: ; preds = %51
%55 = load i32, i32* %3
%56 = load i32, i32* %4
br label %57
57: ; preds = %54, %2
%58 = phi i32 [ %56, %54 ], [ 18, %2 ]
%59 = phi i32 [ %55, %54 ], [ 18, %2 ]
%60 = icmp slt i32 %59, 3
%61 = icmp slt i32 %58, 3
%62 = select i1 %60, i1 true, i1 %61
br i1 %62, label %63, label %70
63: ; preds = %57
%64 = load i8*, i8** %1
%65 = getelementptr inbounds i8*, i8** %1, i64 1
%66 = load i8*, i8** %65
%67 = call i32 @usage(i8* %64, i8* %66, i32 1)
%68 = load i32, i32* %3
%69 = load i32, i32* %4
br label %70
70: ; preds = %57, %63
%71 = phi i32 [ %58, %57 ], [ %69, %63 ]
%72 = phi i32 [ %59, %57 ], [ %68, %63 ]
%73 = call i32** @allocate_matrix(i32 %72, i32 %71, i8 signext 0)
%74 = load i32, i32* %3
%75 = load i32, i32* %4
%76 = call i32** @allocate_matrix(i32 %74, i32 %75, i8 signext 0)
%77 = load i32, i32* %3
%78 = load i32, i32* %4
%79 = call i32** @allocate_matrix(i32 %77, i32 %78, i8 signext 46)
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%82 = load i32, i32* %3
%83 = load i32, i32* %4
%84 = call i32 @set_A1_A2(i32* %80, i32* %81, i32 %82, i32 %83)
%85 = load i32, i32* %3
%86 = load i32, i32* %4
%87 = load double, double* %5
%88 = call i32 @populate_bonds(i32** %73, i32** %76, i32 %85, i32 %86, double %87)
%89 = load i32, i32* %3
%90 = load i32, i32* %4
%91 = call i32 @mark_cluster_numbers(i32** %79, i32** %73, i32** %76, i32 %89, i32 %90, i32* %7)
%92 = load i32, i32* %6
%93 = icmp eq i32 %92, 0
br i1 %93, label %98, label %94
94: ; preds = %70
%95 = load i32, i32* %3
%96 = load i32, i32* %4
%97 = call i32 @print_lattice_and_cluster_numbers(i32** %79, i32** %73, i32** %76, i32 %95, i32 %96)
br label %98
98: ; preds = %94, %70
%99 = load i32, i32* %3
%100 = load i32, i32* %4
%101 = call i32 @sanity_check_cluster_numbers(i32** %79, i32** %73, i32** %76, i32 %99, i32 %100)
%102 = load i32, i32* %7
%103 = shl i32 %102, 2
%104 = call i64 @malloc_or_die(i32 %103)
%105 = inttoptr i64 %104 to i32*
%106 = load i32, i32* %3
%107 = load i32, i32* %4
%108 = load i32, i32* %7
%109 = call i32 @get_cluster_sizes(i32** %79, i32 %106, i32 %107, i32 %108, i32* %105, i32* %8)
%110 = load i32, i32* %80
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32*, i32** %79, i64 %111
%113 = load i32*, i32** %112
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%115 = load i32, i32* %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %113, i64 %116
%118 = load i32, i32* %117
%119 = load i32, i32* %81
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i32*, i32** %79, i64 %120
%122 = load i32*, i32** %121
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%124 = load i32, i32* %123
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i32, i32* %122, i64 %125
%127 = load i32, i32* %126
%128 = load i32, i32* %6
%129 = icmp eq i32 %128, 0
br i1 %129, label %139, label %130
130: ; preds = %98
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %110, i32 %115)
%132 = load i32, i32* %81
%133 = load i32, i32* %123
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %132, i32 %133)
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %118)
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %127)
%137 = load i32, i32* %8
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %137)
br label %139
139: ; preds = %130, %98
%140 = load i32, i32* %8
%141 = icmp eq i32 %118, %140
%142 = icmp eq i32 %127, %140
%143 = select i1 %141, i1 true, i1 %142
%144 = select i1 %143, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0)
%145 = call i32 @puts(i8* dereferenceable(1) %144)
%146 = load i32, i32* %3
%147 = load i32, i32* %4
%148 = call i32 @free_matrix(i32** %73, i32 %146, i32 %147)
%149 = load i32, i32* %3
%150 = load i32, i32* %4
%151 = call i32 @free_matrix(i32** %76, i32 %149, i32 %150)
%152 = load i32, i32* %3
%153 = load i32, i32* %4
%154 = call i32 @free_matrix(i32** %79, i32 %152, i32 %153)
%155 = call i32 @free(i32* %105)
ret void
}