#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 timeb {
  int time;
  scalar_t__ millitm;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ fork();
int /*<<< orphan*/ ftime(struct timeb *);
int getpid();
void *malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, int, ...);
int read(int, int *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char *argv[]) {
  double pr, pi;
  double newRe, newIm, oldRe, oldIm;
  double zoom = 1, moveX = -0.5, moveY = 0;
  int maxIterations = 5000;
  int x, y, i;
  int width = 5000;
  int height = 5000;
  int widthPerProc = width;
  int widthStart = 0;
  int procs = 1;
  pid_t *children = NULL;
  int isChild = 0;
  int *lineDataBuffer = NULL;
  struct timeb beg, end;
  if (argc > 3) {
    width = atoi(argv[2]);
    height = atoi(argv[3]);
  }
  if (argc > 1) {
    procs = atoi(argv[1]);
    if (procs < 1)
      procs = 1;
    widthPerProc = width / procs;
  }
  printf("Procs: %d, Width: %d, Height: %d\n", procs, width, height);
  if (procs > 1) {
    children = malloc(sizeof(pid_t) * (procs - 1));
    int procId = 0;
    for (; procId < (procs - 1); procId++) {
      pid_t pid = fork();
      if (pid == 0) {
        isChild = 1;
        widthStart = procId * widthPerProc;
        lineDataBuffer = malloc(2 * sizeof(int) * height * widthPerProc);
        break;
      } else {
        children[procId] = pid;
      }
    }
    if (!isChild) {
      widthStart = procId * widthPerProc;
    }
  }
  sleep(3);
  printf("Starting calculation of pid %d\n", getpid());
  ftime(&beg);
  for (x = widthStart; x < (widthStart + widthPerProc) && x < width; x++) {
    for (y = 0; y < height; y++) {
      pr = 1.5 * (x - width / 2) / (0.5 * zoom * width) + moveX;
      pi = (y - height / 2) / (0.5 * zoom * height) + moveY;
      newRe = newIm = oldRe = oldIm = 0;
      for (i = 0; i < maxIterations; i++) {
        oldRe = newRe;
        oldIm = newIm;
        newRe = oldRe * oldRe - oldIm * oldIm + pr;
        newIm = 2 * oldRe * oldIm + pi;
        if ((newRe * newRe + newIm * newIm) > 4)
          break;
      }
      if (lineDataBuffer) {
        lineDataBuffer[2 * ((x - widthStart) * height + y)] = newRe;
        lineDataBuffer[2 * ((x - widthStart) * height + y) + 1] = newIm;
      }
    }
  }
  ftime(&end);
  printf("Pid %d calculated columns %d to %d in %ld ms\n", getpid(), widthStart,
         widthStart + widthPerProc,
         (end.millitm + end.time * 1000) - (beg.millitm + beg.time * 1000));
  if (!isChild) {
    int procId = 0;
    int status;
    for (; procId < (procs - 1); procId++) {
      char fname[100];
      int readBuffer[10000];
      sprintf(fname, "/tmp/test-%d", children[procId]);
      int singleRead = 0, totalRead = 0;
      waitpid(children[procId], &status, 0);
      int fd = open(fname, O_RDONLY);
      while (1) {
        singleRead = read(fd, readBuffer, 10000);
        totalRead += singleRead;
        if (singleRead != 10000)
          break;
      }
      close(fd);
      printf("Pid %d finished. Total read: %d Status: %d\n", children[procId],
             totalRead, status);
    }
  } else {
    char fname[100];
    sprintf(fname, "/tmp/test-%d", getpid());
    int fd = open(fname, O_CREAT | O_WRONLY, S_IRWXO | S_IRWXU | S_IRWXG);
    write(fd, lineDataBuffer, sizeof(int) * 2 * height * widthPerProc);
    close(fd);
    printf("Pid %d written: %ld\n", getpid(),
           sizeof(int) * 2 * height * widthPerProc);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9e10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe17(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe02(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x1388,-0x5c(%rbp)
movl   $0x1388,-0x6c(%rbp)
movl   $0x1388,-0x70(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x1,-0x7c(%rbp)
movq   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movq   $0x0,-0x98(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    127e <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12b3 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x1,-0x7c(%rbp)
jge    12a9 <main+0xd9>
movl   $0x1,-0x7c(%rbp)
mov    -0x6c(%rbp),%eax
cltd
idivl  -0x7c(%rbp)
mov    %eax,-0x74(%rbp)
mov    -0x7c(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x70(%rbp),%ecx
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x7c(%rbp)
jle    13b3 <main+0x1e3>
mov    -0x7c(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
mov    -0x7c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1394 <main+0x1c4>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    1362 <main+0x192>
movl   $0x1,-0x8c(%rbp)
mov    -0xbc(%rbp),%eax
imul   -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
movslq -0x74(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x98(%rbp)
jmp    1394 <main+0x1c4>
mov    -0xc8(%rbp),%rdx
mov    -0x88(%rbp),%rax
movslq -0xbc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1380 <main+0x1b0>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    12f8 <main+0x128>
cmpl   $0x0,-0x8c(%rbp)
jne    13ae <main+0x1de>
mov    -0xbc(%rbp),%eax
imul   -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    13b3 <main+0x1e3>
mov    $0x3,%edi
call   10d0 <sleep@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa8(%rbp),%rdi
call   10e0 <ftime@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%ecx
mov    -0x78(%rbp),%edx
add    -0x74(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x9df5(%rbp)
jge    140e <main+0x23e>
mov    -0x60(%rbp),%eax
cmp    -0x6c(%rbp),%eax
setl   %al
mov    %al,-0x9df5(%rbp)
mov    -0x9df5(%rbp),%al
test   $0x1,%al
jne    1421 <main+0x251>
jmp    1635 <main+0x465>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1622 <main+0x452>
mov    -0x60(%rbp),%eax
mov    %eax,-0x9e00(%rbp)
mov    -0x6c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x9e00(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xbba(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xba6(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
cvtsi2sdl -0x6c(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x9dfc(%rbp)
mov    -0x70(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x9dfc(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xb60(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
cvtsi2sdl -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    15ba <main+0x3ea>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xad0(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xa88(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    15a7 <main+0x3d7>
jmp    15ba <main+0x3ea>
jmp    15ac <main+0x3dc>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    14f3 <main+0x323>
cmpq   $0x0,-0x98(%rbp)
je     160f <main+0x43f>
cvttsd2si -0x28(%rbp),%edx
mov    -0x98(%rbp),%rax
mov    -0x60(%rbp),%ecx
sub    -0x78(%rbp),%ecx
imul   -0x70(%rbp),%ecx
add    -0x64(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
cvttsd2si -0x30(%rbp),%edx
mov    -0x98(%rbp),%rax
mov    -0x60(%rbp),%ecx
sub    -0x78(%rbp),%ecx
imul   -0x70(%rbp),%ecx
add    -0x64(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1614 <main+0x444>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1428 <main+0x258>
jmp    1627 <main+0x457>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    13e6 <main+0x216>
lea    -0xb8(%rbp),%rdi
call   10e0 <ftime@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
mov    -0x78(%rbp),%edx
mov    -0x78(%rbp),%ecx
add    -0x74(%rbp),%ecx
mov    -0xb0(%rbp),%r8
imul   $0x3e8,-0xb8(%rbp),%eax
cltq
add    %rax,%r8
mov    -0xa0(%rbp),%rax
imul   $0x3e8,-0xa8(%rbp),%edi
movslq %edi,%rdi
add    %rdi,%rax
sub    %rax,%r8
lea    0x9e8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x8c(%rbp)
jne    17cf <main+0x5ff>
movl   $0x0,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
mov    -0x7c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    17ca <main+0x5fa>
lea    -0x140(%rbp),%rdi
mov    -0x88(%rbp),%rax
movslq -0xcc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%edx
lea    0x9c2(%rip),%rsi
call   10c0 <sprintf@plt>
movl   $0x0,-0x9d84(%rbp)
movl   $0x0,-0x9d88(%rbp)
mov    -0x88(%rbp),%rax
movslq -0xcc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0xd0(%rbp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
lea    -0x140(%rbp),%rdi
mov    0x28a3(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x9d8c(%rbp)
mov    -0x9d8c(%rbp),%edi
lea    -0x9d80(%rbp),%rsi
mov    $0x2710,%edx
call   1070 <read@plt>
mov    %eax,-0x9d84(%rbp)
mov    -0x9d84(%rbp),%eax
add    -0x9d88(%rbp),%eax
mov    %eax,-0x9d88(%rbp)
cmpl   $0x2710,-0x9d84(%rbp)
je     1778 <main+0x5a8>
jmp    177d <main+0x5ad>
jmp    1734 <main+0x564>
mov    -0x9d8c(%rbp),%edi
call   1060 <close@plt>
mov    -0x88(%rbp),%rax
movslq -0xcc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%esi
mov    -0x9d88(%rbp),%edx
mov    -0xd0(%rbp),%ecx
lea    0x8fe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    16a8 <main+0x4d8>
jmp    1890 <main+0x6c0>
lea    -0x9df0(%rbp),%rax
mov    %rax,-0x9e08(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x9e08(%rbp),%rdi
mov    %eax,%edx
lea    0x8ac(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x9df0(%rbp),%rdi
mov    0x27f1(%rip),%rax
mov    (%rax),%esi
mov    0x27a0(%rip),%rax
or     (%rax),%esi
mov    0x27cf(%rip),%rax
mov    (%rax),%edx
mov    0x27b6(%rip),%rax
or     (%rax),%edx
mov    0x27a5(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x9df4(%rbp)
mov    -0x9df4(%rbp),%edi
mov    -0x98(%rbp),%rsi
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
movslq -0x74(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x9df4(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
movslq -0x70(%rbp),%rdx
shl    $0x3,%rdx
movslq -0x74(%rbp),%rax
imul   %rax,%rdx
lea    0x850(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x9e10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9d18,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jl     1202 <main+0x32>
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
jmp    1216 <main+0x46>
mov    $0x1388,%ebp
mov    $0x1388,%r14d
cmp    $0x1,%edi
jle    12e5 <main+0x115>
mov    0x8(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
mov    $0x1,%r15d
cmovg  %eax,%r15d
mov    %r14d,%eax
cltd
idiv   %r15d
mov    %eax,%r12d
lea    0xde2(%rip),%rdi
xor    %r13d,%r13d
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%r15d
mov    %ebp,0xc(%rsp)
mov    $0x1,%al
jb     12d5 <main+0x105>
mov    %eax,0x10(%rsp)
lea    -0x8(,%r15,8),%edi
ff
call   1080 <malloc@plt>
mov    %rax,%r13
xor    %eax,%eax
cmp    $0x2,%ebx
mov    %r15,0x28(%rsp)
mov    %r13,0x20(%rsp)
jl     12ca <main+0xfa>
mov    %r14d,0x18(%rsp)
lea    -0x1(%r15),%eax
mov    %eax,0x14(%rsp)
mov    %eax,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
je     16c2 <main+0x4f2>
mov    %rax,0x0(%r13,%rbp,8)
add    $0x1,%rbp
add    %r12d,%r14d
cmp    %rbp,%rbx
jne    12a0 <main+0xd0>
mov    0x18(%rsp),%r14d
mov    0x14(%rsp),%eax
imul   %r12d,%eax
xor    %ebp,%ebp
mov    %eax,%r13d
jmp    1332 <main+0x162>
mov    %eax,0x10(%rsp)
mov    $0x1,%eax
mov    %rax,0x28(%rsp)
jmp    1329 <main+0x159>
lea    0xd34(%rip),%rdi
xor    %r13d,%r13d
mov    $0x1,%eax
mov    %rax,0x28(%rsp)
mov    $0x1388,%r12d
mov    $0x1,%esi
mov    $0x1388,%edx
mov    $0x1388,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%al
mov    %eax,0x10(%rsp)
mov    $0x1388,%r14d
movl   $0x1388,0xc(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %ebp,%ebp
mov    $0x3,%edi
call   10d0 <sleep@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xcf8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x50(%rsp),%rdi
call   10e0 <ftime@plt>
mov    %r13,0x18(%rsp)
lea    (%r12,%r13,1),%eax
mov    %eax,0x14(%rsp)
mov    %r12,0x38(%rsp)
test   %r12d,%r12d
jle    14f2 <main+0x322>
cmp    %r14d,0x18(%rsp)
jge    14f2 <main+0x322>
mov    %r14d,%r9d
shr    $0x1f,%r9d
add    %r14d,%r9d
sar    %r9d
neg    %r9d
cvtsi2sd %r14d,%xmm10
movsd  0xc60(%rip),%xmm2
mulsd  %xmm2,%xmm10
mov    0xc(%rsp),%eax
mov    %eax,%r13d
shr    $0x1f,%r13d
add    %eax,%r13d
sar    %r13d
neg    %r13d
cvtsi2sd %eax,%xmm1
mulsd  %xmm2,%xmm1
movslq 0x18(%rsp),%r8
mov    %eax,%r15d
movslq %r14d,%r10
movslq 0x14(%rsp),%r11
movsd  0xc2e(%rip),%xmm8
movsd  0xc2d(%rip),%xmm9
movsd  0xc2d(%rip),%xmm4
mov    %r8,%r14
xchg   %ax,%ax
cmpl   $0x0,0xc(%rsp)
jle    14e0 <main+0x310>
lea    (%r9,%r14,1),%edx
xorps  %xmm5,%xmm5
cvtsi2sd %edx,%xmm5
mulsd  %xmm8,%xmm5
divsd  %xmm10,%xmm5
addsd  %xmm9,%xmm5
mov    %r14,%rdx
sub    %r8,%rdx
imul   %r15,%rdx
xor    %edi,%edi
jmp    143d <main+0x26d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
cmp    %r15,%rdi
je     14e0 <main+0x310>
lea    (%rdi,%r13,1),%ebx
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
divsd  %xmm1,%xmm2
xorpd  %xmm7,%xmm7
addsd  %xmm7,%xmm2
xor    %ebx,%ebx
xorpd  %xmm6,%xmm6
nopw   0x0(%rax,%rax,1)
movapd %xmm7,%xmm3
movapd %xmm6,%xmm0
mulsd  %xmm6,%xmm0
mulsd  %xmm7,%xmm7
subsd  %xmm0,%xmm7
addsd  %xmm5,%xmm7
addsd  %xmm3,%xmm3
mulsd  %xmm3,%xmm6
addsd  %xmm2,%xmm6
movapd %xmm6,%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm7,%xmm3
mulsd  %xmm7,%xmm3
addsd  %xmm0,%xmm3
ucomisd %xmm4,%xmm3
ja     14ab <main+0x2db>
lea    0x1(%rbx),%eax
cmp    $0x1387,%ebx
mov    %eax,%ebx
jb     1460 <main+0x290>
test   %rbp,%rbp
je     1430 <main+0x260>
cvttsd2si %xmm7,%eax
lea    (%rdi,%rdx,1),%ebx
lea    (%rbx,%rbx,1),%r12d
movslq %r12d,%rcx
cvttsd2si %xmm6,%esi
mov    %eax,0x0(%rbp,%rcx,4)
lea    (%rbx,%rbx,1),%eax
add    $0x1,%eax
cltq
mov    %esi,0x0(%rbp,%rax,4)
jmp    1430 <main+0x260>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r11,%r14
jge    14f2 <main+0x322>
cmp    %r10,%r14
jl     13f0 <main+0x220>
lea    0x40(%rsp),%rdi
call   10e0 <ftime@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
movslq 0x40(%rsp),%rcx
imul   $0x3e8,%rcx,%r8
movslq 0x50(%rsp),%rcx
add    0x48(%rsp),%r8
imul   $0x3e8,%rcx,%rcx
add    0x58(%rsp),%rcx
sub    %rcx,%r8
lea    0xb33(%rip),%rdi
mov    %eax,%esi
mov    0x18(%rsp),%rdx
mov    0x14(%rsp),%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,0x10(%rsp)
je     1613 <main+0x443>
mov    0x28(%rsp),%r15
cmp    $0x2,%r15d
mov    0x20(%rsp),%rbp
jb     16ae <main+0x4de>
add    $0xffffffff,%r15d
lea    0xd0(%rsp),%rbx
xor    %r13d,%r13d
nop
mov    0x0(%rbp,%r13,8),%edx
lea    0x60(%rsp),%r14
mov    %r14,%rdi
lea    0xb0c(%rip),%rsi
call   10c0 <sprintf@plt>
mov    0x0(%rbp,%r13,8),%rdi
lea    0x34(%rsp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
mov    0x2a27(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <open@plt>
mov    %eax,%r12d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x2710,%edx
call   1070 <read@plt>
add    %eax,%r14d
cmp    $0x2710,%eax
je     15c0 <main+0x3f0>
mov    %r12d,%edi
call   1060 <close@plt>
mov    0x20(%rsp),%rbp
mov    0x0(%rbp,%r13,8),%esi
mov    0x34(%rsp),%ecx
lea    0xaa6(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r13
cmp    %r15,%r13
jne    1570 <main+0x3a0>
jmp    16ae <main+0x4de>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xa6f(%rip),%rsi
lea    0xd0(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   10c0 <sprintf@plt>
mov    0x29be(%rip),%rax
mov    0x296f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x299c(%rip),%rax
mov    0x2985(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2972(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <open@plt>
mov    %eax,%r14d
movslq 0xc(%rsp),%rax
movslq 0x38(%rsp),%rbx
imul   %rax,%rbx
shl    $0x3,%rbx
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xa27(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x9d18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12d,%edi
imul   0xc(%rsp),%edi
shl    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
movl   $0x0,0x10(%rsp)
mov    %r14,%r13
mov    0x18(%rsp),%r14d
jmp    1332 <main+0x162>

LLVM IR (-O0):
%struct.timeb = type { i32, i64 }
@.str = [34 x i8] c"Procs: %d, Width: %d, Height: %d\0A\00"
@.str.1 = [32 x i8] c"Starting calculation of pid %d\0A\00"
@.str.2 = [46 x i8] c"Pid %d calculated columns %d to %d in %ld ms\0A\00"
@.str.3 = [13 x i8] c"/tmp/test-%d\00"
@O_RDONLY = global i32 0
@.str.4 = [44 x i8] c"Pid %d finished. Total read: %d Status: %d\0A\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@S_IRWXO = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@.str.5 = [21 x i8] c"Pid %d written: %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%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 i64*
%25 = alloca i32
%26 = alloca i32*
%27 = alloca %struct.timeb
%28 = alloca %struct.timeb
%29 = alloca i32
%30 = alloca i64
%31 = alloca i32
%32 = alloca i32
%33 = alloca [100 x i8]
%34 = alloca [10000 x i32]
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca [100 x i8]
%39 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 1.000000e+00, double* %12
store double -5.000000e-01, double* %13
store double 0.000000e+00, double* %14
store i32 5000, i32* %15
store i32 5000, i32* %19
store i32 5000, i32* %20
%40 = load i32, i32* %19
store i32 %40, i32* %21
store i32 0, i32* %22
store i32 1, i32* %23
store i64* null, i64** %24
store i32 0, i32* %25
store i32* null, i32** %26
%41 = load i32, i32* %4
%42 = icmp sgt i32 %41, 3
br i1 %42, label %43, label %52
43: ; preds = %2
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %19
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %20
br label %52
52: ; preds = %43, %2
%53 = load i32, i32* %4
%54 = icmp sgt i32 %53, 1
br i1 %54, label %55, label %67
55: ; preds = %52
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 @atoi(i8* %58)
store i32 %59, i32* %23
%60 = load i32, i32* %23
%61 = icmp slt i32 %60, 1
br i1 %61, label %62, label %63
62: ; preds = %55
store i32 1, i32* %23
br label %63
63: ; preds = %62, %55
%64 = load i32, i32* %19
%65 = load i32, i32* %23
%66 = sdiv i32 %64, %65
store i32 %66, i32* %21
br label %67
67: ; preds = %63, %52
%68 = load i32, i32* %23
%69 = load i32, i32* %19
%70 = load i32, i32* %20
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
%72 = load i32, i32* %23
%73 = icmp sgt i32 %72, 1
br i1 %73, label %74, label %122
74: ; preds = %67
%75 = load i32, i32* %23
%76 = sub nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = mul i64 8, %77
%79 = trunc i64 %78 to i32
%80 = call i8* @malloc(i32 %79)
%81 = bitcast i8* %80 to i64*
store i64* %81, i64** %24
store i32 0, i32* %29
br label %82
82: ; preds = %111, %74
%83 = load i32, i32* %29
%84 = load i32, i32* %23
%85 = sub nsw i32 %84, 1
%86 = icmp slt i32 %83, %85
br i1 %86, label %87, label %114
87: ; preds = %82
%88 = call i64 (...) @fork()
store i64 %88, i64* %30
%89 = load i64, i64* %30
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %104
91: ; preds = %87
store i32 1, i32* %25
%92 = load i32, i32* %29
%93 = load i32, i32* %21
%94 = mul nsw i32 %92, %93
store i32 %94, i32* %22
%95 = load i32, i32* %20
%96 = sext i32 %95 to i64
%97 = mul i64 8, %96
%98 = load i32, i32* %21
%99 = sext i32 %98 to i64
%100 = mul i64 %97, %99
%101 = trunc i64 %100 to i32
%102 = call i8* @malloc(i32 %101)
%103 = bitcast i8* %102 to i32*
store i32* %103, i32** %26
br label %114
104: ; preds = %87
%105 = load i64, i64* %30
%106 = load i64*, i64** %24
%107 = load i32, i32* %29
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i64, i64* %106, i64 %108
store i64 %105, i64* %109
br label %110
110: ; preds = %104
br label %111
111: ; preds = %110
%112 = load i32, i32* %29
%113 = add nsw i32 %112, 1
store i32 %113, i32* %29
br label %82
114: ; preds = %91, %82
%115 = load i32, i32* %25
%116 = icmp ne i32 %115, 0
br i1 %116, label %121, label %117
117: ; preds = %114
%118 = load i32, i32* %29
%119 = load i32, i32* %21
%120 = mul nsw i32 %118, %119
store i32 %120, i32* %22
br label %121
121: ; preds = %117, %114
br label %122
122: ; preds = %121, %67
%123 = call i32 @sleep(i32 3)
%124 = call i32 (...) @getpid()
%125 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %124)
%126 = call i32 @ftime(%struct.timeb* %27)
%127 = load i32, i32* %22
store i32 %127, i32* %16
br label %128
128: ; preds = %242, %122
%129 = load i32, i32* %16
%130 = load i32, i32* %22
%131 = load i32, i32* %21
%132 = add nsw i32 %130, %131
%133 = icmp slt i32 %129, %132
br i1 %133, label %134, label %138
134: ; preds = %128
%135 = load i32, i32* %16
%136 = load i32, i32* %19
%137 = icmp slt i32 %135, %136
br label %138
138: ; preds = %134, %128
%139 = phi i1 [ false, %128 ], [ %137, %134 ]
br i1 %139, label %140, label %245
140: ; preds = %138
store i32 0, i32* %17
br label %141
141: ; preds = %238, %140
%142 = load i32, i32* %17
%143 = load i32, i32* %20
%144 = icmp slt i32 %142, %143
br i1 %144, label %145, label %241
145: ; preds = %141
%146 = load i32, i32* %16
%147 = load i32, i32* %19
%148 = sdiv i32 %147, 2
%149 = sub nsw i32 %146, %148
%150 = sitofp i32 %149 to double
%151 = fmul double 1.500000e+00, %150
%152 = load double, double* %12
%153 = fmul double 5.000000e-01, %152
%154 = load i32, i32* %19
%155 = sitofp i32 %154 to double
%156 = fmul double %153, %155
%157 = fdiv double %151, %156
%158 = load double, double* %13
%159 = fadd double %157, %158
store double %159, double* %6
%160 = load i32, i32* %17
%161 = load i32, i32* %20
%162 = sdiv i32 %161, 2
%163 = sub nsw i32 %160, %162
%164 = sitofp i32 %163 to double
%165 = load double, double* %12
%166 = fmul double 5.000000e-01, %165
%167 = load i32, i32* %20
%168 = sitofp i32 %167 to double
%169 = fmul double %166, %168
%170 = fdiv double %164, %169
%171 = load double, double* %14
%172 = fadd double %170, %171
store double %172, double* %7
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %8
store i32 0, i32* %18
br label %173
173: ; preds = %203, %145
%174 = load i32, i32* %18
%175 = load i32, i32* %15
%176 = icmp slt i32 %174, %175
br i1 %176, label %177, label %206
177: ; preds = %173
%178 = load double, double* %8
store double %178, double* %10
%179 = load double, double* %9
store double %179, double* %11
%180 = load double, double* %10
%181 = load double, double* %10
%182 = load double, double* %11
%183 = load double, double* %11
%184 = fmul double %182, %183
%185 = fneg double %184
%186 = call double @llvm.fmuladd.f64(double %180, double %181, double %185)
%187 = load double, double* %6
%188 = fadd double %186, %187
store double %188, double* %8
%189 = load double, double* %10
%190 = fmul double 2.000000e+00, %189
%191 = load double, double* %11
%192 = load double, double* %7
%193 = call double @llvm.fmuladd.f64(double %190, double %191, double %192)
store double %193, double* %9
%194 = load double, double* %8
%195 = load double, double* %8
%196 = load double, double* %9
%197 = load double, double* %9
%198 = fmul double %196, %197
%199 = call double @llvm.fmuladd.f64(double %194, double %195, double %198)
%200 = fcmp ogt double %199, 4.000000e+00
br i1 %200, label %201, label %202
201: ; preds = %177
br label %206
202: ; preds = %177
br label %203
203: ; preds = %202
%204 = load i32, i32* %18
%205 = add nsw i32 %204, 1
store i32 %205, i32* %18
br label %173
206: ; preds = %201, %173
%207 = load i32*, i32** %26
%208 = icmp ne i32* %207, null
br i1 %208, label %209, label %237
209: ; preds = %206
%210 = load double, double* %8
%211 = fptosi double %210 to i32
%212 = load i32*, i32** %26
%213 = load i32, i32* %16
%214 = load i32, i32* %22
%215 = sub nsw i32 %213, %214
%216 = load i32, i32* %20
%217 = mul nsw i32 %215, %216
%218 = load i32, i32* %17
%219 = add nsw i32 %217, %218
%220 = mul nsw i32 2, %219
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds i32, i32* %212, i64 %221
store i32 %211, i32* %222
%223 = load double, double* %9
%224 = fptosi double %223 to i32
%225 = load i32*, i32** %26
%226 = load i32, i32* %16
%227 = load i32, i32* %22
%228 = sub nsw i32 %226, %227
%229 = load i32, i32* %20
%230 = mul nsw i32 %228, %229
%231 = load i32, i32* %17
%232 = add nsw i32 %230, %231
%233 = mul nsw i32 2, %232
%234 = add nsw i32 %233, 1
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds i32, i32* %225, i64 %235
store i32 %224, i32* %236
br label %237
237: ; preds = %209, %206
br label %238
238: ; preds = %237
%239 = load i32, i32* %17
%240 = add nsw i32 %239, 1
store i32 %240, i32* %17
br label %141
241: ; preds = %141
br label %242
242: ; preds = %241
%243 = load i32, i32* %16
%244 = add nsw i32 %243, 1
store i32 %244, i32* %16
br label %128
245: ; preds = %138
%246 = call i32 @ftime(%struct.timeb* %28)
%247 = call i32 (...) @getpid()
%248 = load i32, i32* %22
%249 = load i32, i32* %22
%250 = load i32, i32* %21
%251 = add nsw i32 %249, %250
%252 = getelementptr inbounds %struct.timeb, %struct.timeb* %28, i32 0, i32 1
%253 = load i64, i64* %252
%254 = getelementptr inbounds %struct.timeb, %struct.timeb* %28, i32 0, i32 0
%255 = load i32, i32* %254
%256 = mul nsw i32 %255, 1000
%257 = sext i32 %256 to i64
%258 = add nsw i64 %253, %257
%259 = getelementptr inbounds %struct.timeb, %struct.timeb* %27, i32 0, i32 1
%260 = load i64, i64* %259
%261 = getelementptr inbounds %struct.timeb, %struct.timeb* %27, i32 0, i32 0
%262 = load i32, i32* %261
%263 = mul nsw i32 %262, 1000
%264 = sext i32 %263 to i64
%265 = add nsw i64 %260, %264
%266 = sub nsw i64 %258, %265
%267 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %247, i32 %248, i32 %251, i64 %266)
%268 = load i32, i32* %25
%269 = icmp ne i32 %268, 0
br i1 %269, label %321, label %270
270: ; preds = %245
store i32 0, i32* %31
br label %271
271: ; preds = %317, %270
%272 = load i32, i32* %31
%273 = load i32, i32* %23
%274 = sub nsw i32 %273, 1
%275 = icmp slt i32 %272, %274
br i1 %275, label %276, label %320
276: ; preds = %271
%277 = getelementptr inbounds [100 x i8], [100 x i8]* %33, i64 0, i64 0
%278 = load i64*, i64** %24
%279 = load i32, i32* %31
%280 = sext i32 %279 to i64
%281 = getelementptr inbounds i64, i64* %278, i64 %280
%282 = load i64, i64* %281
%283 = trunc i64 %282 to i32
%284 = call i32 @sprintf(i8* %277, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %283)
store i32 0, i32* %35
store i32 0, i32* %36
%285 = load i64*, i64** %24
%286 = load i32, i32* %31
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i64, i64* %285, i64 %287
%289 = load i64, i64* %288
%290 = call i32 @waitpid(i64 %289, i32* %32, i32 0)
%291 = getelementptr inbounds [100 x i8], [100 x i8]* %33, i64 0, i64 0
%292 = load i32, i32* @O_RDONLY
%293 = call i32 (i8*, i32, ...) @open(i8* %291, i32 %292)
store i32 %293, i32* %37
br label %294
294: ; preds = %276, %304
%295 = load i32, i32* %37
%296 = getelementptr inbounds [10000 x i32], [10000 x i32]* %34, i64 0, i64 0
%297 = call i32 @read(i32 %295, i32* %296, i32 10000)
store i32 %297, i32* %35
%298 = load i32, i32* %35
%299 = load i32, i32* %36
%300 = add nsw i32 %299, %298
store i32 %300, i32* %36
%301 = load i32, i32* %35
%302 = icmp ne i32 %301, 10000
br i1 %302, label %303, label %304
303: ; preds = %294
br label %305
304: ; preds = %294
br label %294
305: ; preds = %303
%306 = load i32, i32* %37
%307 = call i32 @close(i32 %306)
%308 = load i64*, i64** %24
%309 = load i32, i32* %31
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds i64, i64* %308, i64 %310
%312 = load i64, i64* %311
%313 = trunc i64 %312 to i32
%314 = load i32, i32* %36
%315 = load i32, i32* %32
%316 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %313, i32 %314, i32 %315)
br label %317
317: ; preds = %305
%318 = load i32, i32* %31
%319 = add nsw i32 %318, 1
store i32 %319, i32* %31
br label %271
320: ; preds = %271
br label %355
321: ; preds = %245
%322 = getelementptr inbounds [100 x i8], [100 x i8]* %38, i64 0, i64 0
%323 = call i32 (...) @getpid()
%324 = call i32 @sprintf(i8* %322, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %323)
%325 = getelementptr inbounds [100 x i8], [100 x i8]* %38, i64 0, i64 0
%326 = load i32, i32* @O_CREAT
%327 = load i32, i32* @O_WRONLY
%328 = or i32 %326, %327
%329 = load i32, i32* @S_IRWXO
%330 = load i32, i32* @S_IRWXU
%331 = or i32 %329, %330
%332 = load i32, i32* @S_IRWXG
%333 = or i32 %331, %332
%334 = call i32 (i8*, i32, ...) @open(i8* %325, i32 %328, i32 %333)
store i32 %334, i32* %39
%335 = load i32, i32* %39
%336 = load i32*, i32** %26
%337 = load i32, i32* %20
%338 = sext i32 %337 to i64
%339 = mul i64 8, %338
%340 = load i32, i32* %21
%341 = sext i32 %340 to i64
%342 = mul i64 %339, %341
%343 = trunc i64 %342 to i32
%344 = call i32 @write(i32 %335, i32* %336, i32 %343)
%345 = load i32, i32* %39
%346 = call i32 @close(i32 %345)
%347 = call i32 (...) @getpid()
%348 = load i32, i32* %20
%349 = sext i32 %348 to i64
%350 = mul i64 8, %349
%351 = load i32, i32* %21
%352 = sext i32 %351 to i64
%353 = mul i64 %350, %352
%354 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %347, i64 %353)
br label %355
355: ; preds = %321, %320
ret i32 0
}

LLVM IR (-O2):
%struct.timeb = type { i32, i64 }
@.str = [34 x i8] c"Procs: %d, Width: %d, Height: %d\0A\00"
@.str.1 = [32 x i8] c"Starting calculation of pid %d\0A\00"
@.str.2 = [46 x i8] c"Pid %d calculated columns %d to %d in %ld ms\0A\00"
@.str.3 = [13 x i8] c"/tmp/test-%d\00"
@O_RDONLY = global i32 0
@.str.4 = [44 x i8] c"Pid %d finished. Total read: %d Status: %d\0A\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@S_IRWXO = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@.str.5 = [21 x i8] c"Pid %d written: %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeb
%4 = alloca %struct.timeb
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca [10000 x i32]
%8 = alloca [100 x i8]
%9 = bitcast %struct.timeb* %3 to i8*
%10 = bitcast %struct.timeb* %4 to i8*
%11 = icmp sgt i32 %0, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
br label %23
19: ; preds = %2
%20 = icmp sgt i32 %0, 1
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 1, i32 5000, i32 5000)
br label %59
23: ; preds = %19, %12
%24 = phi i32 [ %18, %12 ], [ 5000, %19 ]
%25 = phi i32 [ %15, %12 ], [ 5000, %19 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
%29 = icmp sgt i32 %28, 1
%30 = select i1 %29, i32 %28, i32 1
%31 = sdiv i32 %25, %30
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %25, i32 %24)
%33 = icmp ugt i32 %30, 1
br i1 %33, label %34, label %59
34: ; preds = %23
%35 = add nsw i32 %30, -1
%36 = shl i32 %35, 3
%37 = tail call i8* @malloc(i32 %36)
%38 = bitcast i8* %37 to i64*
br i1 %29, label %39, label %56
39: ; preds = %34
%40 = zext i32 %35 to i64
br label %41
41: ; preds = %39, %45
%42 = phi i64 [ 0, %39 ], [ %47, %45 ]
%43 = tail call i64 (...) @fork()
%44 = icmp eq i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = getelementptr inbounds i64, i64* %38, i64 %42
store i64 %43, i64* %46
%47 = add nuw nsw i64 %42, 1
%48 = icmp eq i64 %47, %40
br i1 %48, label %56, label %41
49: ; preds = %41
%50 = trunc i64 %42 to i32
%51 = mul nsw i32 %31, %50
%52 = shl i32 %24, 3
%53 = mul i32 %52, %31
%54 = tail call i8* @malloc(i32 %53)
%55 = bitcast i8* %54 to i32*
br label %59
56: ; preds = %45, %34
%57 = phi i32 [ 0, %34 ], [ %35, %45 ]
%58 = mul nsw i32 %57, %31
br label %59
59: ; preds = %56, %49, %21, %23
%60 = phi i32 [ 1, %23 ], [ 1, %21 ], [ %30, %49 ], [ %30, %56 ]
%61 = phi i32 [ %31, %23 ], [ 5000, %21 ], [ %31, %49 ], [ %31, %56 ]
%62 = phi i32 [ %25, %23 ], [ 5000, %21 ], [ %25, %49 ], [ %25, %56 ]
%63 = phi i32 [ %24, %23 ], [ 5000, %21 ], [ %24, %49 ], [ %24, %56 ]
%64 = phi i32 [ 0, %23 ], [ 0, %21 ], [ %51, %49 ], [ %58, %56 ]
%65 = phi i64* [ null, %23 ], [ null, %21 ], [ %38, %49 ], [ %38, %56 ]
%66 = phi i1 [ true, %23 ], [ true, %21 ], [ false, %49 ], [ true, %56 ]
%67 = phi i32* [ null, %23 ], [ null, %21 ], [ %55, %49 ], [ null, %56 ]
%68 = tail call i32 @sleep(i32 3)
%69 = tail call i32 (...) @getpid()
%70 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %69)
%71 = call i32 @ftime(%struct.timeb* %3)
%72 = add nsw i32 %64, %61
%73 = icmp sgt i32 %61, 0
%74 = icmp slt i32 %64, %62
%75 = and i1 %73, %74
br i1 %75, label %76, label %144
76: ; preds = %59
%77 = icmp sgt i32 %63, 0
%78 = sdiv i32 %62, -2
%79 = sitofp i32 %62 to double
%80 = fmul double %79, 5.000000e-01
%81 = sdiv i32 %63, -2
%82 = sitofp i32 %63 to double
%83 = fmul double %82, 5.000000e-01
%84 = icmp eq i32* %67, null
%85 = sext i32 %64 to i64
%86 = zext i32 %63 to i64
%87 = sext i32 %62 to i64
%88 = sext i32 %72 to i64
%89 = zext i32 %63 to i64
br label %90
90: ; preds = %76, %139
%91 = phi i64 [ %85, %76 ], [ %140, %139 ]
br i1 %77, label %92, label %139
92: ; preds = %90
%93 = trunc i64 %91 to i32
%94 = add i32 %78, %93
%95 = sitofp i32 %94 to double
%96 = fmul double %95, 1.500000e+00
%97 = fdiv double %96, %80
%98 = fadd double %97, -5.000000e-01
%99 = sub nsw i64 %91, %85
%100 = mul i64 %99, %86
br label %101
101: ; preds = %92, %136
%102 = phi i64 [ 0, %92 ], [ %137, %136 ]
%103 = trunc i64 %102 to i32
%104 = add i32 %81, %103
%105 = sitofp i32 %104 to double
%106 = fdiv double %105, %83
%107 = fadd double %106, 0.000000e+00
br label %108
108: ; preds = %108, %101
%109 = phi double [ 0.000000e+00, %101 ], [ %115, %108 ]
%110 = phi double [ 0.000000e+00, %101 ], [ %117, %108 ]
%111 = phi i32 [ 0, %101 ], [ %121, %108 ]
%112 = fneg double %110
%113 = fmul double %110, %112
%114 = call double @llvm.fmuladd.f64(double %109, double %109, double %113)
%115 = fadd double %98, %114
%116 = fmul double %109, 2.000000e+00
%117 = call double @llvm.fmuladd.f64(double %116, double %110, double %107)
%118 = fmul double %117, %117
%119 = call double @llvm.fmuladd.f64(double %115, double %115, double %118)
%120 = fcmp ule double %119, 4.000000e+00
%121 = add nuw nsw i32 %111, 1
%122 = icmp ult i32 %111, 4999
%123 = select i1 %120, i1 %122, i1 false
br i1 %123, label %108, label %124
124: ; preds = %108
br i1 %84, label %136, label %125
125: ; preds = %124
%126 = fptosi double %115 to i32
%127 = add i64 %102, %100
%128 = trunc i64 %127 to i32
%129 = shl nsw i32 %128, 1
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %67, i64 %130
store i32 %126, i32* %131
%132 = fptosi double %117 to i32
%133 = or i32 %129, 1
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i32, i32* %67, i64 %134
store i32 %132, i32* %135
br label %136
136: ; preds = %124, %125
%137 = add nuw nsw i64 %102, 1
%138 = icmp eq i64 %137, %89
br i1 %138, label %139, label %101
139: ; preds = %136, %90
%140 = add nsw i64 %91, 1
%141 = icmp slt i64 %140, %88
%142 = icmp slt i64 %140, %87
%143 = and i1 %141, %142
br i1 %143, label %90, label %144
144: ; preds = %139, %59
%145 = call i32 @ftime(%struct.timeb* %4)
%146 = call i32 (...) @getpid()
%147 = getelementptr inbounds %struct.timeb, %struct.timeb* %4, i64 0, i32 1
%148 = load i64, i64* %147
%149 = getelementptr inbounds %struct.timeb, %struct.timeb* %4, i64 0, i32 0
%150 = load i32, i32* %149
%151 = mul nsw i32 %150, 1000
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds %struct.timeb, %struct.timeb* %3, i64 0, i32 1
%154 = load i64, i64* %153
%155 = getelementptr inbounds %struct.timeb, %struct.timeb* %3, i64 0, i32 0
%156 = load i32, i32* %155
%157 = mul nsw i32 %156, 1000
%158 = sext i32 %157 to i64
%159 = add i64 %148, %152
%160 = add i64 %154, %158
%161 = sub i64 %159, %160
%162 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %146, i32 %64, i32 %72, i64 %161)
br i1 %66, label %163, label %196
163: ; preds = %144
%164 = bitcast i32* %5 to i8*
%165 = icmp ugt i32 %60, 1
br i1 %165, label %166, label %195
166: ; preds = %163
%167 = add nsw i32 %60, -1
%168 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%169 = bitcast [10000 x i32]* %7 to i8*
%170 = getelementptr inbounds [10000 x i32], [10000 x i32]* %7, i64 0, i64 0
%171 = zext i32 %167 to i64
br label %172
172: ; preds = %166, %187
%173 = phi i64 [ 0, %166 ], [ %193, %187 ]
%174 = getelementptr inbounds i64, i64* %65, i64 %173
%175 = load i64, i64* %174
%176 = trunc i64 %175 to i32
%177 = call i32 @sprintf(i8* %168, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %176)
%178 = load i64, i64* %174
%179 = call i32 @waitpid(i64 %178, i32* %5, i32 0)
%180 = load i32, i32* @O_RDONLY
%181 = call i32 (i8*, i32, ...) @open(i8* %168, i32 %180)
br label %182
182: ; preds = %182, %172
%183 = phi i32 [ 0, %172 ], [ %185, %182 ]
%184 = call i32 @read(i32 %181, i32* %170, i32 10000)
%185 = add nsw i32 %184, %183
%186 = icmp eq i32 %184, 10000
br i1 %186, label %182, label %187
187: ; preds = %182
%188 = call i32 @close(i32 %181)
%189 = load i64, i64* %174
%190 = trunc i64 %189 to i32
%191 = load i32, i32* %5
%192 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %190, i32 %185, i32 %191)
%193 = add nuw nsw i64 %173, 1
%194 = icmp eq i64 %193, %171
br i1 %194, label %195, label %172
195: ; preds = %187, %163
br label %218
196: ; preds = %144
%197 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%198 = call i32 (...) @getpid()
%199 = call i32 @sprintf(i8* %197, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %198)
%200 = load i32, i32* @O_CREAT
%201 = load i32, i32* @O_WRONLY
%202 = or i32 %201, %200
%203 = load i32, i32* @S_IRWXO
%204 = load i32, i32* @S_IRWXU
%205 = or i32 %204, %203
%206 = load i32, i32* @S_IRWXG
%207 = or i32 %205, %206
%208 = call i32 (i8*, i32, ...) @open(i8* %197, i32 %202, i32 %207)
%209 = sext i32 %63 to i64
%210 = shl nsw i64 %209, 3
%211 = sext i32 %61 to i64
%212 = mul i64 %210, %211
%213 = trunc i64 %212 to i32
%214 = call i32 @write(i32 %208, i32* %67, i32 %213)
%215 = call i32 @close(i32 %208)
%216 = call i32 (...) @getpid()
%217 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %216, i64 %212)
br label %218
218: ; preds = %196, %195
ret i32 0
}