#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ input;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ child_msg;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int pipe(int *);
int /*<<< orphan*/ printf(char *);
int rand();
scalar_t__ read(int, char *, int);
int select(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double time_diff(struct timeval, struct timeval);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int /*<<< orphan*/ write_output(char *);
int main(int argc, char *argv[]) {
  struct timeval timeout, time_start, time_end;
  double timestamp;
  pid_t lazy_pid, active_pid;
  int lazy_fd[2], active_fd[2], ret, random;
  char child_msg[256], input[256], input_buffer[256], buffer[256], output[256];
  fd_set set;
  int child_msg_num = 1;
  srand(time(NULL));
  timeout.tv_sec = 5;
  timeout.tv_usec = 0;
  gettimeofday(&time_start, NULL);
  FILE *file = fopen("output.txt", "w");
  if (file == NULL) {
    printf("Arquivo não pode ser aberto. Abortando...\n");
    exit(1);
  }
  fclose(file);
  if (pipe(lazy_fd) == -1) {
    printf("Pipe failed\n");
    exit(1);
  }
  lazy_pid = fork();
  if (lazy_pid < 0) {
    exit(1);
  } else if (lazy_pid == 0) {
    close(lazy_fd[0]);
    do {
      sleep(rand() % 3);
      gettimeofday(&time_end, NULL);
      timestamp = time_diff(time_end, time_start);
      sprintf(child_msg, "0:%02d.%03d: Mensagem %02d do filho dorminhoco",
              (int)timestamp, (int)((timestamp - (int)timestamp) * 1000),
              child_msg_num);
      write(lazy_fd[1], child_msg, sizeof(child_msg));
      child_msg_num++;
    } while (timestamp < 30);
  } else {
    close(lazy_fd[1]);
    if (pipe(active_fd) == -1) {
      printf("Pipe failed\n");
      exit(1);
    }
    active_pid = fork();
    if (active_pid < 0) {
      exit(1);
    } else if (active_pid == 0) {
      close(active_fd[0]);
      do {
        fgets(input_buffer, sizeof(input), stdin);
        sscanf(input_buffer, "%99[^\n]", input);
        gettimeofday(&time_end, NULL);
        timestamp = (double)(time_end.tv_sec - time_start.tv_sec) +
                    ((double)time_end.tv_usec - (double)time_start.tv_usec) /
                        1000000.0f;
        sprintf(child_msg, "0:%02d.%03d: Mensagem %02d do usuario: <%s>",
                (int)timestamp, (int)((timestamp - (int)timestamp) * 1000),
                child_msg_num, input);
        write(active_fd[1], child_msg, sizeof(child_msg));
        child_msg_num++;
      } while (timestamp < 30);
    } else {
      close(active_fd[1]);
      do {
        timeout.tv_sec = 5;
        timeout.tv_usec = 0;
        FD_ZERO(&set);
        FD_SET(lazy_fd[0], &set);
        FD_SET(active_fd[0], &set);
        ret = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
        if (ret > 0) {
          if (FD_ISSET(lazy_fd[0], &set)) {
            if (read(lazy_fd[0], buffer, sizeof(buffer))) {
              gettimeofday(&time_end, NULL);
              timestamp = time_diff(time_end, time_start);
              sprintf(output, "0:%02d.%03d: %s\n", (int)timestamp,
                      (int)((timestamp - (int)timestamp) * 1000), buffer);
              write_output(output);
            }
          }
          if (FD_ISSET(active_fd[0], &set)) {
            if (read(active_fd[0], buffer, sizeof(buffer))) {
              gettimeofday(&time_end, NULL);
              timestamp =
                  (double)(time_end.tv_sec - time_start.tv_sec) +
                  ((double)time_end.tv_usec - (double)time_start.tv_usec) /
                      1000000.0f;
              sprintf(output, "0:%02d.%03d: %s\n", (int)timestamp,
                      (int)((timestamp - (int)timestamp) * 1000), buffer);
              write_output(output);
            }
          }
        }
      } while (ret != 0 && timestamp < 30);
      wait(NULL);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x590,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x578(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,%edi
call   10c0 <srand@plt>
movl   $0x5,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
lea    0xd42(%rip),%rdi
lea    0xd46(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x580(%rbp)
cmpq   $0x0,-0x580(%rbp)
jne    130d <main+0x8d>
lea    0xd27(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    -0x580(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x60(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1341 <main+0xc1>
lea    0xd1f(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jge    1361 <main+0xe1>
mov    $0x1,%edi
call   1150 <exit@plt>
cmpq   $0x0,-0x50(%rbp)
jne    142d <main+0x1ad>
mov    -0x60(%rbp),%edi
call   1090 <close@plt>
mov    $0x0,%al
call   11a0 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1170 <sleep@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1120 <time_diff@plt>
movsd  %xmm0,-0x48(%rbp)
lea    -0x170(%rbp),%rdi
cvttsd2si -0x48(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
cvttsd2si -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xc2b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x578(%rbp),%r8d
lea    0xc73(%rip),%rsi
mov    $0x0,%al
call   1140 <sprintf@plt>
mov    -0x5c(%rbp),%edi
lea    -0x170(%rbp),%rsi
mov    $0x100,%edx
call   1040 <write@plt>
mov    -0x578(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x578(%rbp)
movsd  0xbf3(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
ja     1374 <main+0xf4>
jmp    17bd <main+0x53d>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
lea    -0x68(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    145d <main+0x1dd>
lea    0xc03(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    $0x0,%al
call   1190 <fork@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jge    147d <main+0x1fd>
mov    $0x1,%edi
call   1150 <exit@plt>
cmpq   $0x0,-0x58(%rbp)
jne    1585 <main+0x305>
mov    -0x68(%rbp),%edi
call   1090 <close@plt>
lea    -0x370(%rbp),%rdi
mov    0x2b4a(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   10d0 <fgets@plt>
lea    -0x370(%rbp),%rdi
lea    -0x270(%rbp),%rdx
lea    0xbce(%rip),%rsi
call   1110 <sscanf@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x40(%rbp),%eax
sub    -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
cvtsi2sdq -0x28(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xb15(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x170(%rbp),%rdi
cvttsd2si -0x48(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
cvttsd2si -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xada(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x578(%rbp),%r8d
lea    -0x270(%rbp),%r9
lea    0xb52(%rip),%rsi
mov    $0x0,%al
call   1140 <sprintf@plt>
mov    -0x64(%rbp),%edi
lea    -0x170(%rbp),%rsi
mov    $0x100,%edx
call   1040 <write@plt>
mov    -0x578(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x578(%rbp)
movsd  0xa9b(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
ja     1490 <main+0x210>
jmp    17b3 <main+0x533>
mov    -0x64(%rbp),%edi
call   1090 <close@plt>
movl   $0x5,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x574(%rbp),%rdi
call   10f0 <FD_ZERO@plt>
mov    -0x60(%rbp),%edi
lea    -0x574(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    -0x68(%rbp),%edi
lea    -0x574(%rbp),%rsi
call   1160 <FD_SET@plt>
mov    0x2a0b(%rip),%rax
mov    (%rax),%edi
lea    -0x574(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1100 <select@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jle    176f <main+0x4ef>
mov    -0x60(%rbp),%edi
lea    -0x574(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     16a3 <main+0x423>
mov    -0x60(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    $0x100,%edx
call   10b0 <read@plt>
cmp    $0x0,%rax
je     169e <main+0x41e>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1120 <time_diff@plt>
movsd  %xmm0,-0x48(%rbp)
lea    -0x570(%rbp),%rdi
cvttsd2si -0x48(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
cvttsd2si -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0x98b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
lea    -0x470(%rbp),%r8
lea    0xa36(%rip),%rsi
mov    $0x0,%al
call   1140 <sprintf@plt>
lea    -0x570(%rbp),%rdi
call   1030 <write_output@plt>
jmp    16a3 <main+0x423>
mov    -0x68(%rbp),%edi
lea    -0x574(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     176a <main+0x4ea>
mov    -0x68(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    $0x100,%edx
call   10b0 <read@plt>
cmp    $0x0,%rax
je     1765 <main+0x4e5>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x40(%rbp),%eax
sub    -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
cvtsi2sdq -0x28(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0x8ff(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x570(%rbp),%rdi
cvttsd2si -0x48(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
cvttsd2si -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0x8c4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
lea    -0x470(%rbp),%r8
lea    0x96f(%rip),%rsi
mov    $0x0,%al
call   1140 <sprintf@plt>
lea    -0x570(%rbp),%rdi
call   1030 <write_output@plt>
jmp    176a <main+0x4ea>
jmp    176f <main+0x4ef>
jmp    1774 <main+0x4f4>
xor    %eax,%eax
cmpl   $0x0,-0x6c(%rbp)
mov    %al,-0x581(%rbp)
je     179c <main+0x51c>
movsd  0x882(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
seta   %al
mov    %al,-0x581(%rbp)
mov    -0x581(%rbp),%al
test   $0x1,%al
jne    158d <main+0x30d>
xor    %eax,%eax
mov    %eax,%edi
call   1180 <wait@plt>
jmp    17b8 <main+0x538>
jmp    17bd <main+0x53d>
jmp    17c2 <main+0x542>
xor    %eax,%eax
add    $0x590,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x378,%rsp
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,%edi
call   10c0 <srand@plt>
lea    0x48(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
lea    0xd66(%rip),%rdi
lea    0xd6a(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     1722 <main+0x4a2>
mov    %rax,%rdi
call   1070 <fclose@plt>
lea    0x10(%rsp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
je     170f <main+0x48f>
xor    %eax,%eax
call   1190 <fork@plt>
test   %rax,%rax
js     1718 <main+0x498>
je     151f <main+0x29f>
mov    0x14(%rsp),%edi
call   1090 <close@plt>
lea    0x8(%rsp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
je     170f <main+0x48f>
xor    %eax,%eax
call   1190 <fork@plt>
test   %rax,%rax
js     1718 <main+0x498>
je     15f9 <main+0x379>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    0x48(%rsp),%eax
mov    %eax,0x28(%rsp)
mov    0x50(%rsp),%rax
mov    %rax,0x60(%rsp)
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x58(%rsp)
lea    0x6c(%rsp),%rbx
mov    0x2c7c(%rip),%r15
lea    0x70(%rsp),%r12
lea    0x170(%rsp),%rbp
lea    0x270(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x5,0x70(%rsp)
movq   $0x0,0x78(%rsp)
mov    %rbx,%rdi
call   10f0 <FD_ZERO@plt>
mov    0x10(%rsp),%edi
mov    %rbx,%rsi
call   1160 <FD_SET@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1160 <FD_SET@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1100 <select@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    14fa <main+0x27a>
mov    0x10(%rsp),%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     145a <main+0x1da>
mov    0x10(%rsp),%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   10b0 <read@plt>
test   %rax,%rax
je     145a <main+0x1da>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x18(%rsp),%edi
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%edx
mov    0x60(%rsp),%rcx
call   1120 <time_diff@plt>
movapd %xmm0,%xmm1
cvttsd2si %xmm0,%edx
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm1,0x30(%rsp)
subsd  %xmm0,%xmm1
mulsd  0xbc6(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %r13,%rdi
lea    0xc40(%rip),%rsi
mov    %rbp,%r8
xor    %eax,%eax
call   1140 <sprintf@plt>
mov    %r13,%rdi
call   1030 <write_output@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     14fa <main+0x27a>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   10b0 <read@plt>
test   %rax,%rax
je     14fa <main+0x27a>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x18(%rsp),%eax
sub    0x28(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x20(%rsp),%xmm1
subsd  0x58(%rsp),%xmm1
divsd  0xb50(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm1,0x30(%rsp)
subsd  %xmm0,%xmm1
mulsd  0xb26(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %r13,%rdi
lea    0xba0(%rip),%rsi
mov    %rbp,%r8
xor    %eax,%eax
call   1140 <sprintf@plt>
mov    %r13,%rdi
call   1030 <write_output@plt>
test   %r14d,%r14d
je     1513 <main+0x293>
movsd  0xb09(%rip),%xmm0
ucomisd 0x30(%rsp),%xmm0
ja     1380 <main+0x100>
xor    %edi,%edi
call   1180 <wait@plt>
jmp    16fb <main+0x47b>
mov    0x10(%rsp),%edi
call   1090 <close@plt>
mov    0x48(%rsp),%r14d
mov    $0x1,%ebp
mov    0x50(%rsp),%r13
lea    0x18(%rsp),%r15
lea    0xae2(%rip),%r12
lea    0x170(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11a0 <rand@plt>
movslq %eax,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
call   1170 <sleep@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x18(%rsp),%edi
mov    0x20(%rsp),%rsi
mov    %r14d,%edx
mov    %r13,%rcx
call   1120 <time_diff@plt>
movapd %xmm0,0x30(%rsp)
cvttsd2si %xmm0,%edx
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
mulsd  0xa48(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%r8d
xor    %eax,%eax
call   1140 <sprintf@plt>
mov    0x14(%rsp),%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1050 <write@plt>
add    $0x1,%ebp
movsd  0xa28(%rip),%xmm0
ucomisd 0x30(%rsp),%xmm0
ja     1550 <main+0x2d0>
jmp    16fb <main+0x47b>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0x48(%rsp),%r12d
mov    $0x1,%ebx
cvtsi2sdq 0x50(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0x70(%rsp),%r15
lea    0x270(%rsp),%rbp
lea    0xa2f(%rip),%r13
lea    0x170(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x29a1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x100,%esi
call   10d0 <fgets@plt>
mov    %r15,%rdi
lea    0x9f4(%rip),%rsi
mov    %rbp,%rdx
call   1110 <sscanf@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x18(%rsp),%eax
sub    %r12d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x20(%rsp),%xmm1
subsd  0x28(%rsp),%xmm1
divsd  0x96e(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
cvttsd2si %xmm1,%edx
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
mulsd  0x944(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%r8d
mov    %rbp,%r9
xor    %eax,%eax
call   1140 <sprintf@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    $0x100,%edx
call   1050 <write@plt>
add    $0x1,%ebx
movsd  0x921(%rip),%xmm0
ucomisd 0x30(%rsp),%xmm0
ja     1640 <main+0x3c0>
xor    %eax,%eax
add    $0x378,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x983(%rip),%rdi
jmp    1729 <main+0x4a9>
mov    $0x1,%edi
call   1150 <exit@plt>
lea    0x97c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [11 x i8] c"output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [44 x i8] c"Arquivo n\C3\A3o pode ser aberto. Abortando...\0A\00"
@.str.3 = [13 x i8] c"Pipe failed\0A\00"
@.str.4 = [47 x i8] c"0:%02d.%03d: Mensagem %02d do filho dorminhoco\00"
@stdin = global i32 0
@.str.5 = [8 x i8] c"%99[^\0A]\00"
@.str.6 = [44 x i8] c"0:%02d.%03d: Mensagem %02d do usuario: <%s>\00"
@FD_SETSIZE = global i32 0
@.str.7 = [17 x i8] c"0:%02d.%03d: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca double
%10 = alloca i64
%11 = alloca i64
%12 = alloca [2 x i32]
%13 = alloca [2 x i32]
%14 = alloca i32
%15 = alloca i32
%16 = alloca [256 x i8]
%17 = alloca [256 x i8]
%18 = alloca [256 x i8]
%19 = alloca [256 x i8]
%20 = alloca [256 x i8]
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %22
%24 = call i32 @time(i32* null)
%25 = call i32 @srand(i32 %24)
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i32 5, i32* %26
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i64 0, i64* %27
%28 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%29 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %23
%30 = load i32*, i32** %23
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %2
%36 = load i32*, i32** %23
%37 = call i32 @fclose(i32* %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%39 = call i32 @pipe(i32* %38)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %35
%45 = call i64 (...) @fork()
store i64 %45, i64* %10
%46 = load i64, i64* %10
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %44
%51 = load i64, i64* %10
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %95
53: ; preds = %50
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%55 = load i32, i32* %54
%56 = call i32 @close(i32 %55)
br label %57
57: ; preds = %91, %53
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 3
%60 = call i32 @sleep(i32 %59)
%61 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%62 = bitcast %struct.timeval* %8 to { i32, i64 }*
%63 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %62, i32 0, i32 0
%64 = load i32, i32* %63
%65 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %62, i32 0, i32 1
%66 = load i64, i64* %65
%67 = bitcast %struct.timeval* %7 to { i32, i64 }*
%68 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %67, i32 0, i32 1
%71 = load i64, i64* %70
%72 = call double @time_diff(i32 %64, i64 %66, i32 %69, i64 %71)
store double %72, double* %9
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%74 = load double, double* %9
%75 = fptosi double %74 to i32
%76 = load double, double* %9
%77 = load double, double* %9
%78 = fptosi double %77 to i32
%79 = sitofp i32 %78 to double
%80 = fsub double %76, %79
%81 = fmul double %80, 1.000000e+03
%82 = fptosi double %81 to i32
%83 = load i32, i32* %22
%84 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %75, i32 %82, i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%86 = load i32, i32* %85
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%88 = call i32 @write(i32 %86, i8* %87, i32 256)
%89 = load i32, i32* %22
%90 = add nsw i32 %89, 1
store i32 %90, i32* %22
br label %91
91: ; preds = %57
%92 = load double, double* %9
%93 = fcmp olt double %92, 3.000000e+01
br i1 %93, label %57, label %94
94: ; preds = %91
br label %278
95: ; preds = %50
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%97 = load i32, i32* %96
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%100 = call i32 @pipe(i32* %99)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %95
%103 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %95
%106 = call i64 (...) @fork()
store i64 %106, i64* %11
%107 = load i64, i64* %11
%108 = icmp slt i64 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %105
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %105
%112 = load i64, i64* %11
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %164
114: ; preds = %111
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%116 = load i32, i32* %115
%117 = call i32 @close(i32 %116)
br label %118
118: ; preds = %160, %114
%119 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%120 = load i32, i32* @stdin
%121 = call i32 @fgets(i8* %119, i32 256, i32 %120)
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%123 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%124 = call i32 @sscanf(i8* %122, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %123)
%125 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%126 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%127 = load i32, i32* %126
%128 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%129 = load i32, i32* %128
%130 = sub nsw i32 %127, %129
%131 = sitofp i32 %130 to double
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%133 = load i64, i64* %132
%134 = sitofp i64 %133 to double
%135 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%136 = load i64, i64* %135
%137 = sitofp i64 %136 to double
%138 = fsub double %134, %137
%139 = fdiv double %138, 1.000000e+06
%140 = fadd double %131, %139
store double %140, double* %9
%141 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%142 = load double, double* %9
%143 = fptosi double %142 to i32
%144 = load double, double* %9
%145 = load double, double* %9
%146 = fptosi double %145 to i32
%147 = sitofp i32 %146 to double
%148 = fsub double %144, %147
%149 = fmul double %148, 1.000000e+03
%150 = fptosi double %149 to i32
%151 = load i32, i32* %22
%152 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%153 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %141, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %143, i32 %150, i32 %151, i8* %152)
%154 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%155 = load i32, i32* %154
%156 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%157 = call i32 @write(i32 %155, i8* %156, i32 256)
%158 = load i32, i32* %22
%159 = add nsw i32 %158, 1
store i32 %159, i32* %22
br label %160
160: ; preds = %118
%161 = load double, double* %9
%162 = fcmp olt double %161, 3.000000e+01
br i1 %162, label %118, label %163
163: ; preds = %160
br label %276
164: ; preds = %111
%165 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%166 = load i32, i32* %165
%167 = call i32 @close(i32 %166)
br label %168
168: ; preds = %272, %164
%169 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i32 5, i32* %169
%170 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i64 0, i64* %170
%171 = call i32 @FD_ZERO(i32* %21)
%172 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%173 = load i32, i32* %172
%174 = call i32 @FD_SET(i32 %173, i32* %21)
%175 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%176 = load i32, i32* %175
%177 = call i32 @FD_SET(i32 %176, i32* %21)
%178 = load i32, i32* @FD_SETSIZE
%179 = call i32 @select(i32 %178, i32* %21, i32* null, i32* null, %struct.timeval* %6)
store i32 %179, i32* %14
%180 = load i32, i32* %14
%181 = icmp sgt i32 %180, 0
br i1 %181, label %182, label %265
182: ; preds = %168
%183 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%184 = load i32, i32* %183
%185 = call i64 @FD_ISSET(i32 %184, i32* %21)
%186 = icmp ne i64 %185, 0
br i1 %186, label %187, label %221
187: ; preds = %182
%188 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%189 = load i32, i32* %188
%190 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%191 = call i64 @read(i32 %189, i8* %190, i32 256)
%192 = icmp ne i64 %191, 0
br i1 %192, label %193, label %220
193: ; preds = %187
%194 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%195 = bitcast %struct.timeval* %8 to { i32, i64 }*
%196 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %195, i32 0, i32 0
%197 = load i32, i32* %196
%198 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %195, i32 0, i32 1
%199 = load i64, i64* %198
%200 = bitcast %struct.timeval* %7 to { i32, i64 }*
%201 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %200, i32 0, i32 0
%202 = load i32, i32* %201
%203 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %200, i32 0, i32 1
%204 = load i64, i64* %203
%205 = call double @time_diff(i32 %197, i64 %199, i32 %202, i64 %204)
store double %205, double* %9
%206 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%207 = load double, double* %9
%208 = fptosi double %207 to i32
%209 = load double, double* %9
%210 = load double, double* %9
%211 = fptosi double %210 to i32
%212 = sitofp i32 %211 to double
%213 = fsub double %209, %212
%214 = fmul double %213, 1.000000e+03
%215 = fptosi double %214 to i32
%216 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%217 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %206, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %208, i32 %215, i8* %216)
%218 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%219 = call i32 @write_output(i8* %218)
br label %220
220: ; preds = %193, %187
br label %221
221: ; preds = %220, %182
%222 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%223 = load i32, i32* %222
%224 = call i64 @FD_ISSET(i32 %223, i32* %21)
%225 = icmp ne i64 %224, 0
br i1 %225, label %226, label %264
226: ; preds = %221
%227 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%228 = load i32, i32* %227
%229 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%230 = call i64 @read(i32 %228, i8* %229, i32 256)
%231 = icmp ne i64 %230, 0
br i1 %231, label %232, label %263
232: ; preds = %226
%233 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%234 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%235 = load i32, i32* %234
%236 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%237 = load i32, i32* %236
%238 = sub nsw i32 %235, %237
%239 = sitofp i32 %238 to double
%240 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%241 = load i64, i64* %240
%242 = sitofp i64 %241 to double
%243 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%244 = load i64, i64* %243
%245 = sitofp i64 %244 to double
%246 = fsub double %242, %245
%247 = fdiv double %246, 1.000000e+06
%248 = fadd double %239, %247
store double %248, double* %9
%249 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%250 = load double, double* %9
%251 = fptosi double %250 to i32
%252 = load double, double* %9
%253 = load double, double* %9
%254 = fptosi double %253 to i32
%255 = sitofp i32 %254 to double
%256 = fsub double %252, %255
%257 = fmul double %256, 1.000000e+03
%258 = fptosi double %257 to i32
%259 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%260 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %249, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %251, i32 %258, i8* %259)
%261 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%262 = call i32 @write_output(i8* %261)
br label %263
263: ; preds = %232, %226
br label %264
264: ; preds = %263, %221
br label %265
265: ; preds = %264, %168
br label %266
266: ; preds = %265
%267 = load i32, i32* %14
%268 = icmp ne i32 %267, 0
br i1 %268, label %269, label %272
269: ; preds = %266
%270 = load double, double* %9
%271 = fcmp olt double %270, 3.000000e+01
br label %272
272: ; preds = %269, %266
%273 = phi i1 [ false, %266 ], [ %271, %269 ]
br i1 %273, label %168, label %274
274: ; preds = %272
%275 = call i32 @wait(i32* null)
br label %276
276: ; preds = %274, %163
br label %277
277: ; preds = %276
br label %278
278: ; preds = %277, %94
br label %279
279: ; preds = %278
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [11 x i8] c"output.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.4 = [47 x i8] c"0:%02d.%03d: Mensagem %02d do filho dorminhoco\00"
@stdin = global i32 0
@.str.5 = [8 x i8] c"%99[^\0A]\00"
@.str.6 = [44 x i8] c"0:%02d.%03d: Mensagem %02d do usuario: <%s>\00"
@FD_SETSIZE = global i32 0
@.str.7 = [17 x i8] c"0:%02d.%03d: %s\0A\00"
@str.8 = [12 x i8] c"Pipe failed\00"
@str.9 = [43 x i8] c"Arquivo n\C3\A3o pode ser aberto. Abortando...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca i32
%14 = bitcast %struct.timeval* %3 to i8*
%15 = bitcast %struct.timeval* %4 to i8*
%16 = bitcast %struct.timeval* %5 to i8*
%17 = bitcast [2 x i32]* %6 to i8*
%18 = bitcast [2 x i32]* %7 to i8*
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%24 = bitcast i32* %13 to i8*
%25 = tail call i32 @time(i32* null)
%26 = tail call i32 @srand(i32 %25)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%29 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%30 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %2
%36 = tail call i32 @fclose(i32* %30)
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%38 = call i32 @pipe(i32* %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %35
%44 = call i64 (...) @fork()
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %43
%49 = icmp eq i64 %44, 0
br i1 %49, label %50, label %79
50: ; preds = %48
%51 = load i32, i32* %37
%52 = call i32 @close(i32 %51)
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%58 = load i64, i64* %57
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
br label %60
60: ; preds = %60, %50
%61 = phi i32 [ 1, %50 ], [ %77, %60 ]
%62 = call i32 (...) @rand()
%63 = srem i32 %62, 3
%64 = call i32 @sleep(i32 %63)
%65 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%66 = load i32, i32* %53
%67 = load i64, i64* %54
%68 = call double @time_diff(i32 %66, i64 %67, i32 %56, i64 %58)
%69 = fptosi double %68 to i32
%70 = sitofp i32 %69 to double
%71 = fsub double %68, %70
%72 = fmul double %71, 1.000000e+03
%73 = fptosi double %72 to i32
%74 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %69, i32 %73, i32 %61)
%75 = load i32, i32* %59
%76 = call i32 @write(i32 %75, i8* %19, i32 256)
%77 = add nuw nsw i32 %61, 1
%78 = fcmp olt double %68, 3.000000e+01
br i1 %78, label %60, label %205
79: ; preds = %48
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%81 = load i32, i32* %80
%82 = call i32 @close(i32 %81)
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%84 = call i32 @pipe(i32* %83)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %89
86: ; preds = %79
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %79
%90 = call i64 (...) @fork()
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %89
%95 = icmp eq i64 %90, 0
br i1 %95, label %96, label %131
96: ; preds = %94
%97 = load i32, i32* %83
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%104 = load i64, i64* %103
%105 = sitofp i64 %104 to double
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
br label %107
107: ; preds = %107, %96
%108 = phi i32 [ 1, %96 ], [ %129, %107 ]
%109 = load i32, i32* @stdin
%110 = call i32 @fgets(i8* %21, i32 256, i32 %109)
%111 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%112 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%113 = load i32, i32* %99
%114 = sub nsw i32 %113, %101
%115 = sitofp i32 %114 to double
%116 = load i64, i64* %102
%117 = sitofp i64 %116 to double
%118 = fsub double %117, %105
%119 = fdiv double %118, 1.000000e+06
%120 = fadd double %119, %115
%121 = fptosi double %120 to i32
%122 = sitofp i32 %121 to double
%123 = fsub double %120, %122
%124 = fmul double %123, 1.000000e+03
%125 = fptosi double %124 to i32
%126 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %121, i32 %125, i32 %108, i8* %20)
%127 = load i32, i32* %106
%128 = call i32 @write(i32 %127, i8* %19, i32 256)
%129 = add nuw nsw i32 %108, 1
%130 = fcmp olt double %120, 3.000000e+01
br i1 %130, label %107, label %205
131: ; preds = %94
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%133 = load i32, i32* %132
%134 = call i32 @close(i32 %133)
%135 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%136 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%137 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%138 = load i32, i32* %137
%139 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%140 = load i64, i64* %139
%141 = sitofp i64 %140 to double
br label %142
142: ; preds = %198, %131
%143 = phi double [ undef, %131 ], [ %199, %198 ]
store i32 5, i32* %27
store i64 0, i64* %28
%144 = call i32 @FD_ZERO(i32* %13)
%145 = load i32, i32* %37
%146 = call i32 @FD_SET(i32 %145, i32* %13)
%147 = load i32, i32* %83
%148 = call i32 @FD_SET(i32 %147, i32* %13)
%149 = load i32, i32* @FD_SETSIZE
%150 = call i32 @select(i32 %149, i32* %13, i32* null, i32* null, %struct.timeval* %3)
%151 = icmp sgt i32 %150, 0
br i1 %151, label %152, label %198
152: ; preds = %142
%153 = load i32, i32* %37
%154 = call i64 @FD_ISSET(i32 %153, i32* %13)
%155 = icmp eq i64 %154, 0
br i1 %155, label %172, label %156
156: ; preds = %152
%157 = load i32, i32* %37
%158 = call i64 @read(i32 %157, i8* %22, i32 256)
%159 = icmp eq i64 %158, 0
br i1 %159, label %172, label %160
160: ; preds = %156
%161 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%162 = load i32, i32* %135
%163 = load i64, i64* %136
%164 = call double @time_diff(i32 %162, i64 %163, i32 %138, i64 %140)
%165 = fptosi double %164 to i32
%166 = sitofp i32 %165 to double
%167 = fsub double %164, %166
%168 = fmul double %167, 1.000000e+03
%169 = fptosi double %168 to i32
%170 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %23, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %165, i32 %169, i8* %22)
%171 = call i32 @write_output(i8* %23)
br label %172
172: ; preds = %156, %160, %152
%173 = phi double [ %164, %160 ], [ %143, %156 ], [ %143, %152 ]
%174 = load i32, i32* %83
%175 = call i64 @FD_ISSET(i32 %174, i32* %13)
%176 = icmp eq i64 %175, 0
br i1 %176, label %198, label %177
177: ; preds = %172
%178 = load i32, i32* %83
%179 = call i64 @read(i32 %178, i8* %22, i32 256)
%180 = icmp eq i64 %179, 0
br i1 %180, label %198, label %181
181: ; preds = %177
%182 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%183 = load i32, i32* %135
%184 = sub nsw i32 %183, %138
%185 = sitofp i32 %184 to double
%186 = load i64, i64* %136
%187 = sitofp i64 %186 to double
%188 = fsub double %187, %141
%189 = fdiv double %188, 1.000000e+06
%190 = fadd double %189, %185
%191 = fptosi double %190 to i32
%192 = sitofp i32 %191 to double
%193 = fsub double %190, %192
%194 = fmul double %193, 1.000000e+03
%195 = fptosi double %194 to i32
%196 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %23, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %191, i32 %195, i8* %22)
%197 = call i32 @write_output(i8* %23)
br label %198
198: ; preds = %142, %177, %181, %172
%199 = phi double [ %190, %181 ], [ %173, %177 ], [ %173, %172 ], [ %143, %142 ]
%200 = icmp ne i32 %150, 0
%201 = fcmp olt double %199, 3.000000e+01
%202 = select i1 %200, i1 %201, i1 false
br i1 %202, label %142, label %203
203: ; preds = %198
%204 = call i32 @wait(i32* null)
br label %205
205: ; preds = %107, %60, %203
ret i32 0
}