#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 */
struct sched_param {
  int /*<<< orphan*/ sched_priority;
};
typedef int ssize_t;
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int O_CREAT;
int O_RDONLY;
int O_SYNC;
int O_TRUNC;
int O_WRONLY;
int RAND_MAX;
int SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWUSR;
scalar_t__ WIFEXITED(int);
int atoi(char *);
scalar_t__ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getpid();
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
char *malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int random();
int read(int, char *, int);
int /*<<< orphan*/ sched_get_priority_max(int);
int sched_getscheduler(int /*<<< orphan*/);
scalar_t__ sched_setscheduler(int /*<<< orphan*/, int, struct sched_param *);
int snprintf(char *, int, char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int wait(int *);
int write(int, char *, int);
int zeroDist(double, double);
int main(int argc, char *argv[]) {
  int rv;
  int inputFD;
  int outputFD;
  char inputFilename[80];
  char outputFilename[80];
  char outputFilenameBase[80];
  ssize_t transfersize = 0;
  ssize_t blocksize = 0;
  char *transferBuffer = NULL;
  ssize_t buffersize;
  ssize_t bytesRead = 0;
  ssize_t totalBytesRead = 0;
  int totalReads = 0;
  ssize_t bytesWritten = 0;
  ssize_t totalBytesWritten = 0;
  int totalWrites = 0;
  int inputFileResets = 0;
  long it = 1000000;
  double x, y;
  double inCircle = 0.0;
  double inSquare = 0.0;
  double pCircle = 0.0;
  double piCalc = 0.0;
  pid_t pid;
  int test;
  int pro;
  int policy;
  struct sched_param param;
  blocksize = 1024;
  transfersize = 1024 * 100;
  strncpy(inputFilename, "rwinput", 80);
  strncpy(outputFilenameBase, "rwoutput", 80);
  if (argc < 2) {
    exit(EXIT_FAILURE);
  } else {
    pro = atoi(argv[1]);
    if (pro < 1) {
      fprintf(stderr, "Need more processes\n");
      exit(EXIT_FAILURE);
    }
  }
  if (argc < 3) {
    policy = SCHED_OTHER;
  } else {
    if (!strcmp(argv[2], "SCHED_OTHER")) {
      policy = SCHED_OTHER;
    } else if (!strcmp(argv[2], "SCHED_FIFO")) {
      policy = SCHED_FIFO;
    } else if (!strcmp(argv[2], "SCHED_RR")) {
      policy = SCHED_RR;
    } else {
      fprintf(stderr, "Unhandeled scheduling policy\n");
      exit(EXIT_FAILURE);
    }
  }
  param.sched_priority = sched_get_priority_max(policy);
  fprintf(stdout, "Current Scheduling Policy: %d\n", sched_getscheduler(0));
  fprintf(stdout, "Setting Scheduling Policy to: %d\n", policy);
  if (sched_setscheduler(0, policy, &param)) {
    perror("Error setting scheduler policy");
    exit(EXIT_FAILURE);
  }
  fprintf(stdout, "New Scheduling Policy: %d\n", sched_getscheduler(0));
  fprintf(stdout, "Creating %d simultanious processes\n", pro);
  for (int i = 0; i < pro; i++) {
    if ((pid = fork()) == -1) {
      fprintf(stderr, "The child process %d could not be forked\n", i);
      exit(EXIT_FAILURE);
    } else if (pid == 0) {
      fprintf(stdout, "Process %d forked with PID %d\n", i, pid);
      if (blocksize > transfersize) {
        fprintf(stderr, "blocksize can not exceed transfersize\n");
        exit(EXIT_FAILURE);
      }
      if (transfersize % blocksize) {
        fprintf(stderr, "blocksize must be multiple of transfersize\n");
        exit(EXIT_FAILURE);
      }
      buffersize = blocksize;
      if (!(transferBuffer = malloc(buffersize * sizeof(*transferBuffer)))) {
        perror("Failed to allocate transfer buffer");
        exit(EXIT_FAILURE);
      }
      if ((inputFD = open(inputFilename, O_RDONLY | O_SYNC)) < 0) {
        perror("Failed to open input file");
        exit(EXIT_FAILURE);
      }
      rv = snprintf(outputFilename, 80, "%s-%d", outputFilenameBase, getpid());
      if (rv > 80) {
        fprintf(stderr,
                "Output filenmae length exceeds limit of %d characters.\n", 80);
        exit(EXIT_FAILURE);
      } else if (rv < 0) {
        perror("Failed to generate output filename");
        exit(EXIT_FAILURE);
      }
      if ((outputFD =
               open(outputFilename, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC,
                    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)) < 0) {
        perror("Failed to open output file");
        exit(EXIT_FAILURE);
      }
      fprintf(stdout, "Reading from %s and writing to %s\n", inputFilename,
              outputFilename);
      do {
        bytesRead = read(inputFD, transferBuffer, buffersize);
        if (bytesRead < 0) {
          perror("Error reading input file");
          exit(EXIT_FAILURE);
        } else {
          totalBytesRead += bytesRead;
          totalReads++;
        }
        if (bytesRead == blocksize) {
          bytesWritten = write(outputFD, transferBuffer, bytesRead);
          if (bytesWritten < 0) {
            perror("Error writing output file");
            exit(EXIT_FAILURE);
          } else {
            totalBytesWritten += bytesWritten;
            totalWrites++;
          }
        } else {
          if (lseek(inputFD, 0, SEEK_SET)) {
            perror("Error resetting to beginning of file");
            exit(EXIT_FAILURE);
          }
          inputFileResets++;
        }
      } while (totalBytesWritten < transfersize);
      fprintf(stdout, "Read:    %zd bytes in %d reads\n", totalBytesRead,
              totalReads);
      fprintf(stdout, "Written: %zd bytes in %d writes\n", totalBytesWritten,
              totalWrites);
      fprintf(stdout, "Read input file in %d pass%s\n", (inputFileResets + 1),
              (inputFileResets ? "es" : ""));
      fprintf(stdout, "Processed %zd bytes in blocks of %zd bytes\n",
              transfersize, blocksize);
      free(transferBuffer);
      if (close(outputFD)) {
        perror("Failed to close output file");
        exit(EXIT_FAILURE);
      }
      if (close(inputFD)) {
        perror("Failed to close input file");
        exit(EXIT_FAILURE);
      }
      for (int j = 0; j < it; j++) {
        x = (random() % ((RAND_MAX / 2) * 2)) - (RAND_MAX / 2);
        y = (random() % ((RAND_MAX / 2) * 2)) - (RAND_MAX / 2);
        if (zeroDist(x, y) < (RAND_MAX / 2)) {
          inCircle++;
        }
        inSquare++;
      }
      pCircle = inCircle / inSquare;
      piCalc = pCircle * 4.0;
      fprintf(stdout, "pi = %f\n", piCalc);
      exit(0);
    }
  }
  fprintf(stdout, "\nWaiting for all of the running processes to exit\n");
  int reap = 0;
  while ((pid = wait(&test)) > 0) {
    if (WIFEXITED(test)) {
      fprintf(stdout, "Child process %d has been reaped correctly.\n", pid);
      reap++;
    }
  }
  if (reap == pro) {
    fprintf(stdout, "%d child process forked, %d have been reaped.\n", pro,
            reap);
    exit(EXIT_SUCCESS);
  } else {
    fprintf(stderr, "Something went wrong.\n");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
movq   $0x0,-0x120(%rbp)
movl   $0x0,-0x128(%rbp)
movl   $0x0,-0x12c(%rbp)
movl   $0x0,-0x130(%rbp)
movl   $0x0,-0x134(%rbp)
movl   $0x0,-0x138(%rbp)
movl   $0x0,-0x13c(%rbp)
movl   $0x0,-0x140(%rbp)
movq   $0xf4240,-0x148(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x160(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x168(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x170(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x178(%rbp)
ff
movl   $0x400,-0x118(%rbp)
movl   $0x19000,-0x114(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xccc(%rip),%rsi
mov    $0x50,%edx
call   1050 <strncpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xcbc(%rip),%rsi
mov    $0x50,%edx
call   1050 <strncpy@plt>
cmpl   $0x2,-0x8(%rbp)
jge    137e <main+0x10e>
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x184(%rbp)
cmpl   $0x1,-0x184(%rbp)
jge    13c3 <main+0x153>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
jmp    13c8 <main+0x158>
cmpl   $0x3,-0x8(%rbp)
jge    13e6 <main+0x176>
mov    0x2bbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x188(%rbp)
jmp    14ad <main+0x23d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc41(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%eax
jne    1417 <main+0x1a7>
mov    0x2b8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x188(%rbp)
jmp    14a8 <main+0x238>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc1c(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%eax
jne    1448 <main+0x1d8>
mov    0x2b75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x188(%rbp)
jmp    14a3 <main+0x233>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xbf6(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%eax
jne    1479 <main+0x209>
mov    0x2ae4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x188(%rbp)
jmp    149e <main+0x22e>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
lea    0xbcd(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2ae1(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
jmp    14a3 <main+0x233>
jmp    14a8 <main+0x238>
jmp    14ad <main+0x23d>
mov    -0x188(%rbp),%edi
call   1170 <sched_get_priority_max@plt>
mov    %eax,-0x190(%rbp)
mov    0x2aa3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1a0(%rbp)
xor    %edi,%edi
call   1040 <sched_getscheduler@plt>
mov    -0x1a0(%rbp),%edi
mov    %eax,%edx
lea    0xb91(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2a77(%rip),%rax
mov    (%rax),%edi
mov    -0x188(%rbp),%edx
lea    0xb93(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x188(%rbp),%esi
xor    %edi,%edi
lea    -0x190(%rbp),%rdx
call   10a0 <sched_setscheduler@plt>
cmp    $0x0,%rax
je     153f <main+0x2cf>
lea    0xb89(%rip),%rdi
call   1130 <perror@plt>
mov    0x2a40(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    0x2a22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1a4(%rbp)
xor    %edi,%edi
call   1040 <sched_getscheduler@plt>
mov    -0x1a4(%rbp),%edi
mov    %eax,%edx
lea    0xb70(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x29f6(%rip),%rax
mov    (%rax),%edi
mov    -0x184(%rbp),%edx
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x0,-0x194(%rbp)
mov    -0x194(%rbp),%eax
cmp    -0x184(%rbp),%eax
jge    1c61 <main+0x9f1>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %eax,-0x17c(%rbp)
cmp    $0xffffffff,%eax
jne    15e5 <main+0x375>
mov    0x29df(%rip),%rax
mov    (%rax),%edi
mov    -0x194(%rbp),%edx
lea    0xb43(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x299a(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
cmpl   $0x0,-0x17c(%rbp)
jne    1c43 <main+0x9d3>
mov    0x296f(%rip),%rax
mov    (%rax),%edi
mov    -0x194(%rbp),%edx
mov    -0x17c(%rbp),%ecx
lea    0xb2f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jle    164c <main+0x3dc>
mov    0x2972(%rip),%rax
mov    (%rax),%edi
lea    0xb25(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2933(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x114(%rbp),%eax
cltd
idivl  -0x118(%rbp)
cmp    $0x0,%edx
je     1687 <main+0x417>
mov    0x2937(%rip),%rax
mov    (%rax),%edi
lea    0xb11(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x28f8(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x118(%rbp),%eax
mov    %eax,-0x124(%rbp)
movslq -0x124(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1110 <malloc@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    16d0 <main+0x460>
lea    0xaf2(%rip),%rdi
call   1130 <perror@plt>
mov    0x28af(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
lea    -0x70(%rbp),%rdi
mov    0x28f5(%rip),%rax
mov    (%rax),%esi
mov    0x28f4(%rip),%rax
or     (%rax),%esi
mov    $0x0,%al
call   1120 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1713 <main+0x4a3>
lea    0xad2(%rip),%rdi
call   1130 <perror@plt>
mov    0x286c(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
lea    -0xc0(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x1b8(%rbp),%rdi
mov    -0x1b0(%rbp),%rcx
mov    %eax,%r8d
mov    $0x50,%esi
lea    0xa99(%rip),%rdx
call   1080 <snprintf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jle    178f <main+0x51f>
mov    0x2834(%rip),%rax
mov    (%rax),%edi
lea    0xa7d(%rip),%rsi
mov    $0x50,%edx
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x27f0(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jge    17b3 <main+0x543>
lea    0xa8a(%rip),%rdi
call   1130 <perror@plt>
mov    0x27cc(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
jmp    17b8 <main+0x548>
lea    -0xc0(%rbp),%rdi
mov    0x2782(%rip),%rax
mov    (%rax),%esi
mov    0x2829(%rip),%rax
or     (%rax),%esi
mov    0x2818(%rip),%rax
or     (%rax),%esi
mov    0x27f7(%rip),%rax
or     (%rax),%esi
mov    0x2786(%rip),%rax
mov    (%rax),%edx
mov    0x27cd(%rip),%rax
or     (%rax),%edx
mov    0x278c(%rip),%rax
or     (%rax),%edx
mov    0x27c3(%rip),%rax
or     (%rax),%edx
mov    0x2772(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1120 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    183d <main+0x5cd>
lea    0xa23(%rip),%rdi
call   1130 <perror@plt>
mov    0x2742(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    0x2724(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    0xa10(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x18(%rbp),%edi
mov    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   10c0 <read@plt>
mov    %eax,-0x128(%rbp)
cmpl   $0x0,-0x128(%rbp)
jge    18a1 <main+0x631>
lea    0x9fd(%rip),%rdi
call   1130 <perror@plt>
mov    0x26de(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x128(%rbp),%eax
add    -0x12c(%rbp),%eax
mov    %eax,-0x12c(%rbp)
mov    -0x130(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x130(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x118(%rbp),%eax
jne    193c <main+0x6cc>
mov    -0x1c(%rbp),%edi
mov    -0x120(%rbp),%rsi
mov    -0x128(%rbp),%edx
call   1060 <write@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jge    1916 <main+0x6a6>
lea    0x9a1(%rip),%rdi
call   1130 <perror@plt>
mov    0x2669(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x134(%rbp),%eax
add    -0x138(%rbp),%eax
mov    %eax,-0x138(%rbp)
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    1982 <main+0x712>
mov    -0x18(%rbp),%edi
mov    0x264a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0x0,%rax
je     1973 <main+0x703>
lea    0x95e(%rip),%rdi
call   1130 <perror@plt>
mov    0x260c(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x140(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x140(%rbp)
jmp    1987 <main+0x717>
mov    -0x138(%rbp),%eax
cmp    -0x114(%rbp),%eax
jl     185f <main+0x5ef>
mov    0x25c8(%rip),%rax
mov    (%rax),%edi
mov    -0x12c(%rbp),%edx
mov    -0x130(%rbp),%ecx
lea    0x92e(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x25a5(%rip),%rax
mov    (%rax),%edi
mov    -0x138(%rbp),%edx
mov    -0x13c(%rbp),%ecx
lea    0x92b(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2582(%rip),%rax
mov    (%rax),%edi
mov    -0x140(%rbp),%edx
add    $0x1,%edx
mov    -0x140(%rbp),%esi
lea    0xa41(%rip),%rcx
lea    0x93d(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0x911(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2547(%rip),%rax
mov    (%rax),%edi
mov    -0x114(%rbp),%edx
mov    -0x118(%rbp),%ecx
lea    0x90f(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x120(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   10b0 <close@plt>
cmp    $0x0,%rax
je     1a75 <main+0x805>
lea    0x90f(%rip),%rdi
call   1130 <perror@plt>
mov    0x250a(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    -0x18(%rbp),%edi
call   10b0 <close@plt>
cmp    $0x0,%rax
je     1aa1 <main+0x831>
lea    0x8ff(%rip),%rdi
call   1130 <perror@plt>
mov    0x24de(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
movl   $0x0,-0x198(%rbp)
movslq -0x198(%rbp),%rax
cmp    -0x148(%rbp),%rax
jge    1bed <main+0x97d>
mov    $0x0,%al
call   1100 <random@plt>
mov    %eax,-0x1cc(%rbp)
mov    0x24e5(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1cc(%rbp),%eax
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c8(%rbp)
mov    0x24c0(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x1c8(%rbp),%edx
sub    %eax,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x150(%rbp)
ff
mov    $0x0,%al
call   1100 <random@plt>
mov    %eax,-0x1c4(%rbp)
mov    0x248e(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c4(%rbp),%eax
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c0(%rbp)
mov    0x2469(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x1c0(%rbp),%edx
sub    %eax,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x158(%rbp)
ff
movsd  -0x150(%rbp),%xmm0
ff
movsd  -0x158(%rbp),%xmm1
ff
call   10f0 <zeroDist@plt>
mov    %eax,-0x1bc(%rbp)
mov    0x2429(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1bc(%rbp),%eax
cmp    %ecx,%eax
jge    1bc1 <main+0x951>
movsd  0x457(%rip),%xmm0
addsd  -0x160(%rbp),%xmm0
ff
movsd  %xmm0,-0x160(%rbp)
ff
movsd  0x43f(%rip),%xmm0
addsd  -0x168(%rbp),%xmm0
ff
movsd  %xmm0,-0x168(%rbp)
ff
mov    -0x198(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x198(%rbp)
jmp    1aab <main+0x83b>
movsd  -0x160(%rbp),%xmm0
ff
divsd  -0x168(%rbp),%xmm0
ff
movsd  %xmm0,-0x170(%rbp)
ff
movsd  0x3f3(%rip),%xmm0
mulsd  -0x170(%rbp),%xmm0
ff
movsd  %xmm0,-0x178(%rbp)
ff
mov    0x2344(%rip),%rax
mov    (%rax),%edi
movsd  -0x178(%rbp),%xmm0
ff
lea    0x773(%rip),%rsi
mov    $0x1,%al
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1160 <exit@plt>
jmp    1c48 <main+0x9d8>
jmp    1c4d <main+0x9dd>
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    1592 <main+0x322>
mov    0x2300(%rip),%rax
mov    (%rax),%edi
lea    0x740(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x0,-0x19c(%rbp)
lea    -0x180(%rbp),%rdi
call   1180 <wait@plt>
mov    %eax,-0x17c(%rbp)
cmp    $0x0,%eax
jle    1ce3 <main+0xa73>
mov    -0x180(%rbp),%edi
call   1150 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1cde <main+0xa6e>
mov    0x22af(%rip),%rax
mov    (%rax),%edi
mov    -0x17c(%rbp),%edx
lea    0x71c(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    -0x19c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    1c82 <main+0xa12>
mov    -0x19c(%rbp),%eax
cmp    -0x184(%rbp),%eax
jne    1d26 <main+0xab6>
mov    0x226c(%rip),%rax
mov    (%rax),%edi
mov    -0x184(%rbp),%edx
mov    -0x19c(%rbp),%ecx
lea    0x700(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2241(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    0x2273(%rip),%rax
mov    (%rax),%edi
lea    0x70a(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
mov    0x2234(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xd83(%rip),%rsi
lea    0x80(%rsp),%rdi
mov    $0x50,%edx
call   1050 <strncpy@plt>
lea    0xd72(%rip),%rsi
lea    0xd0(%rsp),%rdi
mov    $0x50,%edx
call   1050 <strncpy@plt>
cmp    $0x1,%ebp
jle    14d4 <main+0x264>
mov    0x8(%r14),%rdi
call   1140 <atoi@plt>
test   %eax,%eax
jg     12ea <main+0x7a>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xd43(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
jmp    14d4 <main+0x264>
mov    %eax,%r13d
mov    0x2ca4(%rip),%rbx
cmp    $0x3,%ebp
jb     134a <main+0xda>
mov    0x10(%r14),%rbp
lea    0xd32(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcmp@plt>
test   %eax,%eax
je     134a <main+0xda>
lea    0xd2b(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcmp@plt>
test   %eax,%eax
jne    132c <main+0xbc>
mov    0x2c86(%rip),%rbx
jmp    134a <main+0xda>
lea    0xd1a(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcmp@plt>
test   %eax,%eax
jne    1559 <main+0x2e9>
mov    0x2c06(%rip),%rbx
mov    (%rbx),%ebp
mov    %ebp,%edi
call   1170 <sched_get_priority_max@plt>
mov    %eax,0x28(%rsp)
mov    0x2c0a(%rip),%r12
mov    (%r12),%r14d
xor    %edi,%edi
call   1040 <sched_getscheduler@plt>
lea    0xd04(%rip),%rsi
mov    %r14d,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    (%r12),%edi
lea    0xd0c(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
lea    0x28(%rsp),%rdx
xor    %edi,%edi
mov    %ebp,%esi
call   10a0 <sched_setscheduler@plt>
test   %rax,%rax
jne    1475 <main+0x205>
mov    (%r12),%ebp
xor    %edi,%edi
call   1040 <sched_getscheduler@plt>
lea    0xd1b(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    (%r12),%edi
lea    0xd20(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1190 <fork@plt>
test   %eax,%eax
je     1483 <main+0x213>
cmp    $0xffffffff,%eax
je     14bb <main+0x24b>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    13e0 <main+0x170>
mov    (%r12),%edi
lea    0xf53(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   10e0 <fprintf@plt>
lea    0x30(%rsp),%rdi
call   1180 <wait@plt>
test   %eax,%eax
jle    14e2 <main+0x272>
mov    %eax,%ebp
lea    0x30(%rsp),%r15
lea    0xf5d(%rip),%r14
xor    %ebx,%ebx
jmp    1452 <main+0x1e2>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1180 <wait@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    14e2 <main+0x272>
mov    0x30(%rsp),%edi
call   1150 <WIFEXITED@plt>
test   %rax,%rax
je     1440 <main+0x1d0>
mov    (%r12),%edi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
add    $0x1,%ebx
jmp    1440 <main+0x1d0>
lea    0xc39(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    (%r12),%edi
lea    0xcaf(%rip),%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x400,%edi
call   1110 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
jne    150d <main+0x29d>
lea    0xca8(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    0x2ade(%rip),%rax
mov    (%rax),%edi
lea    0xc48(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
cmp    %r13d,%ebx
jne    1544 <main+0x2d4>
mov    (%r12),%edi
lea    0xecc(%rip),%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x2a5a(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
mov    0x2abc(%rip),%rax
mov    0x2abd(%rip),%rbx
mov    (%rbx),%esi
or     (%rax),%esi
lea    0x80(%rsp),%rdi
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,0x10(%rsp)
test   %eax,%eax
jns    156e <main+0x2fe>
lea    0xc42(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    0x2a55(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
jmp    12de <main+0x6e>
mov    0x2a40(%rip),%rax
mov    (%rax),%edi
lea    0xaed(%rip),%rsi
jmp    12de <main+0x6e>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xc1d(%rip),%rdx
lea    0x30(%rsp),%rdi
lea    0xd0(%rsp),%rcx
mov    $0x50,%esi
mov    %eax,%r8d
call   1080 <snprintf@plt>
cmp    $0x51,%eax
jl     15b5 <main+0x345>
mov    0x29fe(%rip),%rax
mov    (%rax),%edi
lea    0xbf4(%rip),%rsi
mov    $0x50,%edx
jmp    14cd <main+0x25d>
test   %eax,%eax
jns    15ca <main+0x35a>
lea    0xc17(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    0x2977(%rip),%rax
mov    0x2a20(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2a0d(%rip),%rax
or     (%rax),%esi
or     (%rbx),%esi
mov    0x2982(%rip),%rax
mov    0x29cb(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2988(%rip),%rax
or     (%rax),%edx
mov    0x29bf(%rip),%rax
or     (%rax),%edx
mov    0x296e(%rip),%rax
or     (%rax),%edx
xor    %ebx,%ebx
lea    0x30(%rsp),%rdi
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,0x24(%rsp)
test   %eax,%eax
jns    163b <main+0x3cb>
lea    0xbc9(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    (%r12),%edi
lea    0xbcf(%rip),%rsi
lea    0x80(%rsp),%rdx
lea    0x30(%rsp),%rcx
xor    %eax,%eax
call   10e0 <fprintf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    16a9 <main+0x439>
nopl   0x0(%rax,%rax,1)
mov    0x2919(%rip),%rax
mov    (%rax),%edx
mov    0x10(%rsp),%edi
xor    %esi,%esi
call   1090 <lseek@plt>
test   %rax,%rax
jne    1871 <main+0x601>
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
add    %r15d,%ebx
add    $0x1,%r14d
cmp    $0x19000,%ebp
jge    16fe <main+0x48e>
mov    0x10(%rsp),%edi
mov    0x18(%rsp),%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     16ed <main+0x47d>
mov    %eax,%r15d
cmp    $0x400,%eax
jne    1670 <main+0x400>
mov    0x24(%rsp),%edi
mov    0x18(%rsp),%rsi
mov    $0x400,%edx
call   1060 <write@plt>
test   %eax,%eax
js     1882 <main+0x612>
add    %eax,%ebp
add    $0x1,%r13d
jmp    169a <main+0x42a>
lea    0xb44(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
mov    (%r12),%edi
lea    0xb87(%rip),%rsi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    (%r12),%edi
lea    0xb90(%rip),%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    (%r12),%edi
mov    0x8(%rsp),%rax
lea    0x1(%rax),%edx
test   %eax,%eax
lea    0xcab(%rip),%rax
lea    0xba7(%rip),%rcx
cmove  %rax,%rcx
lea    0xb7e(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    (%r12),%edi
lea    0xb8d(%rip),%rsi
mov    $0x19000,%edx
mov    $0x400,%ecx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x24(%rsp),%edi
call   10b0 <close@plt>
test   %rax,%rax
jne    1893 <main+0x623>
mov    0x10(%rsp),%edi
call   10b0 <close@plt>
test   %rax,%rax
jne    18a4 <main+0x634>
xorpd  %xmm1,%xmm1
mov    $0xf4240,%ebx
mov    0x2804(%rip),%rbp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    17db <main+0x56b>
movsd  0x10(%rsp),%xmm1
movsd  0x832(%rip),%xmm2
addsd  %xmm2,%xmm1
add    $0xffffffff,%ebx
je     18b5 <main+0x645>
movsd  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1100 <random@plt>
mov    0x0(%rbp),%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
mov    %esi,%ecx
sar    %ecx
and    $0xfffffffe,%esi
cltd
idiv   %esi
sub    %ecx,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1100 <random@plt>
mov    0x0(%rbp),%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
mov    %esi,%ecx
sar    %ecx
and    $0xfffffffe,%esi
cltd
idiv   %esi
sub    %ecx,%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
movsd  0x18(%rsp),%xmm0
call   10f0 <zeroDist@plt>
mov    0x0(%rbp),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
cmp    %edx,%eax
jge    17c0 <main+0x550>
movsd  0x8(%rsp),%xmm0
movsd  0x7a4(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
jmp    17ce <main+0x55e>
lea    0x9f3(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
lea    0x9c8(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
lea    0xa84(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
lea    0xa8f(%rip),%rdi
call   1130 <perror@plt>
jmp    14d4 <main+0x264>
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
mulsd  0x741(%rip),%xmm0
mov    (%r12),%edi
lea    0xa83(%rip),%rsi
mov    $0x1,%al
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [8 x i8] c"rwinput\00"
@.str.1 = [9 x i8] c"rwoutput\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [21 x i8] c"Need more processes\0A\00"
@SCHED_OTHER = global i32 0
@.str.3 = [12 x i8] c"SCHED_OTHER\00"
@.str.4 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_FIFO = global i32 0
@.str.5 = [9 x i8] c"SCHED_RR\00"
@SCHED_RR = global i32 0
@.str.6 = [30 x i8] c"Unhandeled scheduling policy\0A\00"
@stdout = global i32 0
@.str.7 = [31 x i8] c"Current Scheduling Policy: %d\0A\00"
@.str.8 = [34 x i8] c"Setting Scheduling Policy to: %d\0A\00"
@.str.9 = [31 x i8] c"Error setting scheduler policy\00"
@.str.10 = [27 x i8] c"New Scheduling Policy: %d\0A\00"
@.str.11 = [36 x i8] c"Creating %d simultanious processes\0A\00"
@.str.12 = [42 x i8] c"The child process %d could not be forked\0A\00"
@.str.13 = [31 x i8] c"Process %d forked with PID %d\0A\00"
@.str.14 = [39 x i8] c"blocksize can not exceed transfersize\0A\00"
@.str.15 = [44 x i8] c"blocksize must be multiple of transfersize\0A\00"
@.str.16 = [35 x i8] c"Failed to allocate transfer buffer\00"
@O_RDONLY = global i32 0
@O_SYNC = global i32 0
@.str.17 = [26 x i8] c"Failed to open input file\00"
@.str.18 = [6 x i8] c"%s-%d\00"
@.str.19 = [56 x i8] c"Output filenmae length exceeds limit of %d characters.\0A\00"
@.str.20 = [35 x i8] c"Failed to generate output filename\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@.str.21 = [27 x i8] c"Failed to open output file\00"
@.str.22 = [35 x i8] c"Reading from %s and writing to %s\0A\00"
@.str.23 = [25 x i8] c"Error reading input file\00"
@.str.24 = [26 x i8] c"Error writing output file\00"
@SEEK_SET = global i32 0
@.str.25 = [37 x i8] c"Error resetting to beginning of file\00"
@.str.26 = [32 x i8] c"Read: %zd bytes in %d reads\0A\00"
@.str.27 = [33 x i8] c"Written: %zd bytes in %d writes\0A\00"
@.str.28 = [30 x i8] c"Read input file in %d pass%s\0A\00"
@.str.29 = [3 x i8] c"es\00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [44 x i8] c"Processed %zd bytes in blocks of %zd bytes\0A\00"
@.str.32 = [28 x i8] c"Failed to close output file\00"
@.str.33 = [27 x i8] c"Failed to close input file\00"
@RAND_MAX = global i32 0
@.str.34 = [9 x i8] c"pi = %f\0A\00"
@.str.35 = [51 x i8] c"\0AWaiting for all of the running processes to exit\0A\00"
@.str.36 = [45 x i8] c"Child process %d has been reaped correctly.\0A\00"
@.str.37 = [47 x i8] c"%d child process forked, %d have been reaped.\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.38 = [23 x i8] c"Something went wrong.\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 [80 x i8]
%10 = alloca [80 x i8]
%11 = alloca [80 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%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 i64
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca %struct.sched_param
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i32 0, i32* %13
store i8* null, i8** %14
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i64 1000000, i64* %23
store double 0.000000e+00, double* %26
store double 0.000000e+00, double* %27
store double 0.000000e+00, double* %28
store double 0.000000e+00, double* %29
store i32 1024, i32* %13
store i32 102400, i32* %12
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%39 = call i32 @strncpy(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 80)
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%41 = call i32 @strncpy(i8* %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 80)
%42 = load i32, i32* %4
%43 = icmp slt i32 %42, 2
br i1 %43, label %44, label %47
44: ; preds = %2
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %2
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %32
%52 = load i32, i32* %32
%53 = icmp slt i32 %52, 1
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %47
br label %60
60: ; preds = %59
%61 = load i32, i32* %4
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = load i32, i32* @SCHED_OTHER
store i32 %64, i32* %33
br label %97
65: ; preds = %60
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 2
%68 = load i8*, i8** %67
%69 = call i32 @strcmp(i8* %68, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%70 = icmp ne i32 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %65
%72 = load i32, i32* @SCHED_OTHER
store i32 %72, i32* %33
br label %96
73: ; preds = %65
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 2
%76 = load i8*, i8** %75
%77 = call i32 @strcmp(i8* %76, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %81, label %79
79: ; preds = %73
%80 = load i32, i32* @SCHED_FIFO
store i32 %80, i32* %33
br label %95
81: ; preds = %73
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = call i32 @strcmp(i8* %84, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%86 = icmp ne i32 %85, 0
br i1 %86, label %89, label %87
87: ; preds = %81
%88 = load i32, i32* @SCHED_RR
store i32 %88, i32* %33
br label %94
89: ; preds = %81
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %87
br label %95
95: ; preds = %94, %79
br label %96
96: ; preds = %95, %71
br label %97
97: ; preds = %96, %63
%98 = load i32, i32* %33
%99 = call i32 @sched_get_priority_max(i32 %98)
%100 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %34, i32 0, i32 0
store i32 %99, i32* %100
%101 = load i32, i32* @stdout
%102 = call i32 @sched_getscheduler(i32 0)
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %102)
%104 = load i32, i32* @stdout
%105 = load i32, i32* %33
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %33
%108 = call i64 @sched_setscheduler(i32 0, i32 %107, %struct.sched_param* %34)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %97
%111 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %97
%115 = load i32, i32* @stdout
%116 = call i32 @sched_getscheduler(i32 0)
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %116)
%118 = load i32, i32* @stdout
%119 = load i32, i32* %32
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0), i32 %119)
store i32 0, i32* %35
br label %121
121: ; preds = %378, %114
%122 = load i32, i32* %35
%123 = load i32, i32* %32
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %381
125: ; preds = %121
%126 = call i32 (...) @fork()
store i32 %126, i32* %30
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %134
128: ; preds = %125
%129 = load i32, i32* @stderr
%130 = load i32, i32* %35
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 %130)
%132 = load i32, i32* @EXIT_FAILURE
%133 = call i32 @exit(i32 %132)
unreachable
134: ; preds = %125
%135 = load i32, i32* %30
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %376
137: ; preds = %134
%138 = load i32, i32* @stdout
%139 = load i32, i32* %35
%140 = load i32, i32* %30
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i32 %139, i32 %140)
%142 = load i32, i32* %13
%143 = load i32, i32* %12
%144 = icmp sgt i32 %142, %143
br i1 %144, label %145, label %150
145: ; preds = %137
%146 = load i32, i32* @stderr
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.14, i64 0, i64 0))
%148 = load i32, i32* @EXIT_FAILURE
%149 = call i32 @exit(i32 %148)
unreachable
150: ; preds = %137
%151 = load i32, i32* %12
%152 = load i32, i32* %13
%153 = srem i32 %151, %152
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %160
155: ; preds = %150
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %150
%161 = load i32, i32* %13
store i32 %161, i32* %15
%162 = load i32, i32* %15
%163 = sext i32 %162 to i64
%164 = mul i64 %163, 1
%165 = trunc i64 %164 to i32
%166 = call i8* @malloc(i32 %165)
store i8* %166, i8** %14
%167 = icmp ne i8* %166, null
br i1 %167, label %172, label %168
168: ; preds = %160
%169 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0))
%170 = load i32, i32* @EXIT_FAILURE
%171 = call i32 @exit(i32 %170)
unreachable
172: ; preds = %160
%173 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%174 = load i32, i32* @O_RDONLY
%175 = load i32, i32* @O_SYNC
%176 = or i32 %174, %175
%177 = call i32 (i8*, i32, ...) @open(i8* %173, i32 %176)
store i32 %177, i32* %7
%178 = icmp slt i32 %177, 0
br i1 %178, label %179, label %183
179: ; preds = %172
%180 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0))
%181 = load i32, i32* @EXIT_FAILURE
%182 = call i32 @exit(i32 %181)
unreachable
183: ; preds = %172
%184 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%185 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%186 = call i32 (...) @getpid()
%187 = call i32 @snprintf(i8* %184, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i8* %185, i32 %186)
store i32 %187, i32* %6
%188 = load i32, i32* %6
%189 = icmp sgt i32 %188, 80
br i1 %189, label %190, label %195
190: ; preds = %183
%191 = load i32, i32* @stderr
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %191, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.19, i64 0, i64 0), i32 80)
%193 = load i32, i32* @EXIT_FAILURE
%194 = call i32 @exit(i32 %193)
unreachable
195: ; preds = %183
%196 = load i32, i32* %6
%197 = icmp slt i32 %196, 0
br i1 %197, label %198, label %202
198: ; preds = %195
%199 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i64 0, i64 0))
%200 = load i32, i32* @EXIT_FAILURE
%201 = call i32 @exit(i32 %200)
unreachable
202: ; preds = %195
br label %203
203: ; preds = %202
%204 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%205 = load i32, i32* @O_WRONLY
%206 = load i32, i32* @O_CREAT
%207 = or i32 %205, %206
%208 = load i32, i32* @O_TRUNC
%209 = or i32 %207, %208
%210 = load i32, i32* @O_SYNC
%211 = or i32 %209, %210
%212 = load i32, i32* @S_IRUSR
%213 = load i32, i32* @S_IWUSR
%214 = or i32 %212, %213
%215 = load i32, i32* @S_IRGRP
%216 = or i32 %214, %215
%217 = load i32, i32* @S_IWGRP
%218 = or i32 %216, %217
%219 = load i32, i32* @S_IROTH
%220 = or i32 %218, %219
%221 = call i32 (i8*, i32, ...) @open(i8* %204, i32 %211, i32 %220)
store i32 %221, i32* %8
%222 = icmp slt i32 %221, 0
br i1 %222, label %223, label %227
223: ; preds = %203
%224 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%225 = load i32, i32* @EXIT_FAILURE
%226 = call i32 @exit(i32 %225)
unreachable
227: ; preds = %203
%228 = load i32, i32* @stdout
%229 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%230 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%231 = call i32 (i32, i8*, ...) @fprintf(i32 %228, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.22, i64 0, i64 0), i8* %229, i8* %230)
br label %232
232: ; preds = %284, %227
%233 = load i32, i32* %7
%234 = load i8*, i8** %14
%235 = load i32, i32* %15
%236 = call i32 @read(i32 %233, i8* %234, i32 %235)
store i32 %236, i32* %16
%237 = load i32, i32* %16
%238 = icmp slt i32 %237, 0
br i1 %238, label %239, label %243
239: ; preds = %232
%240 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.23, i64 0, i64 0))
%241 = load i32, i32* @EXIT_FAILURE
%242 = call i32 @exit(i32 %241)
unreachable
243: ; preds = %232
%244 = load i32, i32* %16
%245 = load i32, i32* %17
%246 = add nsw i32 %245, %244
store i32 %246, i32* %17
%247 = load i32, i32* %18
%248 = add nsw i32 %247, 1
store i32 %248, i32* %18
br label %249
249: ; preds = %243
%250 = load i32, i32* %16
%251 = load i32, i32* %13
%252 = icmp eq i32 %250, %251
br i1 %252, label %253, label %271
253: ; preds = %249
%254 = load i32, i32* %8
%255 = load i8*, i8** %14
%256 = load i32, i32* %16
%257 = call i32 @write(i32 %254, i8* %255, i32 %256)
store i32 %257, i32* %19
%258 = load i32, i32* %19
%259 = icmp slt i32 %258, 0
br i1 %259, label %260, label %264
260: ; preds = %253
%261 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.24, i64 0, i64 0))
%262 = load i32, i32* @EXIT_FAILURE
%263 = call i32 @exit(i32 %262)
unreachable
264: ; preds = %253
%265 = load i32, i32* %19
%266 = load i32, i32* %20
%267 = add nsw i32 %266, %265
store i32 %267, i32* %20
%268 = load i32, i32* %21
%269 = add nsw i32 %268, 1
store i32 %269, i32* %21
br label %270
270: ; preds = %264
br label %283
271: ; preds = %249
%272 = load i32, i32* %7
%273 = load i32, i32* @SEEK_SET
%274 = call i64 @lseek(i32 %272, i32 0, i32 %273)
%275 = icmp ne i64 %274, 0
br i1 %275, label %276, label %280
276: ; preds = %271
%277 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.25, i64 0, i64 0))
%278 = load i32, i32* @EXIT_FAILURE
%279 = call i32 @exit(i32 %278)
unreachable
280: ; preds = %271
%281 = load i32, i32* %22
%282 = add nsw i32 %281, 1
store i32 %282, i32* %22
br label %283
283: ; preds = %280, %270
br label %284
284: ; preds = %283
%285 = load i32, i32* %20
%286 = load i32, i32* %12
%287 = icmp slt i32 %285, %286
br i1 %287, label %232, label %288
288: ; preds = %284
%289 = load i32, i32* @stdout
%290 = load i32, i32* %17
%291 = load i32, i32* %18
%292 = call i32 (i32, i8*, ...) @fprintf(i32 %289, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i32 %290, i32 %291)
%293 = load i32, i32* @stdout
%294 = load i32, i32* %20
%295 = load i32, i32* %21
%296 = call i32 (i32, i8*, ...) @fprintf(i32 %293, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.27, i64 0, i64 0), i32 %294, i32 %295)
%297 = load i32, i32* @stdout
%298 = load i32, i32* %22
%299 = add nsw i32 %298, 1
%300 = load i32, i32* %22
%301 = icmp ne i32 %300, 0
%302 = zext i1 %301 to i64
%303 = select i1 %301, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0)
%304 = call i32 (i32, i8*, ...) @fprintf(i32 %297, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.28, i64 0, i64 0), i32 %299, i8* %303)
%305 = load i32, i32* @stdout
%306 = load i32, i32* %12
%307 = load i32, i32* %13
%308 = call i32 (i32, i8*, ...) @fprintf(i32 %305, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.31, i64 0, i64 0), i32 %306, i32 %307)
%309 = load i8*, i8** %14
%310 = call i32 @free(i8* %309)
%311 = load i32, i32* %8
%312 = call i64 @close(i32 %311)
%313 = icmp ne i64 %312, 0
br i1 %313, label %314, label %318
314: ; preds = %288
%315 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.32, i64 0, i64 0))
%316 = load i32, i32* @EXIT_FAILURE
%317 = call i32 @exit(i32 %316)
unreachable
318: ; preds = %288
%319 = load i32, i32* %7
%320 = call i64 @close(i32 %319)
%321 = icmp ne i64 %320, 0
br i1 %321, label %322, label %326
322: ; preds = %318
%323 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.33, i64 0, i64 0))
%324 = load i32, i32* @EXIT_FAILURE
%325 = call i32 @exit(i32 %324)
unreachable
326: ; preds = %318
store i32 0, i32* %36
br label %327
327: ; preds = %363, %326
%328 = load i32, i32* %36
%329 = sext i32 %328 to i64
%330 = load i64, i64* %23
%331 = icmp slt i64 %329, %330
br i1 %331, label %332, label %366
332: ; preds = %327
%333 = call i32 (...) @random()
%334 = load i32, i32* @RAND_MAX
%335 = sdiv i32 %334, 2
%336 = mul nsw i32 %335, 2
%337 = srem i32 %333, %336
%338 = load i32, i32* @RAND_MAX
%339 = sdiv i32 %338, 2
%340 = sub nsw i32 %337, %339
%341 = sitofp i32 %340 to double
store double %341, double* %24
%342 = call i32 (...) @random()
%343 = load i32, i32* @RAND_MAX
%344 = sdiv i32 %343, 2
%345 = mul nsw i32 %344, 2
%346 = srem i32 %342, %345
%347 = load i32, i32* @RAND_MAX
%348 = sdiv i32 %347, 2
%349 = sub nsw i32 %346, %348
%350 = sitofp i32 %349 to double
store double %350, double* %25
%351 = load double, double* %24
%352 = load double, double* %25
%353 = call i32 @zeroDist(double %351, double %352)
%354 = load i32, i32* @RAND_MAX
%355 = sdiv i32 %354, 2
%356 = icmp slt i32 %353, %355
br i1 %356, label %357, label %360
357: ; preds = %332
%358 = load double, double* %26
%359 = fadd double %358, 1.000000e+00
store double %359, double* %26
br label %360
360: ; preds = %357, %332
%361 = load double, double* %27
%362 = fadd double %361, 1.000000e+00
store double %362, double* %27
br label %363
363: ; preds = %360
%364 = load i32, i32* %36
%365 = add nsw i32 %364, 1
store i32 %365, i32* %36
br label %327
366: ; preds = %327
%367 = load double, double* %26
%368 = load double, double* %27
%369 = fdiv double %367, %368
store double %369, double* %28
%370 = load double, double* %28
%371 = fmul double %370, 4.000000e+00
store double %371, double* %29
%372 = load i32, i32* @stdout
%373 = load double, double* %29
%374 = call i32 (i32, i8*, ...) @fprintf(i32 %372, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.34, i64 0, i64 0), double %373)
%375 = call i32 @exit(i32 0)
unreachable
376: ; preds = %134
br label %377
377: ; preds = %376
br label %378
378: ; preds = %377
%379 = load i32, i32* %35
%380 = add nsw i32 %379, 1
store i32 %380, i32* %35
br label %121
381: ; preds = %121
%382 = load i32, i32* @stdout
%383 = call i32 (i32, i8*, ...) @fprintf(i32 %382, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.35, i64 0, i64 0))
store i32 0, i32* %37
br label %384
384: ; preds = %397, %381
%385 = call i32 @wait(i32* %31)
store i32 %385, i32* %30
%386 = icmp sgt i32 %385, 0
br i1 %386, label %387, label %398
387: ; preds = %384
%388 = load i32, i32* %31
%389 = call i64 @WIFEXITED(i32 %388)
%390 = icmp ne i64 %389, 0
br i1 %390, label %391, label %397
391: ; preds = %387
%392 = load i32, i32* @stdout
%393 = load i32, i32* %30
%394 = call i32 (i32, i8*, ...) @fprintf(i32 %392, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.36, i64 0, i64 0), i32 %393)
%395 = load i32, i32* %37
%396 = add nsw i32 %395, 1
store i32 %396, i32* %37
br label %397
397: ; preds = %391, %387
br label %384
398: ; preds = %384
%399 = load i32, i32* %37
%400 = load i32, i32* %32
%401 = icmp eq i32 %399, %400
br i1 %401, label %402, label %409
402: ; preds = %398
%403 = load i32, i32* @stdout
%404 = load i32, i32* %32
%405 = load i32, i32* %37
%406 = call i32 (i32, i8*, ...) @fprintf(i32 %403, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.37, i64 0, i64 0), i32 %404, i32 %405)
%407 = load i32, i32* @EXIT_SUCCESS
%408 = call i32 @exit(i32 %407)
unreachable
409: ; preds = %398
%410 = load i32, i32* @stderr
%411 = call i32 (i32, i8*, ...) @fprintf(i32 %410, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.38, i64 0, i64 0))
%412 = load i32, i32* @EXIT_FAILURE
%413 = call i32 @exit(i32 %412)
unreachable
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str = [8 x i8] c"rwinput\00"
@.str.1 = [9 x i8] c"rwoutput\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [21 x i8] c"Need more processes\0A\00"
@SCHED_OTHER = global i32 0
@.str.3 = [12 x i8] c"SCHED_OTHER\00"
@.str.4 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_FIFO = global i32 0
@.str.5 = [9 x i8] c"SCHED_RR\00"
@SCHED_RR = global i32 0
@.str.6 = [30 x i8] c"Unhandeled scheduling policy\0A\00"
@stdout = global i32 0
@.str.7 = [31 x i8] c"Current Scheduling Policy: %d\0A\00"
@.str.8 = [34 x i8] c"Setting Scheduling Policy to: %d\0A\00"
@.str.9 = [31 x i8] c"Error setting scheduler policy\00"
@.str.10 = [27 x i8] c"New Scheduling Policy: %d\0A\00"
@.str.11 = [36 x i8] c"Creating %d simultanious processes\0A\00"
@.str.12 = [42 x i8] c"The child process %d could not be forked\0A\00"
@.str.13 = [31 x i8] c"Process %d forked with PID %d\0A\00"
@.str.16 = [35 x i8] c"Failed to allocate transfer buffer\00"
@O_RDONLY = global i32 0
@O_SYNC = global i32 0
@.str.17 = [26 x i8] c"Failed to open input file\00"
@.str.18 = [6 x i8] c"%s-%d\00"
@.str.19 = [56 x i8] c"Output filenmae length exceeds limit of %d characters.\0A\00"
@.str.20 = [35 x i8] c"Failed to generate output filename\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@.str.21 = [27 x i8] c"Failed to open output file\00"
@.str.22 = [35 x i8] c"Reading from %s and writing to %s\0A\00"
@.str.23 = [25 x i8] c"Error reading input file\00"
@.str.24 = [26 x i8] c"Error writing output file\00"
@SEEK_SET = global i32 0
@.str.25 = [37 x i8] c"Error resetting to beginning of file\00"
@.str.26 = [32 x i8] c"Read: %zd bytes in %d reads\0A\00"
@.str.27 = [33 x i8] c"Written: %zd bytes in %d writes\0A\00"
@.str.28 = [30 x i8] c"Read input file in %d pass%s\0A\00"
@.str.29 = [3 x i8] c"es\00"
@.str.30 = [1 x i8] zeroinitializer
@.str.31 = [44 x i8] c"Processed %zd bytes in blocks of %zd bytes\0A\00"
@.str.32 = [28 x i8] c"Failed to close output file\00"
@.str.33 = [27 x i8] c"Failed to close input file\00"
@RAND_MAX = global i32 0
@.str.34 = [9 x i8] c"pi = %f\0A\00"
@.str.35 = [51 x i8] c"\0AWaiting for all of the running processes to exit\0A\00"
@.str.36 = [45 x i8] c"Child process %d has been reaped correctly.\0A\00"
@.str.37 = [47 x i8] c"%d child process forked, %d have been reaped.\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.38 = [23 x i8] c"Something went wrong.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca i32
%7 = alloca %struct.sched_param
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast %struct.sched_param* %7 to i8*
%13 = call i32 @strncpy(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 80)
%14 = call i32 @strncpy(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 80)
%15 = icmp slt i32 %0, 2
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = icmp slt i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = icmp ult i32 %0, 3
br i1 %30, label %47, label %31
31: ; preds = %29
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* dereferenceable(1) %33, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %47, label %36
36: ; preds = %31
%37 = call i32 @strcmp(i8* dereferenceable(1) %33, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %47, label %39
39: ; preds = %36
%40 = call i32 @strcmp(i8* dereferenceable(1) %33, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %39, %36, %31, %29
%48 = phi i32* [ @SCHED_OTHER, %29 ], [ @SCHED_OTHER, %31 ], [ @SCHED_FIFO, %36 ], [ @SCHED_RR, %39 ]
%49 = load i32, i32* %48
%50 = call i32 @sched_get_priority_max(i32 %49)
%51 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %7, i64 0, i32 0
store i32 %50, i32* %51
%52 = load i32, i32* @stdout
%53 = call i32 @sched_getscheduler(i32 0)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = load i32, i32* @stdout
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %49)
%57 = call i64 @sched_setscheduler(i32 0, i32 %49, %struct.sched_param* %7)
%58 = icmp eq i64 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %47
%60 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %47
%64 = load i32, i32* @stdout
%65 = call i32 @sched_getscheduler(i32 0)
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 %65)
%67 = load i32, i32* @stdout
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.11, i64 0, i64 0), i32 %22)
br label %74
69: ; preds = %242
%70 = load i32, i32* @stdout
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.35, i64 0, i64 0))
%72 = call i32 @wait(i32* %6)
%73 = icmp sgt i32 %72, 0
br i1 %73, label %245, label %259
74: ; preds = %63, %242
%75 = phi i32 [ %243, %242 ], [ 0, %63 ]
%76 = call i32 (...) @fork()
switch i32 %76, label %242 [
i32 -1, label %77
i32 0, label %82
]
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 %75)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %74
%83 = load i32, i32* @stdout
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i32 %75, i32 0)
%85 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %91
87: ; preds = %82
%88 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0))
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %82
%92 = load i32, i32* @O_RDONLY
%93 = load i32, i32* @O_SYNC
%94 = or i32 %93, %92
%95 = call i32 (i8*, i32, ...) @open(i8* %8, i32 %94)
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %101
97: ; preds = %91
%98 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0))
%99 = load i32, i32* @EXIT_FAILURE
%100 = call i32 @exit(i32 %99)
unreachable
101: ; preds = %91
%102 = call i32 (...) @getpid()
%103 = call i32 @snprintf(i8* %9, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i8* %10, i32 %102)
%104 = icmp sgt i32 %103, 80
br i1 %104, label %105, label %110
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.19, i64 0, i64 0), i32 80)
%108 = load i32, i32* @EXIT_FAILURE
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %101
%111 = icmp slt i32 %103, 0
br i1 %111, label %112, label %116
112: ; preds = %110
%113 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %110
%117 = load i32, i32* @O_WRONLY
%118 = load i32, i32* @O_CREAT
%119 = or i32 %118, %117
%120 = load i32, i32* @O_TRUNC
%121 = or i32 %119, %120
%122 = load i32, i32* @O_SYNC
%123 = or i32 %121, %122
%124 = load i32, i32* @S_IRUSR
%125 = load i32, i32* @S_IWUSR
%126 = or i32 %125, %124
%127 = load i32, i32* @S_IRGRP
%128 = or i32 %126, %127
%129 = load i32, i32* @S_IWGRP
%130 = or i32 %128, %129
%131 = load i32, i32* @S_IROTH
%132 = or i32 %130, %131
%133 = call i32 (i8*, i32, ...) @open(i8* %9, i32 %123, i32 %132)
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %139
135: ; preds = %116
%136 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%137 = load i32, i32* @EXIT_FAILURE
%138 = call i32 @exit(i32 %137)
unreachable
139: ; preds = %116
%140 = load i32, i32* @stdout
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.22, i64 0, i64 0), i8* %8, i8* %9)
br label %142
142: ; preds = %178, %139
%143 = phi i32 [ 0, %139 ], [ %155, %178 ]
%144 = phi i32 [ 0, %139 ], [ %156, %178 ]
%145 = phi i32 [ 0, %139 ], [ %179, %178 ]
%146 = phi i32 [ 0, %139 ], [ %180, %178 ]
%147 = phi i32 [ 0, %139 ], [ %181, %178 ]
%148 = call i32 @read(i32 %95, i8* %85, i32 1024)
%149 = icmp slt i32 %148, 0
br i1 %149, label %150, label %154
150: ; preds = %142
%151 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.23, i64 0, i64 0))
%152 = load i32, i32* @EXIT_FAILURE
%153 = call i32 @exit(i32 %152)
unreachable
154: ; preds = %142
%155 = add nsw i32 %148, %143
%156 = add nuw nsw i32 %144, 1
%157 = icmp eq i32 %148, 1024
br i1 %157, label %158, label %168
158: ; preds = %154
%159 = call i32 @write(i32 %133, i8* %85, i32 1024)
%160 = icmp slt i32 %159, 0
br i1 %160, label %161, label %165
161: ; preds = %158
%162 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.24, i64 0, i64 0))
%163 = load i32, i32* @EXIT_FAILURE
%164 = call i32 @exit(i32 %163)
unreachable
165: ; preds = %158
%166 = add nsw i32 %159, %145
%167 = add nsw i32 %146, 1
br label %178
168: ; preds = %154
%169 = load i32, i32* @SEEK_SET
%170 = call i64 @lseek(i32 %95, i32 0, i32 %169)
%171 = icmp eq i64 %170, 0
br i1 %171, label %176, label %172
172: ; preds = %168
%173 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.25, i64 0, i64 0))
%174 = load i32, i32* @EXIT_FAILURE
%175 = call i32 @exit(i32 %174)
unreachable
176: ; preds = %168
%177 = add nsw i32 %147, 1
br label %178
178: ; preds = %165, %176
%179 = phi i32 [ %166, %165 ], [ %145, %176 ]
%180 = phi i32 [ %167, %165 ], [ %146, %176 ]
%181 = phi i32 [ %147, %165 ], [ %177, %176 ]
%182 = icmp slt i32 %179, 102400
br i1 %182, label %142, label %183
183: ; preds = %178
%184 = load i32, i32* @stdout
%185 = call i32 (i32, i8*, ...) @fprintf(i32 %184, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0), i32 %155, i32 %156)
%186 = load i32, i32* @stdout
%187 = call i32 (i32, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.27, i64 0, i64 0), i32 %179, i32 %180)
%188 = load i32, i32* @stdout
%189 = add nsw i32 %181, 1
%190 = icmp eq i32 %181, 0
%191 = select i1 %190, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.30, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i64 0, i64 0)
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %188, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.28, i64 0, i64 0), i32 %189, i8* %191)
%193 = load i32, i32* @stdout
%194 = call i32 (i32, i8*, ...) @fprintf(i32 %193, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.31, i64 0, i64 0), i32 102400, i32 1024)
%195 = call i32 @free(i8* %85)
%196 = call i64 @close(i32 %133)
%197 = icmp eq i64 %196, 0
br i1 %197, label %202, label %198
198: ; preds = %183
%199 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.32, i64 0, i64 0))
%200 = load i32, i32* @EXIT_FAILURE
%201 = call i32 @exit(i32 %200)
unreachable
202: ; preds = %183
%203 = call i64 @close(i32 %95)
%204 = icmp eq i64 %203, 0
br i1 %204, label %215, label %205
205: ; preds = %202
%206 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.33, i64 0, i64 0))
%207 = load i32, i32* @EXIT_FAILURE
%208 = call i32 @exit(i32 %207)
unreachable
209: ; preds = %215
%210 = fdiv double %238, %239
%211 = fmul double %210, 4.000000e+00
%212 = load i32, i32* @stdout
%213 = call i32 (i32, i8*, ...) @fprintf(i32 %212, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.34, i64 0, i64 0), double %211)
%214 = call i32 @exit(i32 0)
unreachable
215: ; preds = %202, %215
%216 = phi i32 [ %240, %215 ], [ 0, %202 ]
%217 = phi double [ %239, %215 ], [ 0.000000e+00, %202 ]
%218 = phi double [ %238, %215 ], [ 0.000000e+00, %202 ]
%219 = call i32 (...) @random()
%220 = load i32, i32* @RAND_MAX
%221 = sdiv i32 %220, 2
%222 = shl nsw i32 %221, 1
%223 = srem i32 %219, %222
%224 = sub nsw i32 %223, %221
%225 = sitofp i32 %224 to double
%226 = call i32 (...) @random()
%227 = load i32, i32* @RAND_MAX
%228 = sdiv i32 %227, 2
%229 = shl nsw i32 %228, 1
%230 = srem i32 %226, %229
%231 = sub nsw i32 %230, %228
%232 = sitofp i32 %231 to double
%233 = call i32 @zeroDist(double %225, double %232)
%234 = load i32, i32* @RAND_MAX
%235 = sdiv i32 %234, 2
%236 = icmp slt i32 %233, %235
%237 = fadd double %218, 1.000000e+00
%238 = select i1 %236, double %237, double %218
%239 = fadd double %217, 1.000000e+00
%240 = add nuw nsw i32 %216, 1
%241 = icmp eq i32 %240, 1000000
br i1 %241, label %209, label %215
242: ; preds = %74
%243 = add nuw nsw i32 %75, 1
%244 = icmp eq i32 %243, %22
br i1 %244, label %69, label %74
245: ; preds = %69, %255
%246 = phi i32 [ %257, %255 ], [ %72, %69 ]
%247 = phi i32 [ %256, %255 ], [ 0, %69 ]
%248 = load i32, i32* %6
%249 = call i64 @WIFEXITED(i32 %248)
%250 = icmp eq i64 %249, 0
br i1 %250, label %255, label %251
251: ; preds = %245
%252 = load i32, i32* @stdout
%253 = call i32 (i32, i8*, ...) @fprintf(i32 %252, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.36, i64 0, i64 0), i32 %246)
%254 = add nsw i32 %247, 1
br label %255
255: ; preds = %251, %245
%256 = phi i32 [ %254, %251 ], [ %247, %245 ]
%257 = call i32 @wait(i32* %6)
%258 = icmp sgt i32 %257, 0
br i1 %258, label %245, label %259
259: ; preds = %255, %69
%260 = phi i32 [ 0, %69 ], [ %256, %255 ]
%261 = icmp eq i32 %260, %22
br i1 %261, label %262, label %267
262: ; preds = %259
%263 = load i32, i32* @stdout
%264 = call i32 (i32, i8*, ...) @fprintf(i32 %263, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.37, i64 0, i64 0), i32 %22, i32 %22)
%265 = load i32, i32* @EXIT_SUCCESS
%266 = call i32 @exit(i32 %265)
unreachable
267: ; preds = %259
%268 = load i32, i32* @stderr
%269 = call i32 (i32, i8*, ...) @fprintf(i32 %268, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.38, i64 0, i64 0))
%270 = load i32, i32* @EXIT_FAILURE
%271 = call i32 @exit(i32 %270)
unreachable
}