#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 atoi(char *);
int check_comm_schedule(int **, int);
int /*<<< orphan*/ empty_comm_schedule(int **, int);
int /*<<< orphan*/ fill1_comm_sched(int *, int, int);
int /*<<< orphan*/ fill_comm_schedule(int **, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ free_comm_schedule(int **, int);
int /*<<< orphan*/ invert_comm_schedule(int **, int);
int **make_comm_schedule(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ print_comm_schedule(int **, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sort_comm_schedule(int **, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int **sched;
  int npes = -1, sortpe = -1, steps, i;
  if (argc >= 2) {
    npes = atoi(argv[1]);
    if (npes <= 0) {
      fprintf(stderr, "npes must be positive!");
      return 1;
    }
  }
  if (argc >= 3) {
    sortpe = atoi(argv[2]);
    if (sortpe < 0 || sortpe >= npes) {
      fprintf(stderr, "sortpe must be between 0 and npes-1.\n");
      return 1;
    }
  }
  if (npes != -1) {
    printf("Computing schedule for npes = %d:\n", npes);
    sched = make_comm_schedule(npes);
    if (!sched) {
      fprintf(stderr, "Out of memory!");
      return 6;
    }
    if (steps = check_comm_schedule(sched, npes))
      printf("schedule OK (takes %d steps to complete).\n", steps);
    else
      printf("schedule not OK.\n");
    print_comm_schedule(sched, npes);
    if (sortpe != -1) {
      printf("\nRe-creating schedule for pe = %d...\n", sortpe);
      int *sched1 = (int *)malloc(sizeof(int) * npes);
      for (i = 0; i < npes; ++i)
        sched1[i] = -1;
      fill1_comm_sched(sched1, sortpe, npes);
      printf("  =");
      for (i = 0; i < npes; ++i)
        printf("  %*d", npes < 10 ? 1 : (npes < 100 ? 2 : 3), sched1[i]);
      printf("\n");
      printf("\nSorting schedule for sortpe = %d...\n", sortpe);
      sort_comm_schedule(sched, npes, sortpe);
      if (steps = check_comm_schedule(sched, npes))
        printf("schedule OK (takes %d steps to complete).\n", steps);
      else
        printf("schedule not OK.\n");
      print_comm_schedule(sched, npes);
      printf("\nInverting schedule...\n");
      invert_comm_schedule(sched, npes);
      if (steps = check_comm_schedule(sched, npes))
        printf("schedule OK (takes %d steps to complete).\n", steps);
      else
        printf("schedule not OK.\n");
      print_comm_schedule(sched, npes);
      free_comm_schedule(sched, npes);
      free(sched1);
    }
  } else {
    printf("Doing infinite tests...\n");
    for (npes = 1;; ++npes) {
      int *sched1 = (int *)malloc(sizeof(int) * npes);
      printf("npes = %d...", npes);
      sched = make_comm_schedule(npes);
      if (!sched) {
        fprintf(stderr, "Out of memory!\n");
        return 5;
      }
      for (sortpe = 0; sortpe < npes; ++sortpe) {
        empty_comm_schedule(sched, npes);
        fill_comm_schedule(sched, npes);
        if (!check_comm_schedule(sched, npes)) {
          fprintf(stderr, "\n -- fill error for sortpe = %d!\n", sortpe);
          return 2;
        }
        for (i = 0; i < npes; ++i)
          sched1[i] = -1;
        fill1_comm_sched(sched1, sortpe, npes);
        for (i = 0; i < npes; ++i)
          if (sched1[i] != sched[sortpe][i])
            fprintf(stderr, "\n -- fill1 error for pe = %d!\n", sortpe);
        sort_comm_schedule(sched, npes, sortpe);
        if (!check_comm_schedule(sched, npes)) {
          fprintf(stderr, "\n -- sort error for sortpe = %d!\n", sortpe);
          return 3;
        }
        invert_comm_schedule(sched, npes);
        if (!check_comm_schedule(sched, npes)) {
          fprintf(stderr, "\n -- invert error for sortpe = %d!\n", sortpe);
          return 4;
        }
      }
      free_comm_schedule(sched, npes);
      printf("OK\n");
      if (npes % 50 == 0)
        printf("(...Hit Ctrl-C to stop...)\n");
      free(sched1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1250 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     124b <main+0x6b>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1796 <main+0x5b6>
jmp    1250 <main+0x70>
cmpl   $0x3,-0x8(%rbp)
jl     12a8 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     1280 <main+0xa0>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     12a3 <main+0xc3>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1796 <main+0x5b6>
jmp    12a8 <main+0xc8>
cmpl   $0xffffffff,-0x1c(%rbp)
je     151c <main+0x33c>
mov    -0x1c(%rbp),%esi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   10f0 <make_comm_schedule@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12fd <main+0x11d>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x6,-0x4(%rbp)
jmp    1796 <main+0x5b6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     132b <main+0x14b>
mov    -0x24(%rbp),%esi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1339 <main+0x159>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1100 <print_comm_schedule@plt>
cmpl   $0xffffffff,-0x20(%rbp)
je     1517 <main+0x337>
mov    -0x20(%rbp),%esi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13a3 <main+0x1c3>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    137a <main+0x19a>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <fill1_comm_sched@plt>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    142a <main+0x24a>
cmpl   $0xa,-0x1c(%rbp)
jge    13ea <main+0x20a>
mov    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1400 <main+0x220>
mov    -0x1c(%rbp),%edx
mov    $0x3,%eax
mov    $0x2,%ecx
cmp    $0x64,%edx
cmovl  %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13c7 <main+0x1e7>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xc9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10e0 <sort_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     1486 <main+0x2a6>
mov    -0x24(%rbp),%esi
lea    0xbf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1494 <main+0x2b4>
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1100 <print_comm_schedule@plt>
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <invert_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     14e8 <main+0x308>
mov    -0x24(%rbp),%esi
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f6 <main+0x316>
lea    0xbab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1100 <print_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <free_comm_schedule@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    178f <main+0x5af>
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xbe5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%edi
call   10f0 <make_comm_schedule@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    158f <main+0x3af>
mov    0x2a6d(%rip),%rax
mov    (%rax),%edi
lea    0xbc4(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x5,-0x4(%rbp)
jmp    1796 <main+0x5b6>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    173c <main+0x55c>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1090 <empty_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <fill_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
cmp    $0x0,%eax
jne    15f5 <main+0x415>
mov    0x2a0a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1796 <main+0x5b6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1625 <main+0x445>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    15fc <main+0x41c>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <fill1_comm_sched@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1698 <main+0x4b8>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x28(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     1685 <main+0x4a5>
mov    0x296e(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xaf4(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    168a <main+0x4aa>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    163b <main+0x45b>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10e0 <sort_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
cmp    $0x0,%eax
jne    16e2 <main+0x502>
mov    0x291d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xac2(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1796 <main+0x5b6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <invert_comm_schedule@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <check_comm_schedule@plt>
cmp    $0x0,%eax
jne    1729 <main+0x549>
mov    0x28d6(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xa9d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1796 <main+0x5b6>
jmp    172e <main+0x54e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1596 <main+0x3b6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <free_comm_schedule@plt>
lea    0xa88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1778 <main+0x598>
lea    0xa6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1531 <main+0x351>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     12b5 <main+0xa5>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
test   %eax,%eax
jle    1481 <main+0x271>
mov    %eax,%r12d
mov    $0xffffffff,%r15d
cmp    $0x3,%ebp
jb     1268 <main+0x58>
mov    0x10(%rbx),%rdi
call   1100 <atoi@plt>
test   %eax,%eax
js     1523 <main+0x313>
mov    %eax,%r15d
cmp    %r12d,%eax
jge    1523 <main+0x313>
lea    0xdce(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12d,%edi
call   1120 <make_comm_schedule@plt>
test   %rax,%rax
je     1502 <main+0x2f2>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12d,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     1544 <main+0x334>
lea    0xdc8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1550 <main+0x340>
lea    0xed8(%rip),%rdi
call   1050 <puts@plt>
mov    $0x4,%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
lea    0xe1b(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1120 <make_comm_schedule@plt>
test   %rax,%rax
je     1460 <main+0x250>
mov    %rax,%r12
mov    $0x1,%ebx
lea    0xe2c(%rip),%rbp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x4(,%rax,4),%rax
mov    %rax,0x10(%rsp)
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebx,%esi
call   10c0 <empty_comm_schedule@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   10b0 <fill_comm_schedule@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     1496 <main+0x286>
mov    %r14,%rdi
mov    $0xff,%esi
mov    0x10(%rsp),%rdx
call   10a0 <memset@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1090 <fill1_comm_sched@plt>
xor    %r13d,%r13d
jmp    1379 <main+0x169>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%rbx
je     13a0 <main+0x190>
mov    (%r14,%r13,4),%eax
mov    (%r12,%r15,8),%rcx
cmp    (%rcx,%r13,4),%eax
je     1370 <main+0x160>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
jmp    1370 <main+0x160>
nop
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1110 <sort_comm_schedule@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     14ba <main+0x2aa>
mov    %r12,%rdi
mov    %ebx,%esi
call   1060 <invert_comm_schedule@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     14de <main+0x2ce>
add    $0x1,%r15
cmp    %rbx,%r15
jne    1320 <main+0x110>
mov    %r12,%rdi
mov    %ebx,%esi
call   1070 <free_comm_schedule@plt>
lea    0xdb3(%rip),%rdi
call   1050 <puts@plt>
imul   $0xc28f5c29,%ebx,%eax
ror    %eax
cmp    $0x51eb851,%eax
ja     1419 <main+0x209>
lea    0xd9b(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
lea    0x0(,%rbx,4),%edi
call   10f0 <malloc@plt>
mov    %rax,%r14
lea    0xcb5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%edi
call   1120 <make_comm_schedule@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rax
add    $0x1,%rax
test   %r12,%r12
jne    1305 <main+0xf5>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x5,%eax
jmp    16d6 <main+0x4c6>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
lea    0xb6f(%rip),%rsi
jmp    1533 <main+0x323>
mov    0x2b43(%rip),%rax
mov    (%rax),%edi
lea    0xc67(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x2,%eax
jmp    16d6 <main+0x4c6>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
lea    0xc84(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x3,%eax
jmp    16d6 <main+0x4c6>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
lea    0xc82(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x4,%eax
jmp    16d6 <main+0x4c6>
mov    0x2ad7(%rip),%rax
mov    (%rax),%edi
lea    0xb4e(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x6,%eax
jmp    16d6 <main+0x4c6>
mov    0x2ab6(%rip),%rax
mov    (%rax),%edi
lea    0xae4(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%eax
jmp    16d6 <main+0x4c6>
lea    0xc96(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1130 <print_comm_schedule@plt>
cmp    $0xffffffff,%r15d
je     16d4 <main+0x4c4>
mov    %rbx,0x10(%rsp)
lea    0xb29(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x0(,%r12,4),%edi
call   10f0 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%r14d
lea    0x0(,%r14,4),%rdx
mov    %rax,%rdi
mov    $0xff,%esi
call   10a0 <memset@plt>
mov    %r13,%rdi
mov    %r15d,0x8(%rsp)
mov    %r15d,%esi
mov    %r12d,%edx
call   1090 <fill1_comm_sched@plt>
lea    0xb03(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x64,%r12d
mov    $0x3,%eax
sbb    $0x0,%eax
cmp    $0xa,%r12d
mov    $0x1,%ebx
cmovae %eax,%ebx
lea    0xae1(%rip),%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%r15,4),%edx
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    15f0 <main+0x3e0>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xaaf(%rip),%rdi
mov    0x8(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
call   1110 <sort_comm_schedule@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     165b <main+0x44b>
lea    0xa1f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1667 <main+0x457>
lea    0xb7f(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1130 <print_comm_schedule@plt>
lea    0xb51(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1060 <invert_comm_schedule@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   10d0 <check_comm_schedule@plt>
test   %eax,%eax
je     16aa <main+0x49a>
lea    0x9d0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    16b6 <main+0x4a6>
lea    0xb30(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1130 <print_comm_schedule@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1070 <free_comm_schedule@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"npes must be positive!\00"
@.str.1 = [38 x i8] c"sortpe must be between 0 and npes-1.\0A\00"
@.str.2 = [35 x i8] c"Computing schedule for npes = %d:\0A\00"
@.str.3 = [15 x i8] c"Out of memory!\00"
@.str.4 = [43 x i8] c"schedule OK (takes %d steps to complete).\0A\00"
@.str.5 = [18 x i8] c"schedule not OK.\0A\00"
@.str.6 = [38 x i8] c"\0ARe-creating schedule for pe = %d...\0A\00"
@.str.7 = [4 x i8] c" =\00"
@.str.8 = [6 x i8] c" %*d\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [38 x i8] c"\0ASorting schedule for sortpe = %d...\0A\00"
@.str.11 = [24 x i8] c"\0AInverting schedule...\0A\00"
@.str.12 = [25 x i8] c"Doing infinite tests...\0A\00"
@.str.13 = [13 x i8] c"npes = %d...\00"
@.str.14 = [16 x i8] c"Out of memory!\0A\00"
@.str.15 = [34 x i8] c"\0A -- fill error for sortpe = %d!\0A\00"
@.str.16 = [31 x i8] c"\0A -- fill1 error for pe = %d!\0A\00"
@.str.17 = [34 x i8] c"\0A -- sort error for sortpe = %d!\0A\00"
@.str.18 = [36 x i8] c"\0A -- invert error for sortpe = %d!\0A\00"
@.str.19 = [4 x i8] c"OK\0A\00"
@.str.20 = [28 x i8] c"(...Hit Ctrl-C to stop...)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
store i32 -1, i32* %8
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 2
br i1 %14, label %15, label %26
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %298
25: ; preds = %15
br label %26
26: ; preds = %25, %2
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 3
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %29
%37 = load i32, i32* %8
%38 = load i32, i32* %7
%39 = icmp sge i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36, %29
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %298
43: ; preds = %36
br label %44
44: ; preds = %43, %26
%45 = load i32, i32* %7
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %168
47: ; preds = %44
%48 = load i32, i32* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %7
%51 = call i32** @make_comm_schedule(i32 %50)
store i32** %51, i32*** %6
%52 = load i32**, i32*** %6
%53 = icmp ne i32** %52, null
br i1 %53, label %57, label %54
54: ; preds = %47
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 6, i32* %3
br label %298
57: ; preds = %47
%58 = load i32**, i32*** %6
%59 = load i32, i32* %7
%60 = call i32 @check_comm_schedule(i32** %58, i32 %59)
store i32 %60, i32* %9
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i32, i32* %9
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %67
65: ; preds = %57
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %67
67: ; preds = %65, %62
%68 = load i32**, i32*** %6
%69 = load i32, i32* %7
%70 = call i32 @print_comm_schedule(i32** %68, i32 %69)
%71 = load i32, i32* %8
%72 = icmp ne i32 %71, -1
br i1 %72, label %73, label %167
73: ; preds = %67
%74 = load i32, i32* %8
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = mul i64 4, %77
%79 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to i32*
store i32* %81, i32** %11
store i32 0, i32* %10
br label %82
82: ; preds = %91, %73
%83 = load i32, i32* %10
%84 = load i32, i32* %7
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %94
86: ; preds = %82
%87 = load i32*, i32** %11
%88 = load i32, i32* %10
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %87, i64 %89
store i32 -1, i32* %90
br label %91
91: ; preds = %86
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 1
store i32 %93, i32* %10
br label %82
94: ; preds = %82
%95 = load i32*, i32** %11
%96 = load i32, i32* %8
%97 = load i32, i32* %7
%98 = call i32 @fill1_comm_sched(i32* %95, i32 %96, i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %10
br label %100
100: ; preds = %121, %94
%101 = load i32, i32* %10
%102 = load i32, i32* %7
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %124
104: ; preds = %100
%105 = load i32, i32* %7
%106 = icmp slt i32 %105, 10
br i1 %106, label %107, label %108
107: ; preds = %104
br label %113
108: ; preds = %104
%109 = load i32, i32* %7
%110 = icmp slt i32 %109, 100
%111 = zext i1 %110 to i64
%112 = select i1 %110, i32 2, i32 3
br label %113
113: ; preds = %108, %107
%114 = phi i32 [ 1, %107 ], [ %112, %108 ]
%115 = load i32*, i32** %11
%116 = load i32, i32* %10
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i32, i32* %115, i64 %117
%119 = load i32, i32* %118
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %114, i32 %119)
br label %121
121: ; preds = %113
%122 = load i32, i32* %10
%123 = add nsw i32 %122, 1
store i32 %123, i32* %10
br label %100
124: ; preds = %100
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%126 = load i32, i32* %8
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %126)
%128 = load i32**, i32*** %6
%129 = load i32, i32* %7
%130 = load i32, i32* %8
%131 = call i32 @sort_comm_schedule(i32** %128, i32 %129, i32 %130)
%132 = load i32**, i32*** %6
%133 = load i32, i32* %7
%134 = call i32 @check_comm_schedule(i32** %132, i32 %133)
store i32 %134, i32* %9
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %139
136: ; preds = %124
%137 = load i32, i32* %9
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %137)
br label %141
139: ; preds = %124
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %141
141: ; preds = %139, %136
%142 = load i32**, i32*** %6
%143 = load i32, i32* %7
%144 = call i32 @print_comm_schedule(i32** %142, i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%146 = load i32**, i32*** %6
%147 = load i32, i32* %7
%148 = call i32 @invert_comm_schedule(i32** %146, i32 %147)
%149 = load i32**, i32*** %6
%150 = load i32, i32* %7
%151 = call i32 @check_comm_schedule(i32** %149, i32 %150)
store i32 %151, i32* %9
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %156
153: ; preds = %141
%154 = load i32, i32* %9
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %154)
br label %158
156: ; preds = %141
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %158
158: ; preds = %156, %153
%159 = load i32**, i32*** %6
%160 = load i32, i32* %7
%161 = call i32 @print_comm_schedule(i32** %159, i32 %160)
%162 = load i32**, i32*** %6
%163 = load i32, i32* %7
%164 = call i32 @free_comm_schedule(i32** %162, i32 %163)
%165 = load i32*, i32** %11
%166 = call i32 @free(i32* %165)
br label %167
167: ; preds = %158, %67
br label %297
168: ; preds = %44
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %7
br label %170
170: ; preds = %294, %168
%171 = load i32, i32* %7
%172 = sext i32 %171 to i64
%173 = mul i64 4, %172
%174 = trunc i64 %173 to i32
%175 = call i64 @malloc(i32 %174)
%176 = inttoptr i64 %175 to i32*
store i32* %176, i32** %12
%177 = load i32, i32* %7
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %177)
%179 = load i32, i32* %7
%180 = call i32** @make_comm_schedule(i32 %179)
store i32** %180, i32*** %6
%181 = load i32**, i32*** %6
%182 = icmp ne i32** %181, null
br i1 %182, label %186, label %183
183: ; preds = %170
%184 = load i32, i32* @stderr
%185 = call i32 (i32, i8*, ...) @fprintf(i32 %184, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
store i32 5, i32* %3
br label %298
186: ; preds = %170
store i32 0, i32* %8
br label %187
187: ; preds = %278, %186
%188 = load i32, i32* %8
%189 = load i32, i32* %7
%190 = icmp slt i32 %188, %189
br i1 %190, label %191, label %281
191: ; preds = %187
%192 = load i32**, i32*** %6
%193 = load i32, i32* %7
%194 = call i32 @empty_comm_schedule(i32** %192, i32 %193)
%195 = load i32**, i32*** %6
%196 = load i32, i32* %7
%197 = call i32 @fill_comm_schedule(i32** %195, i32 %196)
%198 = load i32**, i32*** %6
%199 = load i32, i32* %7
%200 = call i32 @check_comm_schedule(i32** %198, i32 %199)
%201 = icmp ne i32 %200, 0
br i1 %201, label %206, label %202
202: ; preds = %191
%203 = load i32, i32* @stderr
%204 = load i32, i32* %8
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %203, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i32 %204)
store i32 2, i32* %3
br label %298
206: ; preds = %191
store i32 0, i32* %10
br label %207
207: ; preds = %216, %206
%208 = load i32, i32* %10
%209 = load i32, i32* %7
%210 = icmp slt i32 %208, %209
br i1 %210, label %211, label %219
211: ; preds = %207
%212 = load i32*, i32** %12
%213 = load i32, i32* %10
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds i32, i32* %212, i64 %214
store i32 -1, i32* %215
br label %216
216: ; preds = %211
%217 = load i32, i32* %10
%218 = add nsw i32 %217, 1
store i32 %218, i32* %10
br label %207
219: ; preds = %207
%220 = load i32*, i32** %12
%221 = load i32, i32* %8
%222 = load i32, i32* %7
%223 = call i32 @fill1_comm_sched(i32* %220, i32 %221, i32 %222)
store i32 0, i32* %10
br label %224
224: ; preds = %249, %219
%225 = load i32, i32* %10
%226 = load i32, i32* %7
%227 = icmp slt i32 %225, %226
br i1 %227, label %228, label %252
228: ; preds = %224
%229 = load i32*, i32** %12
%230 = load i32, i32* %10
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds i32, i32* %229, i64 %231
%233 = load i32, i32* %232
%234 = load i32**, i32*** %6
%235 = load i32, i32* %8
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds i32*, i32** %234, i64 %236
%238 = load i32*, i32** %237
%239 = load i32, i32* %10
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds i32, i32* %238, i64 %240
%242 = load i32, i32* %241
%243 = icmp ne i32 %233, %242
br i1 %243, label %244, label %248
244: ; preds = %228
%245 = load i32, i32* @stderr
%246 = load i32, i32* %8
%247 = call i32 (i32, i8*, ...) @fprintf(i32 %245, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0), i32 %246)
br label %248
248: ; preds = %244, %228
br label %249
249: ; preds = %248
%250 = load i32, i32* %10
%251 = add nsw i32 %250, 1
store i32 %251, i32* %10
br label %224
252: ; preds = %224
%253 = load i32**, i32*** %6
%254 = load i32, i32* %7
%255 = load i32, i32* %8
%256 = call i32 @sort_comm_schedule(i32** %253, i32 %254, i32 %255)
%257 = load i32**, i32*** %6
%258 = load i32, i32* %7
%259 = call i32 @check_comm_schedule(i32** %257, i32 %258)
%260 = icmp ne i32 %259, 0
br i1 %260, label %265, label %261
261: ; preds = %252
%262 = load i32, i32* @stderr
%263 = load i32, i32* %8
%264 = call i32 (i32, i8*, ...) @fprintf(i32 %262, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.17, i64 0, i64 0), i32 %263)
store i32 3, i32* %3
br label %298
265: ; preds = %252
%266 = load i32**, i32*** %6
%267 = load i32, i32* %7
%268 = call i32 @invert_comm_schedule(i32** %266, i32 %267)
%269 = load i32**, i32*** %6
%270 = load i32, i32* %7
%271 = call i32 @check_comm_schedule(i32** %269, i32 %270)
%272 = icmp ne i32 %271, 0
br i1 %272, label %277, label %273
273: ; preds = %265
%274 = load i32, i32* @stderr
%275 = load i32, i32* %8
%276 = call i32 (i32, i8*, ...) @fprintf(i32 %274, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %275)
store i32 4, i32* %3
br label %298
277: ; preds = %265
br label %278
278: ; preds = %277
%279 = load i32, i32* %8
%280 = add nsw i32 %279, 1
store i32 %280, i32* %8
br label %187
281: ; preds = %187
%282 = load i32**, i32*** %6
%283 = load i32, i32* %7
%284 = call i32 @free_comm_schedule(i32** %282, i32 %283)
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%286 = load i32, i32* %7
%287 = srem i32 %286, 50
%288 = icmp eq i32 %287, 0
br i1 %288, label %289, label %291
289: ; preds = %281
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
br label %291
291: ; preds = %289, %281
%292 = load i32*, i32** %12
%293 = call i32 @free(i32* %292)
br label %294
294: ; preds = %291
%295 = load i32, i32* %7
%296 = add nsw i32 %295, 1
store i32 %296, i32* %7
br label %170
297: ; preds = %167
store i32 0, i32* %3
br label %298
298: ; preds = %297, %273, %261, %202, %183, %54, %40, %22
%299 = load i32, i32* %3
ret i32 %299
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"npes must be positive!\00"
@.str.1 = [38 x i8] c"sortpe must be between 0 and npes-1.\0A\00"
@.str.2 = [35 x i8] c"Computing schedule for npes = %d:\0A\00"
@.str.3 = [15 x i8] c"Out of memory!\00"
@.str.4 = [43 x i8] c"schedule OK (takes %d steps to complete).\0A\00"
@.str.6 = [38 x i8] c"\0ARe-creating schedule for pe = %d...\0A\00"
@.str.7 = [4 x i8] c" =\00"
@.str.8 = [6 x i8] c" %*d\00"
@.str.10 = [38 x i8] c"\0ASorting schedule for sortpe = %d...\0A\00"
@.str.13 = [13 x i8] c"npes = %d...\00"
@.str.14 = [16 x i8] c"Out of memory!\0A\00"
@.str.15 = [34 x i8] c"\0A -- fill error for sortpe = %d!\0A\00"
@.str.16 = [31 x i8] c"\0A -- fill1 error for pe = %d!\0A\00"
@.str.17 = [34 x i8] c"\0A -- sort error for sortpe = %d!\0A\00"
@.str.18 = [36 x i8] c"\0A -- invert error for sortpe = %d!\0A\00"
@str = [24 x i8] c"Doing infinite tests...\00"
@str.21 = [3 x i8] c"OK\00"
@str.22 = [27 x i8] c"(...Hit Ctrl-C to stop...)\00"
@str.25 = [23 x i8] c"\0AInverting schedule...\00"
@str.26 = [17 x i8] c"schedule not OK.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %88
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %172
12: ; preds = %4
%13 = icmp ugt i32 %0, 2
br i1 %13, label %14, label %24
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp sgt i32 %17, -1
%19 = icmp slt i32 %17, %7
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %24, label %21
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %172
24: ; preds = %12, %14
%25 = phi i32 [ %17, %14 ], [ -1, %12 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%27 = tail call i32** @make_comm_schedule(i32 %7)
%28 = icmp eq i32** %27, null
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %172
32: ; preds = %24
%33 = tail call i32 @check_comm_schedule(i32** %27, i32 %7)
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %39
37: ; preds = %32
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = tail call i32 @print_comm_schedule(i32** %27, i32 %7)
%41 = icmp eq i32 %25, -1
br i1 %41, label %172, label %42
42: ; preds = %39
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%44 = shl i32 %7, 2
%45 = tail call i64 @malloc(i32 %44)
%46 = inttoptr i64 %45 to i32*
%47 = inttoptr i64 %45 to i8*
%48 = zext i32 %7 to i64
%49 = shl nuw nsw i64 %48, 2
%50 = tail call i32 @fill1_comm_sched(i32* %46, i32 %25, i32 %7)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%52 = icmp ult i32 %7, 10
%53 = icmp ult i32 %7, 100
%54 = select i1 %53, i32 2, i32 3
%55 = select i1 %52, i32 1, i32 %54
%56 = zext i32 %7 to i64
br label %57
57: ; preds = %42, %57
%58 = phi i64 [ 0, %42 ], [ %62, %57 ]
%59 = getelementptr inbounds i32, i32* %46, i64 %58
%60 = load i32, i32* %59
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 %55, i32 %60)
%62 = add nuw nsw i64 %58, 1
%63 = icmp eq i64 %62, %56
br i1 %63, label %64, label %57
64: ; preds = %57
%65 = tail call i32 @putchar(i32 10)
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %25)
%67 = tail call i32 @sort_comm_schedule(i32** %27, i32 %7, i32 %25)
%68 = tail call i32 @check_comm_schedule(i32** %27, i32 %7)
%69 = icmp eq i32 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %64
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %68)
br label %74
72: ; preds = %64
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
%75 = tail call i32 @print_comm_schedule(i32** %27, i32 %7)
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.25, i64 0, i64 0))
%77 = tail call i32 @invert_comm_schedule(i32** %27, i32 %7)
%78 = tail call i32 @check_comm_schedule(i32** %27, i32 %7)
%79 = icmp eq i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %74
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %78)
br label %84
82: ; preds = %74
%83 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
%85 = tail call i32 @print_comm_schedule(i32** %27, i32 %7)
%86 = tail call i32 @free_comm_schedule(i32** %27, i32 %7)
%87 = tail call i32 @free(i32* %46)
br label %172
88: ; preds = %2
%89 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%90 = tail call i64 @malloc(i32 4)
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 1)
%92 = tail call i32** @make_comm_schedule(i32 1)
%93 = icmp eq i32** %92, null
br i1 %93, label %104, label %94
94: ; preds = %88, %162
%95 = phi i64 [ %164, %162 ], [ 1, %88 ]
%96 = phi i64 [ %171, %162 ], [ 0, %88 ]
%97 = phi i32** [ %169, %162 ], [ %92, %88 ]
%98 = phi i64 [ %167, %162 ], [ %90, %88 ]
%99 = shl i64 %96, 2
%100 = add nuw i64 %99, 4
%101 = inttoptr i64 %98 to i32*
%102 = inttoptr i64 %98 to i8*
%103 = trunc i64 %95 to i32
br label %107
104: ; preds = %162, %88
%105 = load i32, i32* @stderr
%106 = tail call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %172
107: ; preds = %94, %151
%108 = phi i64 [ 0, %94 ], [ %152, %151 ]
%109 = tail call i32 @empty_comm_schedule(i32** %97, i32 %103)
%110 = tail call i32 @fill_comm_schedule(i32** %97, i32 %103)
%111 = tail call i32 @check_comm_schedule(i32** %97, i32 %103)
%112 = icmp eq i32 %111, 0
br i1 %112, label %117, label %113
113: ; preds = %107
%114 = trunc i64 %108 to i32
%115 = tail call i32 @fill1_comm_sched(i32* %101, i32 %114, i32 %103)
%116 = getelementptr inbounds i32*, i32** %97, i64 %108
br label %121
117: ; preds = %107
%118 = trunc i64 %108 to i32
%119 = load i32, i32* @stderr
%120 = tail call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i32 %118)
br label %172
121: ; preds = %113, %132
%122 = phi i64 [ 0, %113 ], [ %133, %132 ]
%123 = getelementptr inbounds i32, i32* %101, i64 %122
%124 = load i32, i32* %123
%125 = load i32*, i32** %116
%126 = getelementptr inbounds i32, i32* %125, i64 %122
%127 = load i32, i32* %126
%128 = icmp eq i32 %124, %127
br i1 %128, label %132, label %129
129: ; preds = %121
%130 = load i32, i32* @stderr
%131 = tail call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0), i32 %114)
br label %132
132: ; preds = %121, %129
%133 = add nuw nsw i64 %122, 1
%134 = icmp eq i64 %133, %95
br i1 %134, label %135, label %121
135: ; preds = %132
%136 = tail call i32 @sort_comm_schedule(i32** %97, i32 %103, i32 %114)
%137 = tail call i32 @check_comm_schedule(i32** %97, i32 %103)
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %135
%140 = trunc i64 %108 to i32
%141 = load i32, i32* @stderr
%142 = tail call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.17, i64 0, i64 0), i32 %140)
br label %172
143: ; preds = %135
%144 = tail call i32 @invert_comm_schedule(i32** %97, i32 %103)
%145 = tail call i32 @check_comm_schedule(i32** %97, i32 %103)
%146 = icmp eq i32 %145, 0
br i1 %146, label %147, label %151
147: ; preds = %143
%148 = trunc i64 %108 to i32
%149 = load i32, i32* @stderr
%150 = tail call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %148)
br label %172
151: ; preds = %143
%152 = add nuw nsw i64 %108, 1
%153 = icmp eq i64 %152, %95
br i1 %153, label %154, label %107
154: ; preds = %151
%155 = trunc i64 %95 to i32
%156 = tail call i32 @free_comm_schedule(i32** %97, i32 %155)
%157 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.21, i64 0, i64 0))
%158 = urem i32 %155, 50
%159 = icmp eq i32 %158, 0
br i1 %159, label %160, label %162
160: ; preds = %154
%161 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
br label %162
162: ; preds = %160, %154
%163 = tail call i32 @free(i32* %101)
%164 = add nuw i64 %95, 1
%165 = trunc i64 %164 to i32
%166 = shl i32 %165, 2
%167 = tail call i64 @malloc(i32 %166)
%168 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32 %165)
%169 = tail call i32** @make_comm_schedule(i32 %165)
%170 = icmp eq i32** %169, null
%171 = add nuw nsw i64 %96, 1
br i1 %170, label %104, label %94
172: ; preds = %104, %117, %139, %147, %84, %39, %29, %21, %9
%173 = phi i32 [ 1, %9 ], [ 1, %21 ], [ 6, %29 ], [ 0, %39 ], [ 0, %84 ], [ 5, %104 ], [ 2, %117 ], [ 3, %139 ], [ 4, %147 ]
ret i32 %173
}