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

/* Forward declarations */

/* Type definitions */
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ response_string;
typedef int /*<<< orphan*/ recvbuf;
typedef int pid_t;

/* Variables and functions */
int WCONTINUED;
scalar_t__ WIFCONTINUED(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WUNTRACED;
int accept(int, struct sockaddr *, unsigned int *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int process_cancel(int, char *);
int /*<<< orphan*/ process_get_resource(int, char *);
int recv(int, char **, int, int /*<<< orphan*/);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncasecmp(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int waitpid(int, int *, int);
int /*<<< orphan*/ zombie_listen();
int node_transcode_worker(int sockfd) {
  int ret = 0;
  int recvbytes = 0;
  int client_sockfd = 0;
  unsigned int sin_size = 0;
  struct sockaddr_in client_addr;
  char recvbuf[2048];
  char response_string[128];
  pid_t child_pid = 0;
  pid_t transcoder_pid = 0;
  int status = 0;
  zombie_listen();
  while (1) {
    if ((client_sockfd = accept(sockfd, (struct sockaddr *)&client_addr,
                                &sin_size)) == -1) {
      printf("accept:%s", strerror(errno));
      usleep(10000);
      continue;
    }
    if (!(child_pid = fork())) {
      memset(recvbuf, 0, sizeof(recvbuf));
      if ((recvbytes = recv(client_sockfd, &recvbuf, sizeof(recvbuf), 0)) ==
          -1) {
        printf("recv:[%s]\n", strerror(errno));
        exit(1);
      }
      if (recvbytes < 16) {
        if (!strncasecmp((char *)&recvbuf, "pid=", strlen("pid="))) {
          ret = process_cancel(client_sockfd, recvbuf);
        } else if (!strncasecmp((char *)&recvbuf, "getcpu", strlen("getcpu"))) {
          process_get_resource(client_sockfd, recvbuf);
        } else {
          if (client_sockfd) {
            close(client_sockfd);
            client_sockfd = 0;
          }
        }
      } else {
        if (!(transcoder_pid = fork())) {
          close(client_sockfd);
          client_sockfd = 0;
          execlp("sh", "sh", "-c", recvbuf, NULL);
          exit(1);
        }
        memset(response_string, 0, sizeof(response_string));
        sprintf(response_string, "waiting pid=%d", transcoder_pid);
        if (send(client_sockfd, response_string, strlen(response_string), 0) ==
            -1) {
          printf("child-send:%s", strerror(errno));
        }
        do {
          ret = waitpid(transcoder_pid, &status, WUNTRACED | WCONTINUED);
          if (ret == -1) {
            printf("child:waitpid:%s", strerror(errno));
            exit(-1);
          }
          if (WIFEXITED(status)) {
          } else if (WIFSIGNALED(status)) {
          } else if (WIFSTOPPED(status)) {
          } else if (WIFCONTINUED(status)) {
          }
        } while (!WIFEXITED(status) && !WIFSIGNALED(status));
        if (client_sockfd) {
          close(client_sockfd);
          client_sockfd = 0;
        }
      }
    } else {
      if (client_sockfd) {
        close(client_sockfd);
        client_sockfd = 0;
      }
    }
    printf("recvied buffer size = %d\n", recvbytes);
    printf("recvied byffer = [%s]\n", recvbuf);
  }
}


x86 assembly (clang, -O0):
<node_transcode_worker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8d0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8a4(%rbp)
movl   $0x0,-0x8a8(%rbp)
movl   $0x0,-0x8ac(%rbp)
mov    $0x0,%al
call   10f0 <zombie_listen@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xffffffff,%eax
jne    12f9 <node_transcode_worker+0x99>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
mov    %rax,%rsi
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2710,%edi
call   1180 <usleep@plt>
jmp    12af <node_transcode_worker+0x4f>
mov    $0x0,%al
call   1170 <fork@plt>
mov    %eax,-0x8a4(%rbp)
cmp    $0x0,%eax
jne    165e <node_transcode_worker+0x3fe>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1090 <memset@plt>
mov    -0x10(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    136d <node_transcode_worker+0x10d>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
mov    %rax,%rsi
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
cmpl   $0x10,-0xc(%rbp)
jge    143a <node_transcode_worker+0x1da>
lea    -0x820(%rbp),%rax
mov    %rax,-0x8b8(%rbp)
lea    0xc89(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x8b8(%rbp),%rdi
mov    %eax,%edx
lea    0xc74(%rip),%rsi
call   10e0 <strncasecmp@plt>
cmp    $0x0,%eax
jne    13c6 <node_transcode_worker+0x166>
mov    -0x10(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   1040 <process_cancel@plt>
mov    %eax,-0x8(%rbp)
jmp    1435 <node_transcode_worker+0x1d5>
lea    -0x820(%rbp),%rax
mov    %rax,-0x8c0(%rbp)
lea    0xc3f(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x8c0(%rbp),%rdi
mov    %eax,%edx
lea    0xc2a(%rip),%rsi
call   10e0 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1412 <node_transcode_worker+0x1b2>
mov    -0x10(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   1080 <process_get_resource@plt>
jmp    1430 <node_transcode_worker+0x1d0>
cmpl   $0x0,-0x10(%rbp)
je     142b <node_transcode_worker+0x1cb>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x10(%rbp)
jmp    1430 <node_transcode_worker+0x1d0>
jmp    1435 <node_transcode_worker+0x1d5>
jmp    1659 <node_transcode_worker+0x3f9>
mov    $0x0,%al
call   1170 <fork@plt>
mov    %eax,-0x8a8(%rbp)
cmp    $0x0,%eax
jne    148b <node_transcode_worker+0x22b>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x10(%rbp)
lea    -0x820(%rbp),%rcx
lea    0xbb4(%rip),%rsi
lea    0xbb0(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1150 <execlp@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
lea    -0x8a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1090 <memset@plt>
lea    -0x8a0(%rbp),%rdi
mov    -0x8a8(%rbp),%edx
lea    0xb75(%rip),%rsi
call   1130 <sprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8cc(%rbp)
lea    -0x8a0(%rbp),%rax
mov    %rax,-0x8c8(%rbp)
lea    -0x8a0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x8cc(%rbp),%edi
mov    -0x8c8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    1518 <node_transcode_worker+0x2b8>
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
mov    %rax,%rsi
lea    0xb25(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    151d <node_transcode_worker+0x2bd>
mov    -0x8a8(%rbp),%edi
mov    0x2ab6(%rip),%rax
mov    (%rax),%edx
mov    0x2a95(%rip),%rax
or     (%rax),%edx
lea    -0x8ac(%rbp),%rsi
call   1100 <waitpid@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1577 <node_transcode_worker+0x317>
mov    0x2a83(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
mov    %rax,%rsi
lea    0xade(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
mov    -0x8ac(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1591 <node_transcode_worker+0x331>
jmp    15ee <node_transcode_worker+0x38e>
mov    -0x8ac(%rbp),%edi
call   10b0 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     15ab <node_transcode_worker+0x34b>
jmp    15e9 <node_transcode_worker+0x389>
mov    -0x8ac(%rbp),%edi
call   10d0 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     15c5 <node_transcode_worker+0x365>
jmp    15e4 <node_transcode_worker+0x384>
mov    -0x8ac(%rbp),%edi
call   10c0 <WIFCONTINUED@plt>
cmp    $0x0,%rax
je     15df <node_transcode_worker+0x37f>
jmp    15df <node_transcode_worker+0x37f>
jmp    15e4 <node_transcode_worker+0x384>
jmp    15e9 <node_transcode_worker+0x389>
jmp    15ee <node_transcode_worker+0x38e>
jmp    15f3 <node_transcode_worker+0x393>
mov    -0x8ac(%rbp),%edi
call   1120 <WIFEXITED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x8cd(%rbp)
jne    162d <node_transcode_worker+0x3cd>
mov    -0x8ac(%rbp),%edi
call   10b0 <WIFSIGNALED@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x8cd(%rbp)
mov    -0x8cd(%rbp),%al
test   $0x1,%al
jne    151d <node_transcode_worker+0x2bd>
cmpl   $0x0,-0x10(%rbp)
je     1654 <node_transcode_worker+0x3f4>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x10(%rbp)
jmp    1659 <node_transcode_worker+0x3f9>
jmp    167c <node_transcode_worker+0x41c>
cmpl   $0x0,-0x10(%rbp)
je     1677 <node_transcode_worker+0x417>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x10(%rbp)
jmp    167c <node_transcode_worker+0x41c>
mov    -0xc(%rbp),%esi
lea    0x9cf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x820(%rbp),%rsi
lea    0x9d4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12af <node_transcode_worker+0x4f>

x86 assembly (clang, -O2):
<node_transcode_worker>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8a8,%rsp
mov    %edi,%r12d
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
xor    %eax,%eax
call   10f0 <zombie_listen@plt>
lea    0x18(%rsp),%r14
lea    0x14(%rsp),%r15
mov    0x2d3c(%rip),%rbx
lea    0xd5d(%rip),%r13
movl   $0x0,0xc(%rsp)
jmp    12ea <node_transcode_worker+0x8a>
mov    0x2d24(%rip),%rbx
lea    0xd45(%rip),%r13
lea    0xa0(%rsp),%rbp
mov    0xc(%rsp),%esi
lea    0xd87(%rip),%rdi
mov    %esi,0xc(%rsp)
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd8f(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1110 <accept@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1333 <node_transcode_worker+0xd3>
nop
mov    (%rbx),%edi
call   1160 <strerror@plt>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2710,%edi
call   1180 <usleep@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
je     1300 <node_transcode_worker+0xa0>
mov    %eax,%ebp
xor    %eax,%eax
call   1170 <fork@plt>
test   %eax,%eax
je     1360 <node_transcode_worker+0x100>
test   %ebp,%ebp
je     12bb <node_transcode_worker+0x5b>
mov    %ebp,%edi
call   10a0 <close@plt>
jmp    12bb <node_transcode_worker+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xa0(%rsp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1090 <memset@plt>
mov    %ebp,%edi
lea    0xa0(%rsp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     1540 <node_transcode_worker+0x2e0>
cmp    $0xf,%eax
mov    %eax,0xc(%rsp)
jg     1407 <node_transcode_worker+0x1a7>
lea    0xc72(%rip),%rdi
call   1050 <strlen@plt>
lea    0xa0(%rsp),%rdi
lea    0xc5e(%rip),%rsi
mov    %eax,%edx
call   10e0 <strncasecmp@plt>
test   %eax,%eax
je     1500 <node_transcode_worker+0x2a0>
lea    0xc4d(%rip),%rdi
call   1050 <strlen@plt>
lea    0xa0(%rsp),%rdi
lea    0xc39(%rip),%rsi
mov    %eax,%edx
call   10e0 <strncasecmp@plt>
test   %eax,%eax
jne    133e <node_transcode_worker+0xde>
mov    %ebp,%edi
lea    0xa0(%rsp),%rbp
mov    %rbp,%rsi
call   1080 <process_get_resource@plt>
jmp    12c3 <node_transcode_worker+0x63>
xor    %eax,%eax
call   1170 <fork@plt>
test   %eax,%eax
je     1562 <node_transcode_worker+0x302>
mov    %eax,%r13d
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1090 <memset@plt>
mov    %rbx,%rdi
lea    0xbf0(%rip),%rsi
mov    %r13d,%edx
call   1130 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    1479 <node_transcode_worker+0x219>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xbc7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2b60(%rip),%rbx
mov    0x2b41(%rip),%rax
mov    (%rax),%edx
or     (%rbx),%edx
mov    %r13d,%edi
lea    0x10(%rsp),%rsi
call   1100 <waitpid@plt>
cmp    $0xffffffff,%eax
je     1517 <node_transcode_worker+0x2b7>
mov    0x10(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %rax,%rax
jne    14d0 <node_transcode_worker+0x270>
mov    0x10(%rsp),%edi
call   10b0 <WIFSIGNALED@plt>
test   %rax,%rax
jne    14d0 <node_transcode_worker+0x270>
mov    0x10(%rsp),%edi
call   10d0 <WIFSTOPPED@plt>
test   %rax,%rax
jne    14d0 <node_transcode_worker+0x270>
mov    0x10(%rsp),%edi
call   10c0 <WIFCONTINUED@plt>
mov    0x10(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %rax,%rax
jne    14ec <node_transcode_worker+0x28c>
mov    0x10(%rsp),%edi
call   10b0 <WIFSIGNALED@plt>
test   %rax,%rax
je     1480 <node_transcode_worker+0x220>
test   %ebp,%ebp
je     12ad <node_transcode_worker+0x4d>
mov    %ebp,%edi
call   10a0 <close@plt>
jmp    12ad <node_transcode_worker+0x4d>
mov    %ebp,%edi
lea    0xa0(%rsp),%rbp
mov    %rbp,%rsi
call   1040 <process_cancel@plt>
jmp    12c3 <node_transcode_worker+0x63>
mov    0x2aba(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
lea    0xb18(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
mov    (%rbx),%edi
call   1160 <strerror@plt>
lea    0xabc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
lea    0xab1(%rip),%rdi
lea    0xaad(%rip),%rdx
lea    0xa0(%rsp),%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
call   1150 <execlp@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"accept:%s\00"
@errno = global i32 0
@.str.1 = [11 x i8] c"recv:[%s]\0A\00"
@.str.2 = [5 x i8] c"pid=\00"
@.str.3 = [7 x i8] c"getcpu\00"
@.str.4 = [3 x i8] c"sh\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [15 x i8] c"waiting pid=%d\00"
@.str.7 = [14 x i8] c"child-send:%s\00"
@WUNTRACED = global i32 0
@WCONTINUED = global i32 0
@.str.8 = [17 x i8] c"child:waitpid:%s\00"
@.str.9 = [26 x i8] c"recvied buffer size = %d\0A\00"
@.str.10 = [23 x i8] c"recvied byffer = [%s]\0A\00"
define i32 @node_transcode_worker(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [2048 x i8]
%9 = alloca [128 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = call i32 (...) @zombie_listen()
br label %14
14: ; preds = %1, %19, %158
%15 = load i32, i32* %2
%16 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%17 = call i32 @accept(i32 %15, %struct.sockaddr* %16, i32* %6)
store i32 %17, i32* %5
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @usleep(i32 10000)
br label %14
24: ; preds = %14
%25 = call i32 (...) @fork()
store i32 %25, i32* %10
%26 = icmp ne i32 %25, 0
br i1 %26, label %151, label %27
27: ; preds = %24
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i32 0, i32 2048)
%30 = load i32, i32* %5
%31 = bitcast [2048 x i8]* %8 to i8**
%32 = call i32 @recv(i32 %30, i8** %31, i32 2048, i32 0)
store i32 %32, i32* %4
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %39
34: ; preds = %27
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %27
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 16
br i1 %41, label %42, label %69
42: ; preds = %39
%43 = bitcast [2048 x i8]* %8 to i8*
%44 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @strncasecmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %42
%48 = load i32, i32* %5
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%50 = call i32 @process_cancel(i32 %48, i8* %49)
store i32 %50, i32* %3
br label %68
51: ; preds = %42
%52 = bitcast [2048 x i8]* %8 to i8*
%53 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @strncasecmp(i8* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %51
%57 = load i32, i32* %5
%58 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%59 = call i32 @process_get_resource(i32 %57, i8* %58)
br label %67
60: ; preds = %51
%61 = load i32, i32* %5
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i32, i32* %5
%65 = call i32 @close(i32 %64)
store i32 0, i32* %5
br label %66
66: ; preds = %63, %60
br label %67
67: ; preds = %66, %56
br label %68
68: ; preds = %67, %47
br label %150
69: ; preds = %39
%70 = call i32 (...) @fork()
store i32 %70, i32* %11
%71 = icmp ne i32 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %69
%73 = load i32, i32* %5
%74 = call i32 @close(i32 %73)
store i32 0, i32* %5
%75 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%76 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %75, i32* null)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %69
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%80 = call i32 @memset(i8* %79, i32 0, i32 128)
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%82 = load i32, i32* %11
%83 = call i32 @sprintf(i8* %81, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %5
%85 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%87 = call i32 @strlen(i8* %86)
%88 = call i32 @send(i32 %84, i8* %85, i32 %87, i32 0)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %78
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %90, %78
br label %95
95: ; preds = %141, %94
%96 = load i32, i32* %11
%97 = load i32, i32* @WUNTRACED
%98 = load i32, i32* @WCONTINUED
%99 = or i32 %97, %98
%100 = call i32 @waitpid(i32 %96, i32* %12, i32 %99)
store i32 %100, i32* %3
%101 = load i32, i32* %3
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %108
103: ; preds = %95
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %105)
%107 = call i32 @exit(i32 -1)
unreachable
108: ; preds = %95
%109 = load i32, i32* %12
%110 = call i64 @WIFEXITED(i32 %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %113
112: ; preds = %108
br label %131
113: ; preds = %108
%114 = load i32, i32* %12
%115 = call i64 @WIFSIGNALED(i32 %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %113
br label %130
118: ; preds = %113
%119 = load i32, i32* %12
%120 = call i64 @WIFSTOPPED(i32 %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %118
br label %129
123: ; preds = %118
%124 = load i32, i32* %12
%125 = call i64 @WIFCONTINUED(i32 %124)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %123
br label %128
128: ; preds = %127, %123
br label %129
129: ; preds = %128, %122
br label %130
130: ; preds = %129, %117
br label %131
131: ; preds = %130, %112
br label %132
132: ; preds = %131
%133 = load i32, i32* %12
%134 = call i64 @WIFEXITED(i32 %133)
%135 = icmp ne i64 %134, 0
br i1 %135, label %141, label %136
136: ; preds = %132
%137 = load i32, i32* %12
%138 = call i64 @WIFSIGNALED(i32 %137)
%139 = icmp ne i64 %138, 0
%140 = xor i1 %139, true
br label %141
141: ; preds = %136, %132
%142 = phi i1 [ false, %132 ], [ %140, %136 ]
br i1 %142, label %95, label %143
143: ; preds = %141
%144 = load i32, i32* %5
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %143
%147 = load i32, i32* %5
%148 = call i32 @close(i32 %147)
store i32 0, i32* %5
br label %149
149: ; preds = %146, %143
br label %150
150: ; preds = %149, %68
br label %158
151: ; preds = %24
%152 = load i32, i32* %5
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %157
154: ; preds = %151
%155 = load i32, i32* %5
%156 = call i32 @close(i32 %155)
store i32 0, i32* %5
br label %157
157: ; preds = %154, %151
br label %158
158: ; preds = %157, %150
%159 = load i32, i32* %4
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %159)
%161 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %161)
br label %14
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"accept:%s\00"
@errno = global i32 0
@.str.1 = [11 x i8] c"recv:[%s]\0A\00"
@.str.2 = [5 x i8] c"pid=\00"
@.str.3 = [7 x i8] c"getcpu\00"
@.str.4 = [3 x i8] c"sh\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [15 x i8] c"waiting pid=%d\00"
@.str.7 = [14 x i8] c"child-send:%s\00"
@WUNTRACED = global i32 0
@WCONTINUED = global i32 0
@.str.8 = [17 x i8] c"child:waitpid:%s\00"
@.str.9 = [26 x i8] c"recvied buffer size = %d\0A\00"
@.str.10 = [23 x i8] c"recvied byffer = [%s]\0A\00"
define i32 @node_transcode_worker(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca [2048 x i8]
%5 = alloca [128 x i8]
%6 = alloca i32
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = tail call i32 (...) @zombie_listen()
%13 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%14 = bitcast [2048 x i8]* %4 to i8**
br label %15
15: ; preds = %117, %1
%16 = phi i32 [ %118, %117 ], [ 0, %1 ]
%17 = call i32 @accept(i32 %0, %struct.sockaddr* %13, i32* %2)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %26
19: ; preds = %15, %19
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @usleep(i32 10000)
%24 = call i32 @accept(i32 %0, %struct.sockaddr* %13, i32* %2)
%25 = icmp eq i32 %24, -1
br i1 %25, label %19, label %26
26: ; preds = %19, %15
%27 = phi i32 [ %17, %15 ], [ %24, %19 ]
%28 = call i32 (...) @fork()
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %113
30: ; preds = %26
%31 = call i32 @memset(i8* %9, i32 0, i32 2048)
%32 = call i32 @recv(i32 %27, i8** %14, i32 2048, i32 0)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %30
%40 = icmp slt i32 %32, 16
br i1 %40, label %41, label %57
41: ; preds = %39
%42 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @strncasecmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @process_cancel(i32 %27, i8* %9)
br label %117
47: ; preds = %41
%48 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%49 = call i32 @strncasecmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 @process_get_resource(i32 %27, i8* %9)
br label %117
53: ; preds = %47
%54 = icmp eq i32 %27, 0
br i1 %54, label %117, label %55
55: ; preds = %53
%56 = call i32 @close(i32 %27)
br label %117
57: ; preds = %39
%58 = call i32 (...) @fork()
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = call i32 @close(i32 %27)
%62 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %9, i32* null)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %57
%65 = call i32 @memset(i8* %10, i32 0, i32 128)
%66 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %58)
%67 = call i32 @strlen(i8* %10)
%68 = call i32 @send(i32 %27, i8* %10, i32 %67, i32 0)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %64
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %70, %64
br label %75
75: ; preds = %74, %105
%76 = load i32, i32* @WUNTRACED
%77 = load i32, i32* @WCONTINUED
%78 = or i32 %77, %76
%79 = call i32 @waitpid(i32 %58, i32* %6, i32 %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %86
81: ; preds = %75
%82 = load i32, i32* @errno
%83 = call i8* @strerror(i32 %82)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %83)
%85 = call i32 @exit(i32 -1)
unreachable
86: ; preds = %75
%87 = load i32, i32* %6
%88 = call i64 @WIFEXITED(i32 %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %101
90: ; preds = %86
%91 = load i32, i32* %6
%92 = call i64 @WIFSIGNALED(i32 %91)
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %101
94: ; preds = %90
%95 = load i32, i32* %6
%96 = call i64 @WIFSTOPPED(i32 %95)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = load i32, i32* %6
%100 = call i64 @WIFCONTINUED(i32 %99)
br label %101
101: ; preds = %86, %98, %94, %90
%102 = load i32, i32* %6
%103 = call i64 @WIFEXITED(i32 %102)
%104 = icmp eq i64 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = load i32, i32* %6
%107 = call i64 @WIFSIGNALED(i32 %106)
%108 = icmp eq i64 %107, 0
br i1 %108, label %75, label %109
109: ; preds = %101, %105
%110 = icmp eq i32 %27, 0
br i1 %110, label %117, label %111
111: ; preds = %109
%112 = call i32 @close(i32 %27)
br label %117
113: ; preds = %26
%114 = icmp eq i32 %27, 0
br i1 %114, label %117, label %115
115: ; preds = %113
%116 = call i32 @close(i32 %27)
br label %117
117: ; preds = %113, %115, %51, %55, %53, %45, %111, %109
%118 = phi i32 [ %16, %115 ], [ %16, %113 ], [ %32, %55 ], [ %32, %53 ], [ %32, %51 ], [ %32, %45 ], [ %32, %111 ], [ %32, %109 ]
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %118)
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %9)
br label %15
}