#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 */
typedef int uint64_t;
typedef int ssize_t;
typedef int /*<<< orphan*/ key_t;
typedef int int64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int IPC_CREAT;
int atoi(char *);
int /*<<< orphan*/ bzero(int *, size_t);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ ftok(char *, int);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_graph(int *, int);
int /*<<< orphan*/ printf(char *, float);
int rdtsc();
scalar_t__ shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int shmget(int /*<<< orphan*/, size_t, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ transitive_closure(int *, int, int, int, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int main(int argc, char **argv) {
  FILE *fp = fopen(argv[1], "r");
  if (fp == NULL) {
    perror("Could not open file");
    exit(EXIT_FAILURE);
  }
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int p, n;
  read = getline(&line, &len, fp);
  p = atoi(line);
  read = getline(&line, &len, fp);
  n = atoi(line);
  size_t graph_len = n * n;
  key_t shmkey = ftok("/dev/null", 5);
  int shmid = shmget(shmkey, graph_len * sizeof(int), 0644 | IPC_CREAT);
  if (shmid < 0) {
    perror("Could not create shared memory");
    exit(EXIT_FAILURE);
  }
  int *g = (int *)shmat(shmid, NULL, 0);
  if ((long int)g == -1) {
    perror("Could not attach shared memory");
    exit(EXIT_FAILURE);
  }
  bzero(g, graph_len * sizeof(int));
  while ((read = getline(&line, &len, fp)) != -1) {
    int i, j;
    sscanf(line, "%d %d\n", &i, &j);
    i -= 1;
    j -= 1;
    g[j * n + i] = 1;
  }
  fclose(fp);
  free(line);
  uint64_t start = rdtsc();
  int k, process;
  for (k = 0; k < n; k++) {
    int work_size = n / p;
    int extra = n % p;
    for (process = 0; process < p; process++) {
      int work_start = process * work_size;
      if (fork() == 0) {
        int work_end;
        if (process == p - 1 && extra != 0)
          work_end = extra;
        else
          work_end = work_start + work_size;
        transitive_closure(g, k, n, work_start, work_end);
        exit(EXIT_SUCCESS);
      }
    }
    for (process = 0; process < p; process++) {
      wait(0);
    }
  }
  uint64_t end = rdtsc();
  unsigned int lo1 = start & (((uint64_t)2 << 32) - 1);
  unsigned int lo3 = end & (((int64_t)2 << 32) - 1);
  int cycles1 = lo3 - lo1;
  float tz = ((float)(cycles1));
  float fact = 3092766000 * .000001;
  tz = tz / fact;
  print_graph(g, n);
  printf("%f\n", tz);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdbc(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1276 <main+0x56>
lea    0xda3(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1100 <getline@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1100 <getline@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x34(%rbp),%eax
cltq
mov    %rax,-0x40(%rbp)
lea    0xd40(%rip),%rdi
mov    $0x5,%esi
call   1120 <ftok@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
shl    $0x2,%rsi
mov    0x2cd7(%rip),%rax
mov    (%rax),%edx
or     $0x1a4,%edx
call   10e0 <shmget@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    132d <main+0x10d>
lea    0xd0a(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x48(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10d0 <shmat@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    $0xffffffffffffffff,%rax
jne    1367 <main+0x147>
lea    0xcef(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
shl    $0x2,%rsi
call   10c0 <bzero@plt>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1100 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     13dc <main+0x1bc>
mov    -0x20(%rbp),%rdi
lea    0xcc2(%rip),%rsi
lea    -0x54(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1090 <sscanf@plt>
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1378 <main+0x158>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1070 <rdtsc@plt>
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    14ee <main+0x2ce>
mov    -0x34(%rbp),%eax
cltd
idivl  -0x30(%rbp)
mov    %eax,-0x68(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x30(%rbp)
mov    %edx,-0x6c(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    14b3 <main+0x293>
mov    -0x64(%rbp),%eax
imul   -0x68(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    $0x0,%al
call   1140 <fork@plt>
cmp    $0x0,%rax
jne    14a0 <main+0x280>
mov    -0x64(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1473 <main+0x253>
cmpl   $0x0,-0x6c(%rbp)
je     1473 <main+0x253>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    147c <main+0x25c>
mov    -0x70(%rbp),%eax
add    -0x68(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x70(%rbp),%ecx
mov    -0x74(%rbp),%r8d
call   1080 <transitive_closure@plt>
mov    0x2b3f(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    14a5 <main+0x285>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1426 <main+0x206>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    14db <main+0x2bb>
xor    %edi,%edi
call   1130 <wait@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    14ba <main+0x29a>
jmp    14e0 <main+0x2c0>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    13ff <main+0x1df>
mov    $0x0,%al
call   1070 <rdtsc@plt>
mov    %eax,-0x78(%rbp)
and    -0x5c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
and    -0x78(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
sub    -0x7c(%rbp),%eax
mov    %eax,-0x84(%rbp)
cvtsi2ssl -0x84(%rbp),%xmm0
ff
movss  %xmm0,-0x88(%rbp)
ff
movss  0xad8(%rip),%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
movss  -0x88(%rbp),%xmm0
ff
divss  -0x8c(%rbp),%xmm0
ff
movss  %xmm0,-0x88(%rbp)
ff
mov    -0x50(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <print_graph@plt>
movss  -0x88(%rbp),%xmm0
ff
lea    0xb06(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x8(%rsi),%rdi
lea    0xdc7(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     145a <main+0x23a>
mov    %rax,%r13
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1100 <getline@plt>
mov    0x8(%rsp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1100 <getline@plt>
mov    0x8(%rsp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%r12d
imul   %r12d,%r12d
lea    0xd6e(%rip),%rdi
mov    $0x5,%esi
call   1120 <ftok@plt>
shl    $0x2,%r12
mov    0x2d13(%rip),%rcx
mov    $0x1a4,%edx
or     (%rcx),%edx
mov    %eax,%edi
mov    %r12,%rsi
call   10e0 <shmget@plt>
test   %eax,%eax
js     1463 <main+0x243>
mov    %ebx,0x14(%rsp)
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <shmat@plt>
cmp    $0xffffffffffffffff,%rax
je     146c <main+0x24c>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   10c0 <bzero@plt>
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    %r13,%rdx
call   1100 <getline@plt>
cmp    $0xffffffff,%eax
je     137c <main+0x15c>
movslq 0x14(%rsp),%r12
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rdi
lea    0xd22(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
call   1090 <sscanf@plt>
movslq 0x24(%rsp),%rax
movslq 0x20(%rsp),%rcx
add    $0xffffffffffffffff,%rcx
imul   %r12,%rcx
add    %rax,%rcx
movl   $0x1,-0x4(%r15,%rcx,4)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1100 <getline@plt>
cmp    $0xffffffff,%eax
jne    1330 <main+0x110>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1070 <rdtsc@plt>
mov    0x14(%rsp),%r14d
test   %r14d,%r14d
jle    13ee <main+0x1ce>
xor    %r12d,%r12d
jmp    13b9 <main+0x199>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12d
cmp    %r14d,%r12d
je     13ee <main+0x1ce>
test   %ebp,%ebp
jle    13b0 <main+0x190>
xor    %ebx,%ebx
nop
xor    %eax,%eax
call   1140 <fork@plt>
test   %rax,%rax
je     141d <main+0x1fd>
add    $0xffffffff,%ebx
mov    %ebp,%eax
add    %ebx,%eax
jne    13c0 <main+0x1a0>
mov    %ebp,%ebx
test   %ebp,%ebp
jle    13b0 <main+0x190>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1130 <wait@plt>
add    $0xffffffff,%ebx
jne    13e0 <main+0x1c0>
jmp    13b0 <main+0x190>
xor    %eax,%eax
call   1070 <rdtsc@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <print_graph@plt>
lea    0xc5e(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%eax
cltd
idiv   %ebp
mov    %edx,%r8d
add    %ebx,%ebp
imul   %eax,%ebx
sub    %ebx,%eax
neg    %ebx
test   %edx,%edx
cmove  %eax,%r8d
cmp    $0x1,%ebp
cmovne %eax,%r8d
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1080 <transitive_closure@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xba1(%rip),%rdi
jmp    1473 <main+0x253>
lea    0xbb6(%rip),%rdi
jmp    1473 <main+0x253>
lea    0xbcc(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"Could not open file\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"/dev/null\00"
@IPC_CREAT = global i32 0
@.str.3 = [31 x i8] c"Could not create shared memory\00"
@.str.4 = [31 x i8] c"Could not attach shared memory\00"
@.str.5 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca float
%30 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %34, i32** %6
%35 = load i32*, i32** %6
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %41
37: ; preds = %2
%38 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %2
store i8* null, i8** %7
store i64 0, i64* %8
%42 = load i32*, i32** %6
%43 = call i32 @getline(i8** %7, i64* %8, i32* %42)
store i32 %43, i32* %9
%44 = load i8*, i8** %7
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %10
%46 = load i32*, i32** %6
%47 = call i32 @getline(i8** %7, i64* %8, i32* %46)
store i32 %47, i32* %9
%48 = load i8*, i8** %7
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %11
%50 = load i32, i32* %11
%51 = load i32, i32* %11
%52 = mul nsw i32 %50, %51
%53 = sext i32 %52 to i64
store i64 %53, i64* %12
%54 = call i32 @ftok(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 5)
store i32 %54, i32* %13
%55 = load i32, i32* %13
%56 = load i64, i64* %12
%57 = mul i64 %56, 4
%58 = load i32, i32* @IPC_CREAT
%59 = or i32 420, %58
%60 = call i32 @shmget(i32 %55, i64 %57, i32 %59)
store i32 %60, i32* %14
%61 = load i32, i32* %14
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %41
%64 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %41
%68 = load i32, i32* %14
%69 = call i64 @shmat(i32 %68, i32* null, i32 0)
%70 = inttoptr i64 %69 to i32*
store i32* %70, i32** %15
%71 = load i32*, i32** %15
%72 = ptrtoint i32* %71 to i64
%73 = icmp eq i64 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %67
%75 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %67
%79 = load i32*, i32** %15
%80 = load i64, i64* %12
%81 = mul i64 %80, 4
%82 = call i32 @bzero(i32* %79, i64 %81)
br label %83
83: ; preds = %87, %78
%84 = load i32*, i32** %6
%85 = call i32 @getline(i8** %7, i64* %8, i32* %84)
store i32 %85, i32* %9
%86 = icmp ne i32 %85, -1
br i1 %86, label %87, label %102
87: ; preds = %83
%88 = load i8*, i8** %7
%89 = call i32 @sscanf(i8* %88, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %16, i32* %17)
%90 = load i32, i32* %16
%91 = sub nsw i32 %90, 1
store i32 %91, i32* %16
%92 = load i32, i32* %17
%93 = sub nsw i32 %92, 1
store i32 %93, i32* %17
%94 = load i32*, i32** %15
%95 = load i32, i32* %17
%96 = load i32, i32* %11
%97 = mul nsw i32 %95, %96
%98 = load i32, i32* %16
%99 = add nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32, i32* %94, i64 %100
store i32 1, i32* %101
br label %83
102: ; preds = %83
%103 = load i32*, i32** %6
%104 = call i32 @fclose(i32* %103)
%105 = load i8*, i8** %7
%106 = call i32 @free(i8* %105)
%107 = call i32 (...) @rdtsc()
store i32 %107, i32* %18
store i32 0, i32* %19
br label %108
108: ; preds = %167, %102
%109 = load i32, i32* %19
%110 = load i32, i32* %11
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %170
112: ; preds = %108
%113 = load i32, i32* %11
%114 = load i32, i32* %10
%115 = sdiv i32 %113, %114
store i32 %115, i32* %21
%116 = load i32, i32* %11
%117 = load i32, i32* %10
%118 = srem i32 %116, %117
store i32 %118, i32* %22
store i32 0, i32* %20
br label %119
119: ; preds = %153, %112
%120 = load i32, i32* %20
%121 = load i32, i32* %10
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %156
123: ; preds = %119
%124 = load i32, i32* %20
%125 = load i32, i32* %21
%126 = mul nsw i32 %124, %125
store i32 %126, i32* %23
%127 = call i64 (...) @fork()
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %152
129: ; preds = %123
%130 = load i32, i32* %20
%131 = load i32, i32* %10
%132 = sub nsw i32 %131, 1
%133 = icmp eq i32 %130, %132
br i1 %133, label %134, label %139
134: ; preds = %129
%135 = load i32, i32* %22
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %139
137: ; preds = %134
%138 = load i32, i32* %22
store i32 %138, i32* %24
br label %143
139: ; preds = %134, %129
%140 = load i32, i32* %23
%141 = load i32, i32* %21
%142 = add nsw i32 %140, %141
store i32 %142, i32* %24
br label %143
143: ; preds = %139, %137
%144 = load i32*, i32** %15
%145 = load i32, i32* %19
%146 = load i32, i32* %11
%147 = load i32, i32* %23
%148 = load i32, i32* %24
%149 = call i32 @transitive_closure(i32* %144, i32 %145, i32 %146, i32 %147, i32 %148)
%150 = load i32, i32* @EXIT_SUCCESS
%151 = call i32 @exit(i32 %150)
unreachable
152: ; preds = %123
br label %153
153: ; preds = %152
%154 = load i32, i32* %20
%155 = add nsw i32 %154, 1
store i32 %155, i32* %20
br label %119
156: ; preds = %119
store i32 0, i32* %20
br label %157
157: ; preds = %163, %156
%158 = load i32, i32* %20
%159 = load i32, i32* %10
%160 = icmp slt i32 %158, %159
br i1 %160, label %161, label %166
161: ; preds = %157
%162 = call i32 @wait(i32 0)
br label %163
163: ; preds = %161
%164 = load i32, i32* %20
%165 = add nsw i32 %164, 1
store i32 %165, i32* %20
br label %157
166: ; preds = %157
br label %167
167: ; preds = %166
%168 = load i32, i32* %19
%169 = add nsw i32 %168, 1
store i32 %169, i32* %19
br label %108
170: ; preds = %108
%171 = call i32 (...) @rdtsc()
store i32 %171, i32* %25
%172 = load i32, i32* %18
%173 = and i32 %172, poison
store i32 %173, i32* %26
%174 = load i32, i32* %25
%175 = and i32 %174, poison
store i32 %175, i32* %27
%176 = load i32, i32* %27
%177 = load i32, i32* %26
%178 = sub i32 %176, %177
store i32 %178, i32* %28
%179 = load i32, i32* %28
%180 = sitofp i32 %179 to float
store float %180, float* %29
store float 0x40A8298840000000, float* %30
%181 = load float, float* %29
%182 = load float, float* %30
%183 = fdiv float %181, %182
store float %183, float* %29
%184 = load i32*, i32** %15
%185 = load i32, i32* %11
%186 = call i32 @print_graph(i32* %184, i32 %185)
%187 = load float, float* %29
%188 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), float %187)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"Could not open file\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"/dev/null\00"
@IPC_CREAT = global i32 0
@.str.3 = [31 x i8] c"Could not create shared memory\00"
@.str.4 = [31 x i8] c"Could not attach shared memory\00"
@.str.5 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%17 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%18 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%19 = load i8*, i8** %3
%20 = call i32 @atoi(i8* %19)
%21 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%22 = load i8*, i8** %3
%23 = call i32 @atoi(i8* %22)
%24 = mul nsw i32 %23, %23
%25 = zext i32 %24 to i64
%26 = call i32 @ftok(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 5)
%27 = shl nuw nsw i64 %25, 2
%28 = load i32, i32* @IPC_CREAT
%29 = or i32 %28, 420
%30 = call i32 @shmget(i32 %26, i64 %27, i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %15
%33 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %15
%37 = call i64 @shmat(i32 %30, i32* null, i32 0)
%38 = inttoptr i64 %37 to i32*
%39 = icmp eq i64 %37, -1
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %36
%45 = call i32 @bzero(i32* %38, i64 %27)
%46 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%47 = icmp eq i32 %46, -1
br i1 %47, label %64, label %48
48: ; preds = %44
%49 = bitcast i32* %5 to i8*
%50 = bitcast i32* %6 to i8*
br label %51
51: ; preds = %48, %51
%52 = load i8*, i8** %3
%53 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %5, i32* %6)
%54 = load i32, i32* %5
%55 = add nsw i32 %54, -1
%56 = load i32, i32* %6
%57 = add nsw i32 %56, -1
%58 = mul nsw i32 %57, %23
%59 = add nsw i32 %58, %55
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %38, i64 %60
store i32 1, i32* %61
%62 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %51
64: ; preds = %51, %44
%65 = call i32 @fclose(i32* %9)
%66 = load i8*, i8** %3
%67 = call i32 @free(i8* %66)
%68 = call i32 (...) @rdtsc()
%69 = icmp sgt i32 %23, 0
br i1 %69, label %70, label %103
70: ; preds = %64
%71 = icmp sgt i32 %20, 0
br label %72
72: ; preds = %70, %100
%73 = phi i32 [ 0, %70 ], [ %101, %100 ]
br i1 %71, label %75, label %100
74: ; preds = %92
br i1 %71, label %95, label %100
75: ; preds = %72, %92
%76 = phi i32 [ %93, %92 ], [ 0, %72 ]
%77 = call i64 (...) @fork()
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %92
79: ; preds = %75
%80 = sdiv i32 %23, %20
%81 = srem i32 %23, %20
%82 = mul nsw i32 %76, %80
%83 = add nsw i32 %20, -1
%84 = icmp eq i32 %76, %83
%85 = icmp ne i32 %81, 0
%86 = select i1 %84, i1 %85, i1 false
%87 = add nsw i32 %82, %80
%88 = select i1 %86, i32 %81, i32 %87
%89 = call i32 @transitive_closure(i32* %38, i32 %73, i32 %23, i32 %82, i32 %88)
%90 = load i32, i32* @EXIT_SUCCESS
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %75
%93 = add nuw nsw i32 %76, 1
%94 = icmp eq i32 %93, %20
br i1 %94, label %74, label %75
95: ; preds = %74, %95
%96 = phi i32 [ %98, %95 ], [ 0, %74 ]
%97 = call i32 @wait(i32 0)
%98 = add nuw nsw i32 %96, 1
%99 = icmp eq i32 %98, %20
br i1 %99, label %100, label %95
100: ; preds = %95, %72, %74
%101 = add nuw nsw i32 %73, 1
%102 = icmp eq i32 %101, %23
br i1 %102, label %103, label %72
103: ; preds = %100, %64
%104 = call i32 (...) @rdtsc()
%105 = call i32 @print_graph(i32* %38, i32 %23)
%106 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), float poison)
ret i32 0
}