#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;
};
typedef int pid_t;

/* Variables and functions */
scalar_t__ EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ calloc(int, int const);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ free(int *);
scalar_t__ getpid();
int /*<<< orphan*/ kill_childs(int *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int process(int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int wait(int *);
int main(void) {
  srand(time(0));
  const int N = 10;
  pid_t *childs_id = (pid_t *)calloc(sizeof(pid_t), N + 1);
  int exit_status = EXIT_SUCCESS;
  for (int i = 0; i < N; i++) {
    pid_t fork_status = fork();
    if (fork_status == -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("fork[%d] failed, child processes will be killed", i);
        printf(" (%s)\n", strerror(errno));
        fflush(stdout);
      };
      kill_childs(childs_id);
      goto resourses_free_section;
    } else if (fork_status == 0) {
      exit_status = process(i);
      goto resourses_free_section;
    } else {
      childs_id[i] = fork_status;
    }
  }
  for (int i = 0; i < N; i++) {
    int status = 0;
    pid_t process = wait(&status);
    if (process != -1)
      if ((WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_FAILURE))) {
        {
          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("process with id = %d finished with error status, program "
                 "will terminated",
                 (int)process);
          printf("\n");
          fflush(stdout);
        };
        kill_childs(childs_id);
      } else if (WIFEXITED(status)) {
        {
          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("process with id = %d finished with status %d", (int)process,
                 (int)WEXITSTATUS(status));
          printf("\n");
          fflush(stdout);
        };
      }
  }
systemV_free_section:
resourses_free_section:
  free(childs_id);
  return exit_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
movl   $0xa,-0x8(%rbp)
mov    $0x4,%edi
mov    $0xb,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    1390 <main+0x190>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1350 <main+0x150>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,-0x94(%rbp)
lea    -0x94(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    $0x64,%esi
lea    0xd57(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x1b8(%rbp),%rsi
mov    %eax,%edx
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1050 <kill_childs@plt>
jmp    15a3 <main+0x3a3>
cmpl   $0x0,-0x1c(%rbp)
jne    136a <main+0x16a>
mov    -0x18(%rbp),%edi
call   1080 <process@plt>
mov    %eax,-0x14(%rbp)
jmp    15a3 <main+0x3a3>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    137d <main+0x17d>
jmp    1382 <main+0x182>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    124f <main+0x4f>
movl   $0x0,-0xa4(%rbp)
cmpl   $0xa,-0xa4(%rbp)
jge    1599 <main+0x399>
movl   $0x0,-0xa8(%rbp)
lea    -0xa8(%rbp),%rdi
call   1110 <wait@plt>
mov    %eax,-0xac(%rbp)
cmpl   $0xffffffff,-0xac(%rbp)
je     1580 <main+0x380>
mov    -0xa8(%rbp),%edi
call   10f0 <WIFEXITED@plt>
cmp    $0x0,%rax
je     14ab <main+0x2ab>
mov    -0xa8(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    0x2be1(%rip),%rcx
cmp    (%rcx),%rax
jne    14ab <main+0x2ab>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,-0x124(%rbp)
lea    -0x124(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rcx
mov    $0x64,%esi
lea    0xbc4(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x1c0(%rbp),%rsi
mov    %eax,%edx
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xac(%rbp),%esi
lea    0xbfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbe0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1050 <kill_childs@plt>
jmp    157b <main+0x37b>
mov    -0xa8(%rbp),%edi
call   10f0 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1576 <main+0x376>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,-0x1a4(%rbp)
lea    -0x1a4(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x1b0(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    -0x1b0(%rbp),%rcx
mov    $0x64,%esi
lea    0xb04(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x1d0(%rbp),%rsi
mov    %eax,%edx
lea    0xb44(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xac(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
mov    -0xa8(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    -0x1c4(%rbp),%esi
mov    %eax,%edx
lea    0xb6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xb07(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2a61(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
jmp    157b <main+0x37b>
jmp    1580 <main+0x380>
jmp    1585 <main+0x385>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    139a <main+0x19a>
jmp    159e <main+0x39e>
jmp    15a3 <main+0x3a3>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
xor    %ebp,%ebp
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   10a0 <srand@plt>
mov    $0x4,%edi
mov    $0xb,%esi
call   10b0 <calloc@plt>
mov    %rax,%r15
mov    0x2d81(%rip),%rax
mov    (%rax),%r14d
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     144e <main+0x23e>
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
mov    %eax,(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x1,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x4(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x2,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x8(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x3,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0xc(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x4,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x10(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x5,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x14(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x6,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x18(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x7,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x1c(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x8,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x20(%r15)
xor    %eax,%eax
call   1130 <fork@plt>
mov    $0x9,%ebp
cmp    $0xffffffff,%eax
je     1392 <main+0x182>
test   %eax,%eax
je     1450 <main+0x240>
mov    %eax,0x24(%r15)
mov    $0xa,%ebx
lea    0x8(%rsp),%rbp
lea    0x10(%rsp),%r13
jmp    14f4 <main+0x2e4>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <localtime@plt>
lea    0xc52(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rcx
call   10e0 <strftime@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xc42(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc3b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc33(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc2e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc25(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc37(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    %r15,%rdi
call   1060 <kill_childs@plt>
jmp    145a <main+0x24a>
mov    %eax,%ebp
mov    %ebp,%edi
call   1090 <process@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <localtime@plt>
mov    %r13,%rdi
mov    $0x64,%esi
lea    0xb68(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xbbc(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xbb6(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    %r15,%rdi
call   1060 <kill_childs@plt>
add    $0xffffffff,%ebx
je     145a <main+0x24a>
movl   $0x0,0x8(%rsp)
mov    %rbp,%rdi
call   1120 <wait@plt>
cmp    $0xffffffff,%eax
je     14eb <main+0x2db>
mov    %eax,%r12d
mov    0x8(%rsp),%edi
call   1100 <WIFEXITED@plt>
test   %rax,%rax
je     1533 <main+0x323>
mov    0x8(%rsp),%edi
call   10f0 <WEXITSTATUS@plt>
mov    0x2aae(%rip),%rcx
cmp    (%rcx),%rax
je     1474 <main+0x264>
mov    0x8(%rsp),%edi
call   1100 <WIFEXITED@plt>
test   %rax,%rax
je     14eb <main+0x2db>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <localtime@plt>
mov    %r13,%rdi
mov    $0x64,%esi
lea    0xa9b(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xaef(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%edi
call   10f0 <WEXITSTATUS@plt>
lea    0xb29(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2a1c(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    14eb <main+0x2db>

LLVM IR (-O0):
%struct.tm = type { i32 }
@EXIT_SUCCESS = 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 = [48 x i8] c"fork[%d] failed, child processes will be killed\00"
@.str.6 = [7 x i8] c" (%s)\0A\00"
@errno = global i32 0
@stdout = global i32 0
@EXIT_FAILURE = global i64 0
@.str.7 = [13 x i8] c"%s [pid=%d] \00"
@.str.8 = [73 x i8] c"process with id = %d finished with error status, program will terminated\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [45 x i8] c"process with id = %d finished with status %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [101 x i8]
%8 = alloca i32
%9 = alloca %struct.tm*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [101 x i8]
%14 = alloca i32
%15 = alloca %struct.tm*
%16 = alloca [101 x i8]
%17 = alloca i32
%18 = alloca %struct.tm*
store i32 0, i32* %1
%19 = call i32 @time(i32* null)
%20 = call i32 @srand(i32 %19)
store i32 10, i32* %2
%21 = call i64 @calloc(i32 4, i32 11)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %3
%23 = load i32, i32* @EXIT_SUCCESS
store i32 %23, i32* %4
store i32 0, i32* %5
br label %24
24: ; preds = %67, %0
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %70
27: ; preds = %24
%28 = call i32 (...) @fork()
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %53
31: ; preds = %27
%32 = call i32 @time(i32* null)
store i32 %32, i32* %8
%33 = call %struct.tm* @localtime(i32* %8)
store %struct.tm* %33, %struct.tm** %9
%34 = getelementptr inbounds [101 x i8], [101 x i8]* %7, i64 0, i64 0
%35 = load %struct.tm*, %struct.tm** %9
%36 = call i32 @strftime(i8* %34, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %35)
%37 = getelementptr inbounds [101 x i8], [101 x i8]* %7, i64 0, i64 0
%38 = call i64 (...) @getpid()
%39 = trunc i64 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %37, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32, i32* %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* 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** %3
%52 = call i32 @kill_childs(i32* %51)
br label %134
53: ; preds = %27
%54 = load i32, i32* %6
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %5
%58 = call i32 @process(i32 %57)
store i32 %58, i32* %4
br label %134
59: ; preds = %53
%60 = load i32, i32* %6
%61 = load i32*, i32** %3
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
store i32 %60, i32* %64
br label %65
65: ; preds = %59
br label %66
66: ; preds = %65
br label %67
67: ; preds = %66
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %24
70: ; preds = %24
store i32 0, i32* %10
br label %71
71: ; preds = %129, %70
%72 = load i32, i32* %10
%73 = icmp slt i32 %72, 10
br i1 %73, label %74, label %132
74: ; preds = %71
store i32 0, i32* %11
%75 = call i32 @wait(i32* %11)
store i32 %75, i32* %12
%76 = load i32, i32* %12
%77 = icmp ne i32 %76, -1
br i1 %77, label %78, label %128
78: ; preds = %74
%79 = load i32, i32* %11
%80 = call i64 @WIFEXITED(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %104
82: ; preds = %78
%83 = load i32, i32* %11
%84 = call i64 @WEXITSTATUS(i32 %83)
%85 = load i64, i64* @EXIT_FAILURE
%86 = icmp eq i64 %84, %85
br i1 %86, label %87, label %104
87: ; preds = %82
%88 = call i32 @time(i32* null)
store i32 %88, i32* %14
%89 = call %struct.tm* @localtime(i32* %14)
store %struct.tm* %89, %struct.tm** %15
%90 = getelementptr inbounds [101 x i8], [101 x i8]* %13, i64 0, i64 0
%91 = load %struct.tm*, %struct.tm** %15
%92 = call i32 @strftime(i8* %90, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %91)
%93 = getelementptr inbounds [101 x i8], [101 x i8]* %13, i64 0, i64 0
%94 = call i64 (...) @getpid()
%95 = trunc i64 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %93, i32 %95)
%97 = load i32, i32* %12
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0), i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%100 = load i32, i32* @stdout
%101 = call i32 @fflush(i32 %100)
%102 = load i32*, i32** %3
%103 = call i32 @kill_childs(i32* %102)
br label %127
104: ; preds = %82, %78
%105 = load i32, i32* %11
%106 = call i64 @WIFEXITED(i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %126
108: ; preds = %104
%109 = call i32 @time(i32* null)
store i32 %109, i32* %17
%110 = call %struct.tm* @localtime(i32* %17)
store %struct.tm* %110, %struct.tm** %18
%111 = getelementptr inbounds [101 x i8], [101 x i8]* %16, i64 0, i64 0
%112 = load %struct.tm*, %struct.tm** %18
%113 = call i32 @strftime(i8* %111, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %112)
%114 = getelementptr inbounds [101 x i8], [101 x i8]* %16, i64 0, i64 0
%115 = call i64 (...) @getpid()
%116 = trunc i64 %115 to i32
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %114, i32 %116)
%118 = load i32, i32* %12
%119 = load i32, i32* %11
%120 = call i64 @WEXITSTATUS(i32 %119)
%121 = trunc i64 %120 to i32
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %118, i32 %121)
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%124 = load i32, i32* @stdout
%125 = call i32 @fflush(i32 %124)
br label %126
126: ; preds = %108, %104
br label %127
127: ; preds = %126, %87
br label %128
128: ; preds = %127, %74
br label %129
129: ; preds = %128
%130 = load i32, i32* %10
%131 = add nsw i32 %130, 1
store i32 %131, i32* %10
br label %71
132: ; preds = %71
br label %133
133: ; preds = %132
br label %134
134: ; preds = %133, %56, %31
%135 = load i32*, i32** %3
%136 = call i32 @free(i32* %135)
%137 = load i32, i32* %4
ret i32 %137
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@EXIT_SUCCESS = 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 = [48 x i8] c"fork[%d] failed, child processes will be killed\00"
@.str.6 = [7 x i8] c" (%s)\0A\00"
@errno = global i32 0
@stdout = global i32 0
@EXIT_FAILURE = global i64 0
@.str.7 = [13 x i8] c"%s [pid=%d] \00"
@.str.8 = [73 x i8] c"process with id = %d finished with error status, program will terminated\00"
@.str.10 = [45 x i8] c"process with id = %d finished with status %d\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [101 x i8]
%5 = alloca i32
%6 = alloca [101 x i8]
%7 = alloca i32
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i64 @calloc(i32 4, i32 11)
%11 = inttoptr i64 %10 to i32*
%12 = load i32, i32* @EXIT_SUCCESS
%13 = tail call i32 (...) @fork()
switch i32 %13, label %37 [
i32 -1, label %14
i32 0, label %34
]
14: ; preds = %60, %57, %54, %51, %48, %45, %42, %39, %37, %0
%15 = phi i32 [ 0, %0 ], [ 1, %37 ], [ 2, %39 ], [ 3, %42 ], [ 4, %45 ], [ 5, %48 ], [ 6, %51 ], [ 7, %54 ], [ 8, %57 ], [ 9, %60 ]
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%17 = bitcast i32* %2 to i8*
%18 = tail call i32 @time(i32* null)
store i32 %18, i32* %2
%19 = call %struct.tm* @localtime(i32* %2)
%20 = call i32 @strftime(i8* %16, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %19)
%21 = call i64 (...) @getpid()
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = call i32 @kill_childs(i32* %11)
br label %116
34: ; preds = %60, %57, %54, %51, %48, %45, %42, %39, %37, %0
%35 = phi i32 [ %13, %0 ], [ 1, %37 ], [ 2, %39 ], [ 3, %42 ], [ 4, %45 ], [ 5, %48 ], [ 6, %51 ], [ 7, %54 ], [ 8, %57 ], [ 9, %60 ]
%36 = tail call i32 @process(i32 %35)
br label %116
37: ; preds = %0
store i32 %13, i32* %11
%38 = tail call i32 (...) @fork()
switch i32 %38, label %39 [
i32 -1, label %14
i32 0, label %34
]
39: ; preds = %37
%40 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %38, i32* %40
%41 = tail call i32 (...) @fork()
switch i32 %41, label %42 [
i32 -1, label %14
i32 0, label %34
]
42: ; preds = %39
%43 = getelementptr inbounds i32, i32* %11, i64 2
store i32 %41, i32* %43
%44 = tail call i32 (...) @fork()
switch i32 %44, label %45 [
i32 -1, label %14
i32 0, label %34
]
45: ; preds = %42
%46 = getelementptr inbounds i32, i32* %11, i64 3
store i32 %44, i32* %46
%47 = tail call i32 (...) @fork()
switch i32 %47, label %48 [
i32 -1, label %14
i32 0, label %34
]
48: ; preds = %45
%49 = getelementptr inbounds i32, i32* %11, i64 4
store i32 %47, i32* %49
%50 = tail call i32 (...) @fork()
switch i32 %50, label %51 [
i32 -1, label %14
i32 0, label %34
]
51: ; preds = %48
%52 = getelementptr inbounds i32, i32* %11, i64 5
store i32 %50, i32* %52
%53 = tail call i32 (...) @fork()
switch i32 %53, label %54 [
i32 -1, label %14
i32 0, label %34
]
54: ; preds = %51
%55 = getelementptr inbounds i32, i32* %11, i64 6
store i32 %53, i32* %55
%56 = tail call i32 (...) @fork()
switch i32 %56, label %57 [
i32 -1, label %14
i32 0, label %34
]
57: ; preds = %54
%58 = getelementptr inbounds i32, i32* %11, i64 7
store i32 %56, i32* %58
%59 = tail call i32 (...) @fork()
switch i32 %59, label %60 [
i32 -1, label %14
i32 0, label %34
]
60: ; preds = %57
%61 = getelementptr inbounds i32, i32* %11, i64 8
store i32 %59, i32* %61
%62 = tail call i32 (...) @fork()
switch i32 %62, label %63 [
i32 -1, label %14
i32 0, label %34
]
63: ; preds = %60
%64 = getelementptr inbounds i32, i32* %11, i64 9
store i32 %62, i32* %64
%65 = bitcast i32* %3 to i8*
%66 = getelementptr inbounds [101 x i8], [101 x i8]* %4, i64 0, i64 0
%67 = bitcast i32* %5 to i8*
%68 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%69 = bitcast i32* %7 to i8*
br label %70
70: ; preds = %63, %113
%71 = phi i32 [ 0, %63 ], [ %114, %113 ]
store i32 0, i32* %3
%72 = call i32 @wait(i32* %3)
%73 = icmp eq i32 %72, -1
br i1 %73, label %113, label %74
74: ; preds = %70
%75 = load i32, i32* %3
%76 = call i64 @WIFEXITED(i32 %75)
%77 = icmp eq i64 %76, 0
br i1 %77, label %95, label %78
78: ; preds = %74
%79 = load i32, i32* %3
%80 = call i64 @WEXITSTATUS(i32 %79)
%81 = load i64, i64* @EXIT_FAILURE
%82 = icmp eq i64 %80, %81
br i1 %82, label %83, label %95
83: ; preds = %78
%84 = call i32 @time(i32* null)
store i32 %84, i32* %5
%85 = call %struct.tm* @localtime(i32* %5)
%86 = call i32 @strftime(i8* %66, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %85)
%87 = call i64 (...) @getpid()
%88 = trunc i64 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %66, i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0), i32 %72)
%91 = call i32 @putchar(i32 10)
%92 = load i32, i32* @stdout
%93 = call i32 @fflush(i32 %92)
%94 = call i32 @kill_childs(i32* %11)
br label %113
95: ; preds = %78, %74
%96 = load i32, i32* %3
%97 = call i64 @WIFEXITED(i32 %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %113, label %99
99: ; preds = %95
%100 = call i32 @time(i32* null)
store i32 %100, i32* %7
%101 = call %struct.tm* @localtime(i32* %7)
%102 = call i32 @strftime(i8* %68, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %101)
%103 = call i64 (...) @getpid()
%104 = trunc i64 %103 to i32
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %68, i32 %104)
%106 = load i32, i32* %3
%107 = call i64 @WEXITSTATUS(i32 %106)
%108 = trunc i64 %107 to i32
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %72, i32 %108)
%110 = call i32 @putchar(i32 10)
%111 = load i32, i32* @stdout
%112 = call i32 @fflush(i32 %111)
br label %113
113: ; preds = %83, %99, %95, %70
%114 = add nuw nsw i32 %71, 1
%115 = icmp eq i32 %114, 10
br i1 %115, label %116, label %70
116: ; preds = %113, %34, %14
%117 = phi i32 [ %12, %14 ], [ %36, %34 ], [ %12, %113 ]
%118 = call i32 @free(i32* %11)
ret i32 %117
}