#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SHM_RND;
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ getpid();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ lock(int, int);
int /*<<< orphan*/ memcpy(void *, int *, int);
int open(char const *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, void *, int);
void *shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int shmdt(void *);
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlock(int, int);
int writer_to_shared_memory(int shm_id, int sem_id, const char *filename) {
  int ret_code = EXIT_SUCCESS;
  void *shared_memory = shmat(shm_id, NULL, SHM_RND);
  if (shared_memory == (void *)(-1)) {
    {
      char __tb[101];
      time_t t = time(NULL);
      struct tm *tmp = localtime(&t);
      strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
      printf("%s [pid=%d]", __tb, (int)getpid());
      printf("\x1b[31m");
      printf(" ERROR! ");
      printf("\x1b[0m");
      printf("Shared memory wan not attached");
      printf(" (%s)\n", strerror(errno));
      fflush(stdout);
    };
    ret_code = EXIT_FAILURE;
    goto writer_free_section;
  } else {
    char __tb[101];
    time_t t = time(NULL);
    struct tm *tmp = localtime(&t);
    strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
    printf("%s [pid=%d] ", __tb, (int)getpid());
    printf("shared memory was attached to writer process");
    printf("\n");
    fflush(stdout);
  };
  int input_descriptor = open(filename, O_RDONLY, 0666);
  if (input_descriptor == -1) {
    {
      char __tb[101];
      time_t t = time(NULL);
      struct tm *tmp = localtime(&t);
      strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
      printf("%s [pid=%d]", __tb, (int)getpid());
      printf("\x1b[31m");
      printf(" ERROR! ");
      printf("\x1b[0m");
      printf("\"%s\" was not opened for read only", filename);
      printf(" (%s)\n", strerror(errno));
      fflush(stdout);
    };
    ret_code = EXIT_FAILURE;
    goto writer_free_section;
  } else {
    char __tb[101];
    time_t t = time(NULL);
    struct tm *tmp = localtime(&t);
    strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
    printf("%s [pid=%d] ", __tb, (int)getpid());
    printf("\"%s\" opened for read only", filename);
    printf("\n");
    fflush(stdout);
  };
  int work_path = 0;
  int data_transfer_size;
  void *buffer = shared_memory;
  {
    char __tb[101];
    time_t t = time(NULL);
    struct tm *tmp = localtime(&t);
    strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
    printf("%s [pid=%d] ", __tb, (int)getpid());
    printf("writing process started");
    printf("\n");
    fflush(stdout);
  };
  while (1) {
    lock(sem_id, (2 * work_path + 1));
    data_transfer_size =
        read(input_descriptor, buffer + sizeof(int), 65536 - sizeof(int));
    if (data_transfer_size == -1) {
      {
        char __tb[101];
        time_t t = time(NULL);
        struct tm *tmp = localtime(&t);
        strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
        printf("%s [pid=%d]", __tb, (int)getpid());
        printf("\x1b[31m");
        printf(" ERROR! ");
        printf("\x1b[0m");
        printf("Writer, read error, work_path=%d", work_path);
        printf(" (%s)\n", strerror(errno));
        fflush(stdout);
      };
      ret_code = EXIT_FAILURE;
      goto writer_free_section;
    }
    memcpy(buffer, &data_transfer_size, sizeof(int));
    {
      char __tb[101];
      time_t t = time(NULL);
      struct tm *tmp = localtime(&t);
      strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
      printf("%s [pid=%d] ", __tb, (int)getpid());
      printf("%d bytes was copied from \"%s\" to buffer[%d]",
             data_transfer_size + (int)sizeof(int), filename, work_path);
      printf("\n");
      fflush(stdout);
    };
    unlock(sem_id, (2 * work_path));
    if (data_transfer_size <= 0)
      break;
    work_path = (work_path + 1) % 16;
    buffer = shared_memory + (work_path * 65536);
  }
writer_free_section : {
  char __tb[101];
  time_t t = time(NULL);
  struct tm *tmp = localtime(&t);
  strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
  printf("%s [pid=%d] ", __tb, (int)getpid());
  printf("writing process finished");
  printf("\n");
  fflush(stdout);
};
  if (close(input_descriptor) == -1) {
    {
      char __tb[101];
      time_t t = time(NULL);
      struct tm *tmp = localtime(&t);
      strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
      printf("%s [pid=%d]", __tb, (int)getpid());
      printf("\x1b[31m");
      printf(" ERROR! ");
      printf("\x1b[0m");
      printf("\"%s\" was not closed", filename);
      printf(" (%s)\n", strerror(errno));
      fflush(stdout);
    };
  } else {
    char __tb[101];
    time_t t = time(NULL);
    struct tm *tmp = localtime(&t);
    strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
    printf("%s [pid=%d] ", __tb, (int)getpid());
    printf("\"%s\" was closed from read only mode", filename);
    printf("\n");
    fflush(stdout);
  };
  if (shmdt(shared_memory) == -1) {
    {
      char __tb[101];
      time_t t = time(NULL);
      struct tm *tmp = localtime(&t);
      strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
      printf("%s [pid=%d]", __tb, (int)getpid());
      printf("\x1b[31m");
      printf(" ERROR! ");
      printf("\x1b[0m");
      printf("Shared memory was not detached");
      printf(" (%s)\n", strerror(errno));
      fflush(stdout);
    };
  } else {
    char __tb[101];
    time_t t = time(NULL);
    struct tm *tmp = localtime(&t);
    strftime(__tb, 100, "%d/%m/%Y %H:%M:%S ", tmp);
    printf("%s [pid=%d] ", __tb, (int)getpid());
    printf("shared memory was detached from writer");
    printf("\n");
    fflush(stdout);
  };
  return ret_code;
}


