#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*/ unixfile;
typedef int /*<<< orphan*/ template;
typedef int /*<<< orphan*/ sockpath;
typedef int pid_t;

/* Variables and functions */
scalar_t__ ECHILD;
scalar_t__ EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WSTOPSIG(int);
int WTERMSIG(int);
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ child1_main(char *);
int /*<<< orphan*/ child2_main(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int getpid();
char *mkdtemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int recursive_sockets();
int rmdir(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int /*<<< orphan*/ stderr;
int unlink(char *);
int waitpid(int, int *, int /*<<< orphan*/);
int main(void) {
  const char unixfile[] = "unix.sock";
  char template[] = "/tmp/pass-fd-XXXXXX", *dirpath;
  char sockpath[sizeof(template) + sizeof(unixfile)];
  pid_t child1, child2, pid;
  int status = 0, return_value = 0;
  dirpath = mkdtemp(template);
  if (!dirpath) {
    perror("mkdtemp");
    return 1;
  }
  snprintf(sockpath, sizeof(sockpath), "%s/%s", dirpath, unixfile);
  child1 = fork();
  if (child1 == -1) {
    perror("fork");
    return 1;
  } else if (child1 == 0) {
    printf("[%u] Start first child\n", getpid());
    exit(child1_main(sockpath));
  }
  child2 = fork();
  if (child2 == -1) {
    perror("fork");
    return 1;
  } else if (child2 == 0) {
    printf("[%u] Start second child\n", getpid());
    exit(child2_main(sockpath));
  }
  for (;;) {
    pid = waitpid(-1, &status, 0);
    if (pid == -1) {
      if (errno == ECHILD) {
        break;
      }
      perror("waitpid");
      return 1;
    }
    if (WIFEXITED(status)) {
      if (WEXITSTATUS(status) != EXIT_SUCCESS) {
        fprintf(stderr, "Child %u exited with status %d\n", pid,
                WEXITSTATUS(status));
        return_value = 1;
      } else {
        printf("[parent] Child %u successfully exited\n", pid);
      }
    } else if (WIFSIGNALED(status)) {
      fprintf(stderr, "Child %u was killed by signal %d\n", pid,
              WTERMSIG(status));
      return_value = 1;
    } else if (WIFSTOPPED(status)) {
      fprintf(stderr, "Child %u has been stopped by signal %d\n", pid,
              WSTOPSIG(status));
      return_value = 1;
    } else {
      fprintf(stderr, "Child %u has been waited with unexpected status %d\n",
              pid, status);
      return_value = 1;
    }
  }
  if (access(sockpath, F_OK) == 0) {
    if (unlink(sockpath) == -1) {
      perror("unlink");
      return 1;
    }
  }
  if (rmdir(dirpath) == -1) {
    perror("rmdir");
    return 1;
  }
  if (!return_value) {
    return_value = recursive_sockets();
  }
  return return_value;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xd97(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xd94(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0x30(%rbp),%rdi
call   10e0 <mkdtemp@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12d5 <main+0x85>
lea    0xd46(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rcx
lea    -0xe(%rbp),%r8
mov    $0x1e,%esi
lea    0xd25(%rip),%rdx
call   1090 <snprintf@plt>
mov    $0x0,%al
call   1170 <fork@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    131e <main+0xce>
lea    0xd0b(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
cmpl   $0x0,-0x64(%rbp)
jne    134d <main+0xfd>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xce5(%rip),%rdi
call   1080 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <child1_main@plt>
mov    %eax,%edi
call   1150 <exit@plt>
jmp    1352 <main+0x102>
mov    $0x0,%al
call   1170 <fork@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    137e <main+0x12e>
lea    0xcab(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
cmpl   $0x0,-0x68(%rbp)
jne    13ad <main+0x15d>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xc9d(%rip),%rdi
call   1080 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1140 <child2_main@plt>
mov    %eax,%edi
call   1150 <exit@plt>
jmp    13b2 <main+0x162>
jmp    13b7 <main+0x167>
mov    $0xffffffff,%edi
lea    -0x70(%rbp),%rsi
xor    %edx,%edx
call   1100 <waitpid@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    140b <main+0x1bb>
mov    0x2bfd(%rip),%rax
mov    (%rax),%rax
mov    0x2beb(%rip),%rcx
cmp    (%rcx),%rax
jne    13f3 <main+0x1a3>
jmp    1560 <main+0x310>
lea    0xc54(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
mov    -0x70(%rbp),%edi
call   1130 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1485 <main+0x235>
mov    -0x70(%rbp),%edi
call   10f0 <WEXITSTATUS@plt>
cltq
mov    0x2b9a(%rip),%rcx
cmp    (%rcx),%rax
je     1471 <main+0x221>
mov    0x2ba2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x70(%rbp),%edi
call   10f0 <WEXITSTATUS@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%edx
mov    %eax,%ecx
lea    0xbf6(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x1,-0x74(%rbp)
jmp    1480 <main+0x230>
mov    -0x6c(%rbp),%esi
lea    0xbfb(%rip),%rdi
call   1080 <printf@plt>
jmp    155b <main+0x30b>
mov    -0x70(%rbp),%edi
call   10a0 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     14d7 <main+0x287>
mov    0x2b42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x70(%rbp),%edi
call   10d0 <WTERMSIG@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%edx
mov    %eax,%ecx
lea    0xbd7(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x1,-0x74(%rbp)
jmp    1556 <main+0x306>
mov    -0x70(%rbp),%edi
call   10c0 <WIFSTOPPED@plt>
cmp    $0x0,%rax
je     152f <main+0x2df>
mov    0x2af0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x70(%rbp),%edi
call   1160 <WSTOPSIG@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%edx
mov    %eax,%ecx
lea    0xba1(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x1,-0x74(%rbp)
jmp    1551 <main+0x301>
mov    0x2aaa(%rip),%rax
mov    (%rax),%edi
mov    -0x6c(%rbp),%edx
mov    -0x70(%rbp),%ecx
lea    0xba2(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x1,-0x74(%rbp)
jmp    1556 <main+0x306>
jmp    155b <main+0x30b>
jmp    13b7 <main+0x167>
lea    -0x60(%rbp),%rdi
mov    0x2a4d(%rip),%rax
mov    (%rax),%esi
call   1110 <access@plt>
cmp    $0x0,%rax
jne    15ab <main+0x35b>
lea    -0x60(%rbp),%rdi
call   1040 <unlink@plt>
cmp    $0xffffffff,%eax
jne    15a6 <main+0x356>
lea    0xb86(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
jmp    15ab <main+0x35b>
mov    -0x38(%rbp),%rdi
call   1070 <rmdir@plt>
cmp    $0xffffffff,%eax
jne    15d5 <main+0x385>
lea    0xb5e(%rip),%rdi
call   1120 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15ef <main+0x39f>
cmpl   $0x0,-0x74(%rbp)
jne    15e9 <main+0x399>
mov    $0x0,%al
call   1050 <recursive_sockets@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movabs $0x636f732e78696e75,%rax
73 6f 63
mov    %rax,0x8(%rsp)
movw   $0x6b,0x10(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movl   $0x585858,0x50(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x40(%rsp),%rdi
call   10e0 <mkdtemp@plt>
test   %rax,%rax
je     1493 <main+0x243>
mov    %rax,%rbx
lea    0xd65(%rip),%rdx
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%r8
mov    $0x1e,%esi
mov    %rax,%rcx
call   1090 <snprintf@plt>
xor    %eax,%eax
call   1170 <fork@plt>
cmp    $0xffffffff,%eax
je     148a <main+0x23a>
test   %eax,%eax
je     14ce <main+0x27e>
xor    %eax,%eax
call   1170 <fork@plt>
cmp    $0xffffffff,%eax
je     148a <main+0x23a>
mov    %rbx,0x18(%rsp)
test   %eax,%eax
je     14f4 <main+0x2a4>
lea    0x4(%rsp),%rsi
xor    %ebp,%ebp
mov    $0xffffffff,%edi
xor    %edx,%edx
call   1100 <waitpid@plt>
cmp    $0xffffffff,%eax
je     142c <main+0x1dc>
mov    %eax,%r15d
xor    %ebp,%ebp
mov    0x2cbf(%rip),%r13
lea    0x4(%rsp),%rbx
mov    0x2c9b(%rip),%r14
lea    0xd42(%rip),%r12
jmp    1366 <main+0x116>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15d,%esi
call   1080 <printf@plt>
mov    $0xffffffff,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1100 <waitpid@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
je     142c <main+0x1dc>
mov    0x4(%rsp),%edi
call   1130 <WIFEXITED@plt>
mov    0x4(%rsp),%edi
test   %rax,%rax
je     13a0 <main+0x150>
call   10f0 <WEXITSTATUS@plt>
cltq
cmp    %rax,(%r14)
je     1340 <main+0xf0>
mov    0x0(%r13),%ebp
mov    0x4(%rsp),%edi
call   10f0 <WEXITSTATUS@plt>
mov    %ebp,%edi
lea    0xcbc(%rip),%rsi
jmp    13c0 <main+0x170>
nopl   0x0(%rax)
call   10a0 <WIFSIGNALED@plt>
test   %rax,%rax
je     13d4 <main+0x184>
mov    0x0(%r13),%ebp
mov    0x4(%rsp),%edi
call   10d0 <WTERMSIG@plt>
mov    %ebp,%edi
lea    0xcdd(%rip),%rsi
mov    %r15d,%edx
mov    %eax,%ecx
call   10b0 <fprintf@plt>
mov    $0x1,%ebp
jmp    134b <main+0xfb>
mov    %r13,%rbp
mov    %r12,%rbx
mov    0x4(%rsp),%edi
call   10c0 <WIFSTOPPED@plt>
mov    0x0(%r13),%r12d
mov    0x4(%rsp),%ecx
test   %rax,%rax
je     1408 <main+0x1b8>
mov    %ecx,%edi
call   1160 <WSTOPSIG@plt>
mov    %r12d,%edi
lea    0xcbe(%rip),%rsi
mov    %r15d,%edx
mov    %eax,%ecx
jmp    1415 <main+0x1c5>
mov    %r12d,%edi
lea    0xcd5(%rip),%rsi
mov    %r15d,%edx
call   10b0 <fprintf@plt>
mov    $0x1,%ebp
mov    %rbx,%r12
lea    0x4(%rsp),%rbx
jmp    134b <main+0xfb>
mov    0x2ba5(%rip),%rax
mov    (%rax),%rax
mov    0x2b93(%rip),%rcx
cmp    (%rcx),%rax
jne    149c <main+0x24c>
mov    0x2b6f(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdi
call   1110 <access@plt>
test   %rax,%rax
jne    1469 <main+0x219>
lea    0x20(%rsp),%rdi
call   1040 <unlink@plt>
cmp    $0xffffffff,%eax
je     14ae <main+0x25e>
mov    0x18(%rsp),%rdi
call   1070 <rmdir@plt>
cmp    $0xffffffff,%eax
je     14a5 <main+0x255>
mov    $0x1,%eax
test   %ebp,%ebp
jne    14bf <main+0x26f>
xor    %eax,%eax
call   1050 <recursive_sockets@plt>
jmp    14bf <main+0x26f>
lea    0xb87(%rip),%rdi
jmp    14b5 <main+0x265>
lea    0xb70(%rip),%rdi
jmp    14b5 <main+0x265>
lea    0xbab(%rip),%rdi
jmp    14b5 <main+0x265>
lea    0xc76(%rip),%rdi
jmp    14b5 <main+0x265>
lea    0xc66(%rip),%rdi
call   1120 <perror@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xb41(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
lea    0x20(%rsp),%rdi
call   1030 <child1_main@plt>
mov    %eax,%edi
call   1150 <exit@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xb33(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
lea    0x20(%rsp),%rdi
call   1140 <child2_main@plt>
mov    %eax,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
@__const.main.unixfile = [10 x i8] c"unix.sock\00"
@__const.main.template = [20 x i8] c"/tmp/pass-fd-XXXXXX\00"
@.str = [8 x i8] c"mkdtemp\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [5 x i8] c"fork\00"
@.str.3 = [24 x i8] c"[%u] Start first child\0A\00"
@.str.4 = [25 x i8] c"[%u] Start second child\0A\00"
@errno = global i64 0
@ECHILD = global i64 0
@.str.5 = [8 x i8] c"waitpid\00"
@EXIT_SUCCESS = global i64 0
@stderr = global i32 0
@.str.6 = [32 x i8] c"Child %u exited with status %d\0A\00"
@.str.7 = [39 x i8] c"[parent] Child %u successfully exited\0A\00"
@.str.8 = [34 x i8] c"Child %u was killed by signal %d\0A\00"
@.str.9 = [40 x i8] c"Child %u has been stopped by signal %d\0A\00"
@.str.10 = [52 x i8] c"Child %u has been waited with unexpected status %d\0A\00"
@F_OK = global i32 0
@.str.11 = [7 x i8] c"unlink\00"
@.str.12 = [6 x i8] c"rmdir\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [20 x i8]
%4 = alloca i8*
%5 = alloca [30 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = bitcast [10 x i8]* %2 to i8*
%12 = bitcast [20 x i8]* %3 to i8*
store i32 0, i32* %9
store i32 0, i32* %10
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%14 = call i8* @mkdtemp(i8* %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %140
19: ; preds = %0
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i32 @snprintf(i8* %20, i32 30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22)
%24 = call i32 (...) @fork()
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %140
29: ; preds = %19
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 (...) @getpid()
%34 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%36 = call i32 @child1_main(i8* %35)
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %29
br label %39
39: ; preds = %38
%40 = call i32 (...) @fork()
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %140
45: ; preds = %39
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = call i32 (...) @getpid()
%50 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%52 = call i32 @child2_main(i8* %51)
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %45
br label %55
55: ; preds = %54
br label %56
56: ; preds = %114, %55
%57 = call i32 @waitpid(i32 -1, i32* %9, i32 0)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load i64, i64* @errno
%62 = load i64, i64* @ECHILD
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %65
64: ; preds = %60
br label %115
65: ; preds = %60
%66 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %140
67: ; preds = %56
%68 = load i32, i32* %9
%69 = call i64 @WIFEXITED(i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %87
71: ; preds = %67
%72 = load i32, i32* %9
%73 = call i32 @WEXITSTATUS(i32 %72)
%74 = sext i32 %73 to i64
%75 = load i64, i64* @EXIT_SUCCESS
%76 = icmp ne i64 %74, %75
br i1 %76, label %77, label %83
77: ; preds = %71
%78 = load i32, i32* @stderr
%79 = load i32, i32* %8
%80 = load i32, i32* %9
%81 = call i32 @WEXITSTATUS(i32 %80)
%82 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %79, i32 %81)
store i32 1, i32* %10
br label %86
83: ; preds = %71
%84 = load i32, i32* %8
%85 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %83, %77
br label %114
87: ; preds = %67
%88 = load i32, i32* %9
%89 = call i64 @WIFSIGNALED(i32 %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %97
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = load i32, i32* %8
%94 = load i32, i32* %9
%95 = call i32 @WTERMSIG(i32 %94)
%96 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %93, i32 %95)
store i32 1, i32* %10
br label %113
97: ; preds = %87
%98 = load i32, i32* %9
%99 = call i64 @WIFSTOPPED(i32 %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %97
%102 = load i32, i32* @stderr
%103 = load i32, i32* %8
%104 = load i32, i32* %9
%105 = call i32 @WSTOPSIG(i32 %104)
%106 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %103, i32 %105)
store i32 1, i32* %10
br label %112
107: ; preds = %97
%108 = load i32, i32* @stderr
%109 = load i32, i32* %8
%110 = load i32, i32* %9
%111 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0), i32 %109, i32 %110)
store i32 1, i32* %10
br label %112
112: ; preds = %107, %101
br label %113
113: ; preds = %112, %91
br label %114
114: ; preds = %113, %86
br label %56
115: ; preds = %64
%116 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%117 = load i32, i32* @F_OK
%118 = call i64 @access(i8* %116, i32 %117)
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %127
120: ; preds = %115
%121 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%122 = call i32 @unlink(i8* %121)
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %126
124: ; preds = %120
%125 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %1
br label %140
126: ; preds = %120
br label %127
127: ; preds = %126, %115
%128 = load i8*, i8** %4
%129 = call i32 @rmdir(i8* %128)
%130 = icmp eq i32 %129, -1
br i1 %130, label %131, label %133
131: ; preds = %127
%132 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %1
br label %140
133: ; preds = %127
%134 = load i32, i32* %10
%135 = icmp ne i32 %134, 0
br i1 %135, label %138, label %136
136: ; preds = %133
%137 = call i32 (...) @recursive_sockets()
store i32 %137, i32* %10
br label %138
138: ; preds = %136, %133
%139 = load i32, i32* %10
store i32 %139, i32* %1
br label %140
140: ; preds = %138, %131, %124, %65, %43, %27, %17
%141 = load i32, i32* %1
ret i32 %141
}

LLVM IR (-O2):
@__const.main.unixfile = [10 x i8] c"unix.sock\00"
@__const.main.template = [20 x i8] c"/tmp/pass-fd-XXXXXX\00"
@.str = [8 x i8] c"mkdtemp\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [5 x i8] c"fork\00"
@.str.3 = [24 x i8] c"[%u] Start first child\0A\00"
@.str.4 = [25 x i8] c"[%u] Start second child\0A\00"
@errno = global i64 0
@ECHILD = global i64 0
@.str.5 = [8 x i8] c"waitpid\00"
@EXIT_SUCCESS = global i64 0
@stderr = global i32 0
@.str.6 = [32 x i8] c"Child %u exited with status %d\0A\00"
@.str.7 = [39 x i8] c"[parent] Child %u successfully exited\0A\00"
@.str.8 = [34 x i8] c"Child %u was killed by signal %d\0A\00"
@.str.9 = [40 x i8] c"Child %u has been stopped by signal %d\0A\00"
@.str.10 = [52 x i8] c"Child %u has been waited with unexpected status %d\0A\00"
@F_OK = global i32 0
@.str.11 = [7 x i8] c"unlink\00"
@.str.12 = [6 x i8] c"rmdir\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [20 x i8]
%3 = alloca [30 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i8* @mkdtemp(i8* %6)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %102
13: ; preds = %0
%14 = call i32 @snprintf(i8* %7, i32 30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %5)
%15 = call i32 (...) @fork()
switch i32 %15, label %23 [
i32 -1, label %16
i32 0, label %18
]
16: ; preds = %13
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %102
18: ; preds = %13
%19 = call i32 (...) @getpid()
%20 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 @child1_main(i8* %7)
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %13
%24 = call i32 (...) @fork()
switch i32 %24, label %25 [
i32 -1, label %28
i32 0, label %30
]
25: ; preds = %23
%26 = call i32 @waitpid(i32 -1, i32* %4, i32 0)
%27 = icmp eq i32 %26, -1
br i1 %27, label %35, label %42
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %102
30: ; preds = %23
%31 = call i32 (...) @getpid()
%32 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = call i32 @child2_main(i8* %7)
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %80, %25
%36 = phi i32 [ 0, %25 ], [ %81, %80 ]
%37 = load i64, i64* @errno
%38 = load i64, i64* @ECHILD
%39 = icmp eq i64 %37, %38
br i1 %39, label %84, label %40
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %102
42: ; preds = %25, %80
%43 = phi i32 [ %82, %80 ], [ %26, %25 ]
%44 = phi i32 [ %81, %80 ], [ 0, %25 ]
%45 = load i32, i32* %4
%46 = call i64 @WIFEXITED(i32 %45)
%47 = icmp eq i64 %46, 0
%48 = load i32, i32* %4
br i1 %47, label %61, label %49
49: ; preds = %42
%50 = call i32 @WEXITSTATUS(i32 %48)
%51 = sext i32 %50 to i64
%52 = load i64, i64* @EXIT_SUCCESS
%53 = icmp eq i64 %52, %51
br i1 %53, label %59, label %54
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = load i32, i32* %4
%57 = call i32 @WEXITSTATUS(i32 %56)
%58 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %43, i32 %57)
br label %80
59: ; preds = %49
%60 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %43)
br label %80
61: ; preds = %42
%62 = call i64 @WIFSIGNALED(i32 %48)
%63 = icmp eq i64 %62, 0
br i1 %63, label %69, label %64
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = load i32, i32* %4
%67 = call i32 @WTERMSIG(i32 %66)
%68 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i32 %43, i32 %67)
br label %80
69: ; preds = %61
%70 = load i32, i32* %4
%71 = call i64 @WIFSTOPPED(i32 %70)
%72 = icmp eq i64 %71, 0
%73 = load i32, i32* @stderr
%74 = load i32, i32* %4
br i1 %72, label %78, label %75
75: ; preds = %69
%76 = call i32 @WSTOPSIG(i32 %74)
%77 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %43, i32 %76)
br label %80
78: ; preds = %69
%79 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0), i32 %43, i32 %74)
br label %80
80: ; preds = %64, %78, %75, %54, %59
%81 = phi i32 [ 1, %54 ], [ %44, %59 ], [ 1, %64 ], [ 1, %75 ], [ 1, %78 ]
%82 = call i32 @waitpid(i32 -1, i32* %4, i32 0)
%83 = icmp eq i32 %82, -1
br i1 %83, label %35, label %42
84: ; preds = %35
%85 = load i32, i32* @F_OK
%86 = call i64 @access(i8* %7, i32 %85)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %93
88: ; preds = %84
%89 = call i32 @unlink(i8* %7)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %93
91: ; preds = %88
%92 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %102
93: ; preds = %88, %84
%94 = call i32 @rmdir(i8* %9)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %102
98: ; preds = %93
%99 = icmp eq i32 %36, 0
br i1 %99, label %100, label %102
100: ; preds = %98
%101 = call i32 (...) @recursive_sockets()
br label %102
102: ; preds = %98, %100, %96, %91, %40, %28, %16, %11
%103 = phi i32 [ 1, %16 ], [ 1, %28 ], [ 1, %91 ], [ 1, %96 ], [ 1, %40 ], [ 1, %11 ], [ 1, %98 ], [ %101, %100 ]
ret i32 %103
}