#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;
typedef int /*<<< orphan*/ pidbuf;
typedef int pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ WCOREDUMP(int);
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int WTERMSIG(int);
int /*<<< orphan*/ close(int);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fcgi_spawn_connection(char *, char **, int, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getpid();
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int wait(int *);
int /*<<< orphan*/ write(int, char *, int);
int fcgi_spawn_monitor(char *fcgi_app, char **fcgi_app_argv, int fcgi_fd,
                       int fork_count, int child_count, int pid_fd, int nofork,
                       FILE *log_fp) {
  int status;
  pid_t w;
  char pidbuf[12];
  int rc = -1;
  time_t log_time = time(NULL);
  char *time_str = ctime(&log_time);
  time_str[strlen(time_str) - 1] = 0;
  fprintf(log_fp, "[%s] begin to spawn ...\n", time_str);
  for (int i = 0; i < fork_count; i++) {
    rc = fcgi_spawn_connection(fcgi_app, fcgi_app_argv, fcgi_fd, child_count,
                               nofork, log_fp);
    if (rc < 0) {
      exit(EXIT_FAILURE);
    }
  }
  snprintf(pidbuf, sizeof(pidbuf), "%d", getpid());
  write(pid_fd, pidbuf, strlen(pidbuf));
  close(pid_fd);
  while (1) {
    w = wait(&status);
    log_time = time(NULL);
    time_str = ctime(&log_time);
    time_str[strlen(time_str) - 1] = 0;
    fprintf(log_fp, "[%s] wait waked up.\n", time_str);
    if (w == -1) {
      fprintf(log_fp, "wait interrupted: %s\n", strerror(errno));
      continue;
    }
    if (WIFEXITED(status)) {
      fprintf(log_fp, "child[%d] exited, status=%d\n", w, WEXITSTATUS(status));
    } else if (WCOREDUMP(status)) {
      fprintf(log_fp, "child[%d] coredump!\n", w);
    } else if (WIFSIGNALED(status)) {
      fprintf(log_fp, "child[%d] killed by signal %d\n", w, WTERMSIG(status));
    } else if (WIFSTOPPED(status)) {
      fprintf(log_fp, "chlild[%d] stopped by signal %d\n", w, WSTOPSIG(status));
    }
    rc = fcgi_spawn_connection(fcgi_app, fcgi_app_argv, fcgi_fd, child_count,
                               nofork, log_fp);
    if (rc < 0) {
      break;
    }
  }
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<fcgi_spawn_monitor>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movl   $0xffffffff,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x3c(%rbp),%rdi
call   1060 <ctime@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x18(%rbp),%rdi
mov    -0x48(%rbp),%rdx
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    130b <fcgi_spawn_monitor+0xdb>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9
call   1030 <fcgi_spawn_connection@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    12f8 <fcgi_spawn_monitor+0xc8>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
jmp    12fd <fcgi_spawn_monitor+0xcd>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12b6 <fcgi_spawn_monitor+0x86>
lea    -0x34(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%ecx
mov    $0xc,%esi
lea    0xced(%rip),%rdx
call   1090 <snprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x64(%rbp)
lea    -0x34(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x34(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
call   10a0 <close@plt>
lea    -0x24(%rbp),%rdi
call   1150 <wait@plt>
mov    %eax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x3c(%rbp),%rdi
call   1060 <ctime@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x18(%rbp),%rdi
mov    -0x48(%rbp),%rdx
lea    0xc69(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmpl   $0xffffffff,-0x28(%rbp)
jne    13f4 <fcgi_spawn_monitor+0x1c4>
mov    0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x80(%rbp),%rdi
mov    %rax,%rdx
lea    0xc49(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    135e <fcgi_spawn_monitor+0x12e>
mov    -0x24(%rbp),%edi
call   1110 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1444 <fcgi_spawn_monitor+0x214>
mov    0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x24(%rbp),%edi
call   1100 <WEXITSTATUS@plt>
mov    -0x90(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    %eax,%ecx
lea    0xc0f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    151a <fcgi_spawn_monitor+0x2ea>
mov    -0x24(%rbp),%edi
call   1080 <WCOREDUMP@plt>
cmp    $0x0,%rax
je     1470 <fcgi_spawn_monitor+0x240>
mov    0x18(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xc00(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1515 <fcgi_spawn_monitor+0x2e5>
mov    -0x24(%rbp),%edi
call   10b0 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     14c0 <fcgi_spawn_monitor+0x290>
mov    0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x24(%rbp),%edi
call   10f0 <WTERMSIG@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x94(%rbp),%edx
mov    %eax,%ecx
lea    0xbc5(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1510 <fcgi_spawn_monitor+0x2e0>
mov    -0x24(%rbp),%edi
call   10d0 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     150b <fcgi_spawn_monitor+0x2db>
mov    0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x24(%rbp),%edi
call   1140 <WSTOPSIG@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    %eax,%ecx
lea    0xb94(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1510 <fcgi_spawn_monitor+0x2e0>
jmp    1515 <fcgi_spawn_monitor+0x2e5>
jmp    151a <fcgi_spawn_monitor+0x2ea>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9
call   1030 <fcgi_spawn_connection@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1547 <fcgi_spawn_monitor+0x317>
jmp    154c <fcgi_spawn_monitor+0x31c>
jmp    135e <fcgi_spawn_monitor+0x12e>
mov    0x2a85(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

x86 assembly (clang, -O2):
<fcgi_spawn_monitor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,0x18(%rsp)
mov    %r8d,0x14(%rsp)
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0x68(%rsp),%rbx
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1060 <ctime@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xd78(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
test   %r13d,%r13d
jle    12c8 <fcgi_spawn_monitor+0x98>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    0x14(%rsp),%ecx
mov    0x60(%rsp),%r8d
mov    %rbx,%r9
call   1030 <fcgi_spawn_connection@plt>
test   %eax,%eax
js     1437 <fcgi_spawn_monitor+0x207>
add    $0xffffffff,%r13d
jne    12a0 <fcgi_spawn_monitor+0x70>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xd43(%rip),%rdx
lea    0x1c(%rsp),%r13
mov    %r13,%rdi
mov    $0xc,%esi
mov    %eax,%ecx
call   1090 <snprintf@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    0x18(%rsp),%r14d
mov    %r14d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
jmp    1332 <fcgi_spawn_monitor+0x102>
xchg   %ax,%ax
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    %rbx,%rdi
lea    0xd09(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0xc(%rsp),%rdi
call   1150 <wait@plt>
mov    %eax,%r13d
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1060 <ctime@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %rbx,%rdi
lea    0xcab(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
cmp    $0xffffffff,%r13d
je     1310 <fcgi_spawn_monitor+0xe0>
mov    0xc(%rsp),%edi
call   1110 <WIFEXITED@plt>
mov    0xc(%rsp),%edi
test   %rax,%rax
je     13b0 <fcgi_spawn_monitor+0x180>
call   1100 <WEXITSTATUS@plt>
mov    %rbx,%rdi
lea    0xca5(%rip),%rsi
mov    %r13d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    13ce <fcgi_spawn_monitor+0x19e>
call   1080 <WCOREDUMP@plt>
test   %rax,%rax
je     13f2 <fcgi_spawn_monitor+0x1c2>
mov    %rbx,%rdi
lea    0xca0(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    0x14(%rsp),%ecx
mov    0x60(%rsp),%r8d
mov    %rbx,%r9
call   1030 <fcgi_spawn_connection@plt>
test   %eax,%eax
jns    1332 <fcgi_spawn_monitor+0x102>
jmp    1437 <fcgi_spawn_monitor+0x207>
mov    0xc(%rsp),%edi
call   10b0 <WIFSIGNALED@plt>
mov    0xc(%rsp),%edi
test   %rax,%rax
je     1415 <fcgi_spawn_monitor+0x1e5>
call   10f0 <WTERMSIG@plt>
mov    %rbx,%rdi
lea    0xc66(%rip),%rsi
jmp    13a2 <fcgi_spawn_monitor+0x172>
call   10d0 <WIFSTOPPED@plt>
test   %rax,%rax
je     13ce <fcgi_spawn_monitor+0x19e>
mov    0xc(%rsp),%edi
call   1140 <WSTOPSIG@plt>
mov    %rbx,%rdi
lea    0xc66(%rip),%rsi
jmp    13a2 <fcgi_spawn_monitor+0x172>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"[%s] begin to spawn ...\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"[%s] wait waked up.\0A\00"
@.str.3 = [22 x i8] c"wait interrupted: %s\0A\00"
@errno = global i32 0
@.str.4 = [29 x i8] c"child[%d] exited, status=%d\0A\00"
@.str.5 = [21 x i8] c"child[%d] coredump!\0A\00"
@.str.6 = [31 x i8] c"child[%d] killed by signal %d\0A\00"
@.str.7 = [33 x i8] c"chlild[%d] stopped by signal %d\0A\00"
define i32 @fcgi_spawn_monitor(i8* %0, i8** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7) {
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca [12 x i8]
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8*
%23 = alloca i32
store i8* %0, i8** %9
store i8** %1, i8*** %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32* %7, i32** %16
store i32 -1, i32* %20
%24 = call i32 @time(i32* null)
store i32 %24, i32* %21
%25 = call i8* @ctime(i32* %21)
store i8* %25, i8** %22
%26 = load i8*, i8** %22
%27 = load i8*, i8** %22
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
store i8 0, i8* %31
%32 = load i32*, i32** %16
%33 = load i8*, i8** %22
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %33)
store i32 0, i32* %23
br label %35
35: ; preds = %53, %8
%36 = load i32, i32* %23
%37 = load i32, i32* %12
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load i8*, i8** %9
%41 = load i8**, i8*** %10
%42 = load i32, i32* %11
%43 = load i32, i32* %13
%44 = load i32, i32* %15
%45 = load i32*, i32** %16
%46 = call i32 @fcgi_spawn_connection(i8* %40, i8** %41, i32 %42, i32 %43, i32 %44, i32* %45)
store i32 %46, i32* %20
%47 = load i32, i32* %20
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %39
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %39
br label %53
53: ; preds = %52
%54 = load i32, i32* %23
%55 = add nsw i32 %54, 1
store i32 %55, i32* %23
br label %35
56: ; preds = %35
%57 = getelementptr inbounds [12 x i8], [12 x i8]* %19, i64 0, i64 0
%58 = call i32 (...) @getpid()
%59 = call i32 @snprintf(i8* %57, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %14
%61 = getelementptr inbounds [12 x i8], [12 x i8]* %19, i64 0, i64 0
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %19, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @write(i32 %60, i8* %61, i32 %63)
%65 = load i32, i32* %14
%66 = call i32 @close(i32 %65)
br label %67
67: ; preds = %56, %82, %139
%68 = call i32 @wait(i32* %17)
store i32 %68, i32* %18
%69 = call i32 @time(i32* null)
store i32 %69, i32* %21
%70 = call i8* @ctime(i32* %21)
store i8* %70, i8** %22
%71 = load i8*, i8** %22
%72 = load i8*, i8** %22
%73 = call i32 @strlen(i8* %72)
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %71, i64 %75
store i8 0, i8* %76
%77 = load i32*, i32** %16
%78 = load i8*, i8** %22
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %78)
%80 = load i32, i32* %18
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %87
82: ; preds = %67
%83 = load i32*, i32** %16
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %85)
br label %67
87: ; preds = %67
%88 = load i32, i32* %17
%89 = call i64 @WIFEXITED(i32 %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %97
91: ; preds = %87
%92 = load i32*, i32** %16
%93 = load i32, i32* %18
%94 = load i32, i32* %17
%95 = call i32 @WEXITSTATUS(i32 %94)
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %93, i32 %95)
br label %128
97: ; preds = %87
%98 = load i32, i32* %17
%99 = call i64 @WCOREDUMP(i32 %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %97
%102 = load i32*, i32** %16
%103 = load i32, i32* %18
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %102, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %103)
br label %127
105: ; preds = %97
%106 = load i32, i32* %17
%107 = call i64 @WIFSIGNALED(i32 %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %115
109: ; preds = %105
%110 = load i32*, i32** %16
%111 = load i32, i32* %18
%112 = load i32, i32* %17
%113 = call i32 @WTERMSIG(i32 %112)
%114 = call i32 (i32*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %111, i32 %113)
br label %126
115: ; preds = %105
%116 = load i32, i32* %17
%117 = call i64 @WIFSTOPPED(i32 %116)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %125
119: ; preds = %115
%120 = load i32*, i32** %16
%121 = load i32, i32* %18
%122 = load i32, i32* %17
%123 = call i32 @WSTOPSIG(i32 %122)
%124 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %121, i32 %123)
br label %125
125: ; preds = %119, %115
br label %126
126: ; preds = %125, %109
br label %127
127: ; preds = %126, %101
br label %128
128: ; preds = %127, %91
%129 = load i8*, i8** %9
%130 = load i8**, i8*** %10
%131 = load i32, i32* %11
%132 = load i32, i32* %13
%133 = load i32, i32* %15
%134 = load i32*, i32** %16
%135 = call i32 @fcgi_spawn_connection(i8* %129, i8** %130, i32 %131, i32 %132, i32 %133, i32* %134)
store i32 %135, i32* %20
%136 = load i32, i32* %20
%137 = icmp slt i32 %136, 0
br i1 %137, label %138, label %139
138: ; preds = %128
br label %140
139: ; preds = %128
br label %67
140: ; preds = %138
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
}

LLVM IR (-O2):
@.str = [25 x i8] c"[%s] begin to spawn ...\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"[%s] wait waked up.\0A\00"
@.str.3 = [22 x i8] c"wait interrupted: %s\0A\00"
@errno = global i32 0
@.str.4 = [29 x i8] c"child[%d] exited, status=%d\0A\00"
@.str.5 = [21 x i8] c"child[%d] coredump!\0A\00"
@.str.6 = [31 x i8] c"child[%d] killed by signal %d\0A\00"
@.str.7 = [33 x i8] c"chlild[%d] stopped by signal %d\0A\00"
define i32 @fcgi_spawn_monitor(i8* %0, i8** %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7) {
%9 = alloca i32
%10 = alloca [12 x i8]
%11 = alloca i32
%12 = bitcast i32* %9 to i8*
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %10, i64 0, i64 0
%14 = bitcast i32* %11 to i8*
%15 = tail call i32 @time(i32* null)
store i32 %15, i32* %11
%16 = call i8* @ctime(i32* %11)
%17 = call i32 @strlen(i8* %16)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8 0, i8* %20
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
%22 = icmp sgt i32 %3, 0
br i1 %22, label %31, label %25
23: ; preds = %31
%24 = icmp eq i32 %35, %3
br i1 %24, label %25, label %31
25: ; preds = %23, %8
%26 = call i32 (...) @getpid()
%27 = call i32 @snprintf(i8* %13, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = call i32 @strlen(i8* %13)
%29 = call i32 @write(i32 %5, i8* %13, i32 %28)
%30 = call i32 @close(i32 %5)
br label %39
31: ; preds = %8, %23
%32 = phi i32 [ %35, %23 ], [ 0, %8 ]
%33 = call i32 @fcgi_spawn_connection(i8* %0, i8** %1, i32 %2, i32 %4, i32 %6, i32* %7)
%34 = icmp slt i32 %33, 0
%35 = add nuw nsw i32 %32, 1
br i1 %34, label %36, label %23
36: ; preds = %31
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %53, %25
%40 = call i32 @wait(i32* %9)
%41 = call i32 @time(i32* null)
store i32 %41, i32* %11
%42 = call i8* @ctime(i32* %11)
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
store i8 0, i8* %46
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%48 = icmp eq i32 %40, -1
br i1 %48, label %49, label %54
49: ; preds = %39
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %82
br label %39
54: ; preds = %39
%55 = load i32, i32* %9
%56 = call i64 @WIFEXITED(i32 %55)
%57 = icmp eq i64 %56, 0
%58 = load i32, i32* %9
br i1 %57, label %62, label %59
59: ; preds = %54
%60 = call i32 @WEXITSTATUS(i32 %58)
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %60)
br label %82
62: ; preds = %54
%63 = call i64 @WCOREDUMP(i32 %58)
%64 = icmp eq i64 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %62
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %82
67: ; preds = %62
%68 = load i32, i32* %9
%69 = call i64 @WIFSIGNALED(i32 %68)
%70 = icmp eq i64 %69, 0
%71 = load i32, i32* %9
br i1 %70, label %75, label %72
72: ; preds = %67
%73 = call i32 @WTERMSIG(i32 %71)
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %40, i32 %73)
br label %82
75: ; preds = %67
%76 = call i64 @WIFSTOPPED(i32 %71)
%77 = icmp eq i64 %76, 0
br i1 %77, label %82, label %78
78: ; preds = %75
%79 = load i32, i32* %9
%80 = call i32 @WSTOPSIG(i32 %79)
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %40, i32 %80)
br label %82
82: ; preds = %65, %75, %78, %72, %59
%83 = call i32 @fcgi_spawn_connection(i8* %0, i8** %1, i32 %2, i32 %4, i32 %6, i32* %7)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %53
85: ; preds = %82
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
}