x86 assembly (clang, -O0):
<writer_to_shared_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x690,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1100 <shmat@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x20(%rbp)
jne    131e <writer_to_shared_memory+0x12e>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x94(%rbp)
lea    -0x94(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    $0x64,%esi
lea    0xd89(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x638(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x638(%rbp),%rsi
mov    %eax,%edx
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1858 <writer_to_shared_memory+0x668>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x114(%rbp)
lea    -0x114(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rcx
mov    $0x64,%esi
lea    0xca6(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x640(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x640(%rbp),%rsi
mov    %eax,%edx
lea    0xcd5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x10(%rbp),%rdi
mov    0x2c28(%rip),%rax
mov    (%rax),%esi
mov    $0x1b6,%edx
call   10f0 <open@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0xffffffff,-0x124(%rbp)
jne    14c6 <writer_to_shared_memory+0x2d6>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x194(%rbp)
lea    -0x194(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x1a0(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0x1a0(%rbp),%rcx
mov    $0x64,%esi
lea    0xbe5(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x190(%rbp),%rax
mov    %rax,-0x648(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x648(%rbp),%rsi
mov    %eax,%edx
lea    0xbce(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xbcc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xbc4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2b41(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xbb2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    0x2b0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1858 <writer_to_shared_memory+0x668>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x214(%rbp)
lea    -0x214(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x220(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x220(%rbp),%rcx
mov    $0x64,%esi
lea    0xafe(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x210(%rbp),%rax
mov    %rax,-0x650(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x650(%rbp),%rsi
mov    %eax,%edx
lea    0xb2d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xb77(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb0b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2a66(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
movl   $0x0,-0x224(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x230(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x2a4(%rbp)
lea    -0x2a4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x2b0(%rbp)
lea    -0x2a0(%rbp),%rdi
mov    -0x2b0(%rbp),%rcx
mov    $0x64,%esi
lea    0xa4e(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x2a0(%rbp),%rax
mov    %rax,-0x658(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x658(%rbp),%rsi
mov    %eax,%edx
lea    0xa7d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xae5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xa5f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x29ba(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x8(%rbp),%edi
mov    -0x224(%rbp),%esi
shl    $0x1,%esi
add    $0x1,%esi
call   1050 <lock@plt>
mov    -0x124(%rbp),%edi
mov    -0x230(%rbp),%rsi
add    $0x4,%rsi
mov    $0xfffc,%edx
call   10a0 <read@plt>
mov    %eax,-0x228(%rbp)
cmpl   $0xffffffff,-0x228(%rbp)
jne    1738 <writer_to_shared_memory+0x548>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x324(%rbp)
lea    -0x324(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x330(%rbp)
lea    -0x320(%rbp),%rdi
mov    -0x330(%rbp),%rcx
mov    $0x64,%esi
lea    0x975(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x320(%rbp),%rax
mov    %rax,-0x660(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x660(%rbp),%rsi
mov    %eax,%edx
lea    0x95e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x95c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x954(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x94f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x224(%rbp),%esi
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x28cf(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0x940(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x28a0(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    0x289a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1858 <writer_to_shared_memory+0x668>
mov    -0x230(%rbp),%rdi
lea    -0x228(%rbp),%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x3a4(%rbp)
lea    -0x3a4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x3b0(%rbp)
lea    -0x3a0(%rbp),%rdi
mov    -0x3b0(%rbp),%rcx
mov    $0x64,%esi
lea    0x874(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x3a0(%rbp),%rax
mov    %rax,-0x668(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x668(%rbp),%rsi
mov    %eax,%edx
lea    0x8a3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x228(%rbp),%esi
add    $0x4,%esi
mov    -0x10(%rbp),%rdx
mov    -0x224(%rbp),%ecx
lea    0x931(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x872(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x27cd(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x8(%rbp),%edi
mov    -0x224(%rbp),%esi
shl    $0x1,%esi
call   1040 <unlock@plt>
cmpl   $0x0,-0x228(%rbp)
jg     181d <writer_to_shared_memory+0x62d>
jmp    1853 <writer_to_shared_memory+0x663>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x224(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x224(%rbp),%ecx
shl    $0x10,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x230(%rbp)
jmp    160d <writer_to_shared_memory+0x41d>
jmp    1858 <writer_to_shared_memory+0x668>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x424(%rbp)
lea    -0x424(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x430(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x430(%rbp),%rcx
mov    $0x64,%esi
lea    0x76c(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x670(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x670(%rbp),%rsi
mov    %eax,%edx
lea    0x79b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x868(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x77d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x26d8(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x124(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    19de <writer_to_shared_memory+0x7ee>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x4a4(%rbp)
lea    -0x4a4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x4b0(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x4b0(%rbp),%rcx
mov    $0x64,%esi
lea    0x6c1(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x4a0(%rbp),%rax
mov    %rax,-0x678(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x678(%rbp),%rsi
mov    %eax,%edx
lea    0x6aa(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x6a8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x6a0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x69b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0x7a8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x261d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0x68e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x25ee(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    1a79 <writer_to_shared_memory+0x889>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x524(%rbp)
lea    -0x524(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x530(%rbp)
lea    -0x520(%rbp),%rdi
mov    -0x530(%rbp),%rcx
mov    $0x64,%esi
lea    0x5e6(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x520(%rbp),%rax
mov    %rax,-0x680(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x680(%rbp),%rsi
mov    %eax,%edx
lea    0x615(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0x70b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x5f3(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x254e(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x20(%rbp),%rdi
call   1060 <shmdt@plt>
cmp    $0xffffffff,%eax
jne    1b62 <writer_to_shared_memory+0x972>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x5a4(%rbp)
lea    -0x5a4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x5b0(%rbp)
lea    -0x5a0(%rbp),%rdi
mov    -0x5b0(%rbp),%rcx
mov    $0x64,%esi
lea    0x539(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x5a0(%rbp),%rax
mov    %rax,-0x688(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x688(%rbp),%rsi
mov    %eax,%edx
lea    0x522(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x520(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x518(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x513(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x65c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2499(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0x50a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x246a(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    1bf9 <writer_to_shared_memory+0xa09>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x624(%rbp)
lea    -0x624(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x630(%rbp)
lea    -0x620(%rbp),%rdi
mov    -0x630(%rbp),%rcx
mov    $0x64,%esi
lea    0x462(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x620(%rbp),%rax
mov    %rax,-0x690(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    -0x690(%rbp),%rsi
mov    %eax,%edx
lea    0x491(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x5ce(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x473(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x23ce(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x14(%rbp),%eax
add    $0x690,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writer_to_shared_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,%ebx
mov    0x2d99(%rip),%rax
mov    (%rax),%ebp
mov    0x2db8(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1110 <shmat@plt>
mov    %rax,0x20(%rsp)
cmp    $0xffffffffffffffff,%rax
je     15d7 <writer_to_shared_memory+0x3d7>
mov    %ebx,0xc(%rsp)
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xda0(%rip),%rdx
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0xdd6(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d12(%rip),%r13
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%rdi
mov    $0x1b6,%edx
call   1100 <open@plt>
cmp    $0xffffffff,%eax
je     1696 <writer_to_shared_memory+0x496>
mov    %eax,%r15d
mov    %ebp,0x2c(%rsp)
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xd05(%rip),%r14
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0xd38(%rip),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd2f(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
mov    0xc(%rsp),%r14d
mov    %r14d,%edi
mov    $0x1,%esi
call   1060 <lock@plt>
mov    0x20(%rsp),%rax
lea    0x4(%rax),%rsi
mov    %r15d,%edi
mov    $0xfffc,%edx
call   10b0 <read@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
mov    $0x0,%ebp
je     151b <writer_to_shared_memory+0x31b>
movl   $0x0,0x1c(%rsp)
xor    %ebp,%ebp
mov    0x20(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
call   10c0 <memcpy@plt>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
lea    0xbb5(%rip),%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0xbf8(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rsp),%esi
add    $0x4,%esi
lea    0xc8d(%rip),%rdi
mov    0x10(%rsp),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
mov    %r14d,%edi
mov    0x1c(%rsp),%esi
call   1050 <unlock@plt>
cmpl   $0x0,0x8(%rsp)
jle    1758 <writer_to_shared_memory+0x558>
lea    0x1(%rbp),%eax
lea    0x10(%rbp),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff0,%ecx
neg    %ecx
add    %ecx,%ebp
add    $0x1,%ebp
mov    %ebp,%eax
shl    $0x10,%eax
mov    %r13,%rbx
movslq %eax,%r13
mov    0x20(%rsp),%r14
lea    (%r14,%r13,1),%r12
lea    0x0(%rbp,%rbp,1),%eax
mov    %eax,0x1c(%rsp)
lea    0x1(%rbp,%rbp,1),%esi
mov    0xc(%rsp),%edi
call   1060 <lock@plt>
lea    (%r14,%r13,1),%rsi
add    $0x4,%rsi
mov    0xc(%rsp),%r14d
mov    %rbx,%r13
mov    %r15d,%edi
mov    $0xfffc,%edx
call   10b0 <read@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    1410 <writer_to_shared_memory+0x210>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xac9(%rip),%rdx
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0xab9(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xab2(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xaaa(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xaa5(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xb50(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2a29(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xa9d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
mov    0x29f9(%rip),%rax
mov    (%rax),%r12d
jmp    175d <writer_to_shared_memory+0x55d>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xa0d(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x9fd(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x9f6(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x9ee(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x9e9(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x9e0(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x296f(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0x9e3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2940(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
mov    0x293a(%rip),%rax
mov    (%rax),%r12d
jmp    175d <writer_to_shared_memory+0x55d>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x94e(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x93e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x937(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x92f(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x92a(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x981(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x28ab(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0x91f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x0(%r13),%edi
call   10e0 <fflush@plt>
mov    0x287b(%rip),%rax
mov    (%rax),%r12d
mov    $0xffffffff,%r15d
jmp    175d <writer_to_shared_memory+0x55d>
mov    0x2c(%rsp),%r12d
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x887(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x8bd(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x985(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x27f9(%rip),%r14
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
je     1849 <writer_to_shared_memory+0x649>
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x808(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x83e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x933(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    18ee <writer_to_shared_memory+0x6ee>
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x79d(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x78d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x786(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x77e(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x779(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x88a(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x26fa(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0x76e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    0x20(%rsp),%rdi
call   1070 <shmdt@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
je     196d <writer_to_shared_memory+0x76d>
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x6df(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x715(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x84d(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1a0d <writer_to_shared_memory+0x80d>
call   10d0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x679(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10f0 <strftime@plt>
xor    %eax,%eax
call   1080 <getpid@plt>
lea    0x669(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x662(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x65a(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x655(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x79e(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x25db(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0x64f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    %r12d,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@EXIT_SUCCESS = global i32 0
@SHM_RND = global i32 0
@.str = [19 x i8] c"%d/%m/%Y %H:%M:%S \00"
@.str.1 = [12 x i8] c"%s [pid=%d]\00"
@.str.2 = [6 x i8] c"\1B[31m\00"
@.str.3 = [9 x i8] c" ERROR! \00"
@.str.4 = [5 x i8] c"\1B[0m\00"
@.str.5 = [31 x i8] c"Shared memory wan not attached\00"
@.str.6 = [7 x i8] c" (%s)\0A\00"
@errno = global i32 0
@stdout = global i32 0
@EXIT_FAILURE = global i32 0
@.str.7 = [13 x i8] c"%s [pid=%d] \00"
@.str.8 = [45 x i8] c"shared memory was attached to writer process\00"
@.str.9 = [2 x i8] c"\0A\00"
@O_RDONLY = global i32 0
@.str.10 = [34 x i8] c"\22%s\22 was not opened for read only\00"
@.str.11 = [26 x i8] c"\22%s\22 opened for read only\00"
@.str.12 = [24 x i8] c"writing process started\00"
@.str.13 = [33 x i8] c"Writer, read error, work_path=%d\00"
@.str.14 = [44 x i8] c"%d bytes was copied from \22%s\22 to buffer[%d]\00"
@.str.15 = [25 x i8] c"writing process finished\00"
@.str.16 = [20 x i8] c"\22%s\22 was not closed\00"
@.str.17 = [36 x i8] c"\22%s\22 was closed from read only mode\00"
@.str.18 = [31 x i8] c"Shared memory was not detached\00"
@.str.19 = [39 x i8] c"shared memory was detached from writer\00"
define i32 @writer_to_shared_memory(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [101 x i8]
%10 = alloca i32
%11 = alloca %struct.tm*
%12 = alloca [101 x i8]
%13 = alloca i32
%14 = alloca %struct.tm*
%15 = alloca i32
%16 = alloca [101 x i8]
%17 = alloca i32
%18 = alloca %struct.tm*
%19 = alloca [101 x i8]
%20 = alloca i32
%21 = alloca %struct.tm*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i8*
%25 = alloca [101 x i8]
%26 = alloca i32
%27 = alloca %struct.tm*
%28 = alloca [101 x i8]
%29 = alloca i32
%30 = alloca %struct.tm*
%31 = alloca [101 x i8]
%32 = alloca i32
%33 = alloca %struct.tm*
%34 = alloca [101 x i8]
%35 = alloca i32
%36 = alloca %struct.tm*
%37 = alloca [101 x i8]
%38 = alloca i32
%39 = alloca %struct.tm*
%40 = alloca [101 x i8]
%41 = alloca i32
%42 = alloca %struct.tm*
%43 = alloca [101 x i8]
%44 = alloca i32
%45 = alloca %struct.tm*
%46 = alloca [101 x i8]
%47 = alloca i32
%48 = alloca %struct.tm*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%49 = load i32, i32* @EXIT_SUCCESS
store i32 %49, i32* %7
%50 = load i32, i32* %4
%51 = load i32, i32* @SHM_RND
%52 = call i8* @shmat(i32 %50, i32* null, i32 %51)
store i8* %52, i8** %8
%53 = load i8*, i8** %8
%54 = icmp eq i8* %53, inttoptr (i64 -1 to i8*)
br i1 %54, label %55, label %75
55: ; preds = %3
%56 = call i32 @time(i32* null)
store i32 %56, i32* %10
%57 = call %struct.tm* @localtime(i32* %10)
store %struct.tm* %57, %struct.tm** %11
%58 = getelementptr inbounds [101 x i8], [101 x i8]* %9, i64 0, i64 0
%59 = load %struct.tm*, %struct.tm** %11
%60 = call i32 @strftime(i8* %58, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %59)
%61 = getelementptr inbounds [101 x i8], [101 x i8]* %9, i64 0, i64 0
%62 = call i64 (...) @getpid()
%63 = trunc i64 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %61, i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @stdout
%73 = call i32 @fflush(i32 %72)
%74 = load i32, i32* @EXIT_FAILURE
store i32 %74, i32* %7
br label %216
75: ; preds = %3
%76 = call i32 @time(i32* null)
store i32 %76, i32* %13
%77 = call %struct.tm* @localtime(i32* %13)
store %struct.tm* %77, %struct.tm** %14
%78 = getelementptr inbounds [101 x i8], [101 x i8]* %12, i64 0, i64 0
%79 = load %struct.tm*, %struct.tm** %14
%80 = call i32 @strftime(i8* %78, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %79)
%81 = getelementptr inbounds [101 x i8], [101 x i8]* %12, i64 0, i64 0
%82 = call i64 (...) @getpid()
%83 = trunc i64 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %81, i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%87 = load i32, i32* @stdout
%88 = call i32 @fflush(i32 %87)
br label %89
89: ; preds = %75
%90 = load i8*, i8** %6
%91 = load i32, i32* @O_RDONLY
%92 = call i32 @open(i8* %90, i32 %91, i32 438)
store i32 %92, i32* %15
%93 = load i32, i32* %15
%94 = icmp eq i32 %93, -1
br i1 %94, label %95, label %116
95: ; preds = %89
%96 = call i32 @time(i32* null)
store i32 %96, i32* %17
%97 = call %struct.tm* @localtime(i32* %17)
store %struct.tm* %97, %struct.tm** %18
%98 = getelementptr inbounds [101 x i8], [101 x i8]* %16, i64 0, i64 0
%99 = load %struct.tm*, %struct.tm** %18
%100 = call i32 @strftime(i8* %98, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %99)
%101 = getelementptr inbounds [101 x i8], [101 x i8]* %16, i64 0, i64 0
%102 = call i64 (...) @getpid()
%103 = trunc i64 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %101, i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%108 = load i8*, i8** %6
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i8* %108)
%110 = load i32, i32* @errno
%111 = call i8* @strerror(i32 %110)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %111)
%113 = load i32, i32* @stdout
%114 = call i32 @fflush(i32 %113)
%115 = load i32, i32* @EXIT_FAILURE
store i32 %115, i32* %7
br label %216
116: ; preds = %89
%117 = call i32 @time(i32* null)
store i32 %117, i32* %20
%118 = call %struct.tm* @localtime(i32* %20)
store %struct.tm* %118, %struct.tm** %21
%119 = getelementptr inbounds [101 x i8], [101 x i8]* %19, i64 0, i64 0
%120 = load %struct.tm*, %struct.tm** %21
%121 = call i32 @strftime(i8* %119, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %120)
%122 = getelementptr inbounds [101 x i8], [101 x i8]* %19, i64 0, i64 0
%123 = call i64 (...) @getpid()
%124 = trunc i64 %123 to i32
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %122, i32 %124)
%126 = load i8*, i8** %6
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%129 = load i32, i32* @stdout
%130 = call i32 @fflush(i32 %129)
br label %131
131: ; preds = %116
store i32 0, i32* %22
%132 = load i8*, i8** %8
store i8* %132, i8** %24
%133 = call i32 @time(i32* null)
store i32 %133, i32* %26
%134 = call %struct.tm* @localtime(i32* %26)
store %struct.tm* %134, %struct.tm** %27
%135 = getelementptr inbounds [101 x i8], [101 x i8]* %25, i64 0, i64 0
%136 = load %struct.tm*, %struct.tm** %27
%137 = call i32 @strftime(i8* %135, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %136)
%138 = getelementptr inbounds [101 x i8], [101 x i8]* %25, i64 0, i64 0
%139 = call i64 (...) @getpid()
%140 = trunc i64 %139 to i32
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %138, i32 %140)
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%144 = load i32, i32* @stdout
%145 = call i32 @fflush(i32 %144)
br label %146
146: ; preds = %131, %206
%147 = load i32, i32* %5
%148 = load i32, i32* %22
%149 = mul nsw i32 2, %148
%150 = add nsw i32 %149, 1
%151 = call i32 @lock(i32 %147, i32 %150)
%152 = load i32, i32* %15
%153 = load i8*, i8** %24
%154 = getelementptr i8, i8* %153, i64 4
%155 = call i32 @read(i32 %152, i8* %154, i32 65532)
store i32 %155, i32* %23
%156 = load i32, i32* %23
%157 = icmp eq i32 %156, -1
br i1 %157, label %158, label %179
158: ; preds = %146
%159 = call i32 @time(i32* null)
store i32 %159, i32* %29
%160 = call %struct.tm* @localtime(i32* %29)
store %struct.tm* %160, %struct.tm** %30
%161 = getelementptr inbounds [101 x i8], [101 x i8]* %28, i64 0, i64 0
%162 = load %struct.tm*, %struct.tm** %30
%163 = call i32 @strftime(i8* %161, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %162)
%164 = getelementptr inbounds [101 x i8], [101 x i8]* %28, i64 0, i64 0
%165 = call i64 (...) @getpid()
%166 = trunc i64 %165 to i32
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %164, i32 %166)
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%171 = load i32, i32* %22
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i32 %171)
%173 = load i32, i32* @errno
%174 = call i8* @strerror(i32 %173)
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %174)
%176 = load i32, i32* @stdout
%177 = call i32 @fflush(i32 %176)
%178 = load i32, i32* @EXIT_FAILURE
store i32 %178, i32* %7
br label %216
179: ; preds = %146
%180 = load i8*, i8** %24
%181 = call i32 @memcpy(i8* %180, i32* %23, i32 4)
%182 = call i32 @time(i32* null)
store i32 %182, i32* %32
%183 = call %struct.tm* @localtime(i32* %32)
store %struct.tm* %183, %struct.tm** %33
%184 = getelementptr inbounds [101 x i8], [101 x i8]* %31, i64 0, i64 0
%185 = load %struct.tm*, %struct.tm** %33
%186 = call i32 @strftime(i8* %184, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %185)
%187 = getelementptr inbounds [101 x i8], [101 x i8]* %31, i64 0, i64 0
%188 = call i64 (...) @getpid()
%189 = trunc i64 %188 to i32
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %187, i32 %189)
%191 = load i32, i32* %23
%192 = add nsw i32 %191, 4
%193 = load i8*, i8** %6
%194 = load i32, i32* %22
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.14, i64 0, i64 0), i32 %192, i8* %193, i32 %194)
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%197 = load i32, i32* @stdout
%198 = call i32 @fflush(i32 %197)
%199 = load i32, i32* %5
%200 = load i32, i32* %22
%201 = mul nsw i32 2, %200
%202 = call i32 @unlock(i32 %199, i32 %201)
%203 = load i32, i32* %23
%204 = icmp sle i32 %203, 0
br i1 %204, label %205, label %206
205: ; preds = %179
br label %215
206: ; preds = %179
%207 = load i32, i32* %22
%208 = add nsw i32 %207, 1
%209 = srem i32 %208, 16
store i32 %209, i32* %22
%210 = load i8*, i8** %8
%211 = load i32, i32* %22
%212 = mul nsw i32 %211, 65536
%213 = sext i32 %212 to i64
%214 = getelementptr i8, i8* %210, i64 %213
store i8* %214, i8** %24
br label %146
215: ; preds = %205
br label %216
216: ; preds = %215, %158, %95, %55
%217 = call i32 @time(i32* null)
store i32 %217, i32* %35
%218 = call %struct.tm* @localtime(i32* %35)
store %struct.tm* %218, %struct.tm** %36
%219 = getelementptr inbounds [101 x i8], [101 x i8]* %34, i64 0, i64 0
%220 = load %struct.tm*, %struct.tm** %36
%221 = call i32 @strftime(i8* %219, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %220)
%222 = getelementptr inbounds [101 x i8], [101 x i8]* %34, i64 0, i64 0
%223 = call i64 (...) @getpid()
%224 = trunc i64 %223 to i32
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %222, i32 %224)
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
%227 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%228 = load i32, i32* @stdout
%229 = call i32 @fflush(i32 %228)
%230 = load i32, i32* %15
%231 = call i32 @close(i32 %230)
%232 = icmp eq i32 %231, -1
br i1 %232, label %233, label %253
233: ; preds = %216
%234 = call i32 @time(i32* null)
store i32 %234, i32* %38
%235 = call %struct.tm* @localtime(i32* %38)
store %struct.tm* %235, %struct.tm** %39
%236 = getelementptr inbounds [101 x i8], [101 x i8]* %37, i64 0, i64 0
%237 = load %struct.tm*, %struct.tm** %39
%238 = call i32 @strftime(i8* %236, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %237)
%239 = getelementptr inbounds [101 x i8], [101 x i8]* %37, i64 0, i64 0
%240 = call i64 (...) @getpid()
%241 = trunc i64 %240 to i32
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %239, i32 %241)
%243 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%244 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%246 = load i8*, i8** %6
%247 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), i8* %246)
%248 = load i32, i32* @errno
%249 = call i8* @strerror(i32 %248)
%250 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %249)
%251 = load i32, i32* @stdout
%252 = call i32 @fflush(i32 %251)
br label %268
253: ; preds = %216
%254 = call i32 @time(i32* null)
store i32 %254, i32* %41
%255 = call %struct.tm* @localtime(i32* %41)
store %struct.tm* %255, %struct.tm** %42
%256 = getelementptr inbounds [101 x i8], [101 x i8]* %40, i64 0, i64 0
%257 = load %struct.tm*, %struct.tm** %42
%258 = call i32 @strftime(i8* %256, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %257)
%259 = getelementptr inbounds [101 x i8], [101 x i8]* %40, i64 0, i64 0
%260 = call i64 (...) @getpid()
%261 = trunc i64 %260 to i32
%262 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %259, i32 %261)
%263 = load i8*, i8** %6
%264 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i8* %263)
%265 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%266 = load i32, i32* @stdout
%267 = call i32 @fflush(i32 %266)
br label %268
268: ; preds = %253, %233
%269 = load i8*, i8** %8
%270 = call i32 @shmdt(i8* %269)
%271 = icmp eq i32 %270, -1
br i1 %271, label %272, label %291
272: ; preds = %268
%273 = call i32 @time(i32* null)
store i32 %273, i32* %44
%274 = call %struct.tm* @localtime(i32* %44)
store %struct.tm* %274, %struct.tm** %45
%275 = getelementptr inbounds [101 x i8], [101 x i8]* %43, i64 0, i64 0
%276 = load %struct.tm*, %struct.tm** %45
%277 = call i32 @strftime(i8* %275, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %276)
%278 = getelementptr inbounds [101 x i8], [101 x i8]* %43, i64 0, i64 0
%279 = call i64 (...) @getpid()
%280 = trunc i64 %279 to i32
%281 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %278, i32 %280)
%282 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%283 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%284 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0))
%286 = load i32, i32* @errno
%287 = call i8* @strerror(i32 %286)
%288 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %287)
%289 = load i32, i32* @stdout
%290 = call i32 @fflush(i32 %289)
br label %305
291: ; preds = %268
%292 = call i32 @time(i32* null)
store i32 %292, i32* %47
%293 = call %struct.tm* @localtime(i32* %47)
store %struct.tm* %293, %struct.tm** %48
%294 = getelementptr inbounds [101 x i8], [101 x i8]* %46, i64 0, i64 0
%295 = load %struct.tm*, %struct.tm** %48
%296 = call i32 @strftime(i8* %294, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %295)
%297 = getelementptr inbounds [101 x i8], [101 x i8]* %46, i64 0, i64 0
%298 = call i64 (...) @getpid()
%299 = trunc i64 %298 to i32
%300 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %297, i32 %299)
%301 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0))
%302 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%303 = load i32, i32* @stdout
%304 = call i32 @fflush(i32 %303)
br label %305
305: ; preds = %291, %272
%306 = load i32, i32* %7
ret i32 %306
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@EXIT_SUCCESS = global i32 0
@SHM_RND = global i32 0
@.str = [19 x i8] c"%d/%m/%Y %H:%M:%S \00"
@.str.1 = [12 x i8] c"%s [pid=%d]\00"
@.str.2 = [6 x i8] c"\1B[31m\00"
@.str.3 = [9 x i8] c" ERROR! \00"
@.str.4 = [5 x i8] c"\1B[0m\00"
@.str.5 = [31 x i8] c"Shared memory wan not attached\00"
@.str.6 = [7 x i8] c" (%s)\0A\00"
@errno = global i32 0
@stdout = global i32 0
@EXIT_FAILURE = global i32 0
@.str.7 = [13 x i8] c"%s [pid=%d] \00"
@.str.8 = [45 x i8] c"shared memory was attached to writer process\00"
@O_RDONLY = global i32 0
@.str.10 = [34 x i8] c"\22%s\22 was not opened for read only\00"
@.str.11 = [26 x i8] c"\22%s\22 opened for read only\00"
@.str.12 = [24 x i8] c"writing process started\00"
@.str.13 = [33 x i8] c"Writer, read error, work_path=%d\00"
@.str.14 = [44 x i8] c"%d bytes was copied from \22%s\22 to buffer[%d]\00"
@.str.15 = [25 x i8] c"writing process finished\00"
@.str.16 = [20 x i8] c"\22%s\22 was not closed\00"
@.str.17 = [36 x i8] c"\22%s\22 was closed from read only mode\00"
@.str.18 = [31 x i8] c"Shared memory was not detached\00"
@.str.19 = [39 x i8] c"shared memory was detached from writer\00"
define i32 @writer_to_shared_memory(i32 %0, i32 %1, i8* %2) {
%4 = alloca [101 x i8]
%5 = alloca i32
%6 = alloca [101 x i8]
%7 = alloca i32
%8 = alloca [101 x i8]
%9 = alloca i32
%10 = alloca [101 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca [101 x i8]
%14 = alloca i32
%15 = alloca [101 x i8]
%16 = alloca i32
%17 = alloca [101 x i8]
%18 = alloca i32
%19 = alloca [101 x i8]
%20 = alloca i32
%21 = alloca [101 x i8]
%22 = alloca i32
%23 = alloca [101 x i8]
%24 = alloca i32
%25 = alloca [101 x i8]
%26 = alloca i32
%27 = alloca [101 x i8]
%28 = alloca i32
%29 = load i32, i32* @EXIT_SUCCESS
%30 = load i32, i32* @SHM_RND
%31 = tail call i8* @shmat(i32 %0, i32* null, i32 %30)
%32 = icmp eq i8* %31, inttoptr (i64 -1 to i8*)
br i1 %32, label %33, label %52
33: ; preds = %3
%34 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%35 = bitcast i32* %5 to i8*
%36 = tail call i32 @time(i32* null)
store i32 %36, i32* %5
%37 = call %struct.tm* @localtime(i32* %5)
%38 = call i32 @strftime(i8* %34, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %37)
%39 = call i64 (...) @getpid()
%40 = trunc i64 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %34, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %47)
%49 = load i32, i32* @stdout
%50 = call i32 @fflush(i32 %49)
%51 = load i32, i32* @EXIT_FAILURE
br label %171
52: ; preds = %3
%53 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%54 = bitcast i32* %7 to i8*
%55 = tail call i32 @time(i32* null)
store i32 %55, i32* %7
%56 = call %struct.tm* @localtime(i32* %7)
%57 = call i32 @strftime(i8* %53, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %56)
%58 = call i64 (...) @getpid()
%59 = trunc i64 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %53, i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%62 = call i32 @putchar(i32 10)
%63 = load i32, i32* @stdout
%64 = call i32 @fflush(i32 %63)
%65 = load i32, i32* @O_RDONLY
%66 = call i32 @open(i8* %2, i32 %65, i32 438)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %87
68: ; preds = %52
%69 = getelementptr inbounds [101 x i8], [101 x i8]* %8, i64 0, i64 0
%70 = bitcast i32* %9 to i8*
%71 = call i32 @time(i32* null)
store i32 %71, i32* %9
%72 = call %struct.tm* @localtime(i32* %9)
%73 = call i32 @strftime(i8* %69, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %72)
%74 = call i64 (...) @getpid()
%75 = trunc i64 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %69, i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %82)
%84 = load i32, i32* @stdout
%85 = call i32 @fflush(i32 %84)
%86 = load i32, i32* @EXIT_FAILURE
br label %171
87: ; preds = %52
%88 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%89 = bitcast i32* %11 to i8*
%90 = call i32 @time(i32* null)
store i32 %90, i32* %11
%91 = call %struct.tm* @localtime(i32* %11)
%92 = call i32 @strftime(i8* %88, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %91)
%93 = call i64 (...) @getpid()
%94 = trunc i64 %93 to i32
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %88, i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %2)
%97 = call i32 @putchar(i32 10)
%98 = load i32, i32* @stdout
%99 = call i32 @fflush(i32 %98)
%100 = getelementptr inbounds [101 x i8], [101 x i8]* %13, i64 0, i64 0
%101 = bitcast i32* %14 to i8*
%102 = call i32 @time(i32* null)
store i32 %102, i32* %14
%103 = call %struct.tm* @localtime(i32* %14)
%104 = call i32 @strftime(i8* %100, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %103)
%105 = call i64 (...) @getpid()
%106 = trunc i64 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %100, i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%109 = call i32 @putchar(i32 10)
%110 = load i32, i32* @stdout
%111 = call i32 @fflush(i32 %110)
%112 = call i32 @lock(i32 %1, i32 1)
%113 = getelementptr i8, i8* %31, i64 4
%114 = call i32 @read(i32 %66, i8* %113, i32 65532)
store i32 %114, i32* %12
%115 = icmp eq i32 %114, -1
br i1 %115, label %119, label %116
116: ; preds = %87
%117 = getelementptr inbounds [101 x i8], [101 x i8]* %17, i64 0, i64 0
%118 = bitcast i32* %18 to i8*
br label %139
119: ; preds = %159, %87
%120 = phi i32 [ 0, %87 ], [ %161, %159 ]
%121 = getelementptr inbounds [101 x i8], [101 x i8]* %15, i64 0, i64 0
%122 = bitcast i32* %16 to i8*
%123 = call i32 @time(i32* null)
store i32 %123, i32* %16
%124 = call %struct.tm* @localtime(i32* %16)
%125 = call i32 @strftime(i8* %121, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %124)
%126 = call i64 (...) @getpid()
%127 = trunc i64 %126 to i32
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %121, i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i32 %120)
%133 = load i32, i32* @errno
%134 = call i8* @strerror(i32 %133)
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %134)
%136 = load i32, i32* @stdout
%137 = call i32 @fflush(i32 %136)
%138 = load i32, i32* @EXIT_FAILURE
br label %171
139: ; preds = %116, %159
%140 = phi i32 [ 0, %116 ], [ %165, %159 ]
%141 = phi i32 [ 0, %116 ], [ %161, %159 ]
%142 = phi i8* [ %31, %116 ], [ %164, %159 ]
%143 = call i32 @memcpy(i8* %142, i32* %12, i32 4)
%144 = call i32 @time(i32* null)
store i32 %144, i32* %18
%145 = call %struct.tm* @localtime(i32* %18)
%146 = call i32 @strftime(i8* %117, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %145)
%147 = call i64 (...) @getpid()
%148 = trunc i64 %147 to i32
%149 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %117, i32 %148)
%150 = load i32, i32* %12
%151 = add nsw i32 %150, 4
%152 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.14, i64 0, i64 0), i32 %151, i8* %2, i32 %141)
%153 = call i32 @putchar(i32 10)
%154 = load i32, i32* @stdout
%155 = call i32 @fflush(i32 %154)
%156 = call i32 @unlock(i32 %1, i32 %140)
%157 = load i32, i32* %12
%158 = icmp slt i32 %157, 1
br i1 %158, label %171, label %159
159: ; preds = %139
%160 = add nsw i32 %141, 1
%161 = srem i32 %160, 16
%162 = shl nsw i32 %161, 16
%163 = sext i32 %162 to i64
%164 = getelementptr i8, i8* %31, i64 %163
%165 = shl nsw i32 %161, 1
%166 = or i32 %165, 1
%167 = call i32 @lock(i32 %1, i32 %166)
%168 = getelementptr i8, i8* %164, i64 4
%169 = call i32 @read(i32 %66, i8* %168, i32 65532)
store i32 %169, i32* %12
%170 = icmp eq i32 %169, -1
br i1 %170, label %119, label %139
171: ; preds = %139, %119, %68, %33
%172 = phi i32 [ undef, %33 ], [ -1, %68 ], [ %66, %119 ], [ %66, %139 ]
%173 = phi i32 [ %51, %33 ], [ %86, %68 ], [ %138, %119 ], [ %29, %139 ]
%174 = getelementptr inbounds [101 x i8], [101 x i8]* %19, i64 0, i64 0
%175 = bitcast i32* %20 to i8*
%176 = call i32 @time(i32* null)
store i32 %176, i32* %20
%177 = call %struct.tm* @localtime(i32* %20)
%178 = call i32 @strftime(i8* %174, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %177)
%179 = call i64 (...) @getpid()
%180 = trunc i64 %179 to i32
%181 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %174, i32 %180)
%182 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
%183 = call i32 @putchar(i32 10)
%184 = load i32, i32* @stdout
%185 = call i32 @fflush(i32 %184)
%186 = call i32 @close(i32 %172)
%187 = icmp eq i32 %186, -1
br i1 %187, label %188, label %206
188: ; preds = %171
%189 = getelementptr inbounds [101 x i8], [101 x i8]* %21, i64 0, i64 0
%190 = bitcast i32* %22 to i8*
%191 = call i32 @time(i32* null)
store i32 %191, i32* %22
%192 = call %struct.tm* @localtime(i32* %22)
%193 = call i32 @strftime(i8* %189, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %192)
%194 = call i64 (...) @getpid()
%195 = trunc i64 %194 to i32
%196 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %189, i32 %195)
%197 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%198 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%200 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), i8* %2)
%201 = load i32, i32* @errno
%202 = call i8* @strerror(i32 %201)
%203 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %202)
%204 = load i32, i32* @stdout
%205 = call i32 @fflush(i32 %204)
br label %219
206: ; preds = %171
%207 = getelementptr inbounds [101 x i8], [101 x i8]* %23, i64 0, i64 0
%208 = bitcast i32* %24 to i8*
%209 = call i32 @time(i32* null)
store i32 %209, i32* %24
%210 = call %struct.tm* @localtime(i32* %24)
%211 = call i32 @strftime(i8* %207, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %210)
%212 = call i64 (...) @getpid()
%213 = trunc i64 %212 to i32
%214 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %207, i32 %213)
%215 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i8* %2)
%216 = call i32 @putchar(i32 10)
%217 = load i32, i32* @stdout
%218 = call i32 @fflush(i32 %217)
br label %219
219: ; preds = %206, %188
%220 = call i32 @shmdt(i8* %31)
%221 = icmp eq i32 %220, -1
br i1 %221, label %222, label %240
222: ; preds = %219
%223 = getelementptr inbounds [101 x i8], [101 x i8]* %25, i64 0, i64 0
%224 = bitcast i32* %26 to i8*
%225 = call i32 @time(i32* null)
store i32 %225, i32* %26
%226 = call %struct.tm* @localtime(i32* %26)
%227 = call i32 @strftime(i8* %223, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %226)
%228 = call i64 (...) @getpid()
%229 = trunc i64 %228 to i32
%230 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %223, i32 %229)
%231 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%232 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%233 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%234 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0))
%235 = load i32, i32* @errno
%236 = call i8* @strerror(i32 %235)
%237 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %236)
%238 = load i32, i32* @stdout
%239 = call i32 @fflush(i32 %238)
br label %253
240: ; preds = %219
%241 = getelementptr inbounds [101 x i8], [101 x i8]* %27, i64 0, i64 0
%242 = bitcast i32* %28 to i8*
%243 = call i32 @time(i32* null)
store i32 %243, i32* %28
%244 = call %struct.tm* @localtime(i32* %28)
%245 = call i32 @strftime(i8* %241, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %244)
%246 = call i64 (...) @getpid()
%247 = trunc i64 %246 to i32
%248 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %241, i32 %247)
%249 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0))
%250 = call i32 @putchar(i32 10)
%251 = load i32, i32* @stdout
%252 = call i32 @fflush(i32 %251)
br label %253
253: ; preds = %240, %222
ret i32 %173
}