#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 pid_t;

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int);
int /*<<< orphan*/ stderr;
int waitpid(int, int *, int /*<<< orphan*/);
int WaitChild(pid_t pid, const char *name) {
  int err, status;
  do {
    err = waitpid(pid, &status, 0);
  } while (err == -1 && errno == EINTR);
  if (err == -1) {
    {
      fprintf(stderr,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/"
              "src/main/tools/process-tools.c"
              ":"
              "136"
              ": "
              "wait on %s (pid %d) failed\n",
              name, pid);
      exit(EXIT_FAILURE);
    };
  }
  return status;
}


x86 assembly (clang, -O0):
<WaitChild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <waitpid@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jne    1179 <WaitChild+0x49>
mov    0x2e72(%rip),%rax
mov    (%rax),%rax
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    113f <WaitChild+0xf>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11b8 <WaitChild+0x88>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0xe5b(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WaitChild>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xc(%rsp),%r15
mov    0x2e8a(%rip),%r12
mov    0x2e73(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   1040 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    117b <WaitChild+0x4b>
mov    0x0(%r13),%rcx
cmp    %rcx,(%r12)
je     1160 <WaitChild+0x30>
cmp    $0xffffffff,%eax
je     1192 <WaitChild+0x62>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [190 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/process-tools.c:136: wait on %s (pid %d) failed\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @WaitChild(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
br label %7
7: ; preds = %17, %2
%8 = load i32, i32* %3
%9 = call i32 @waitpid(i32 %8, i32* %6, i32 0)
store i32 %9, i32* %5
br label %10
10: ; preds = %7
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* @errno
%15 = load i64, i64* @EINTR
%16 = icmp eq i64 %14, %15
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %7, label %19
19: ; preds = %17
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = load i32, i32* %3
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([190 x i8], [190 x i8]* @.str, i64 0, i64 0), i8* %24, i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [190 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/process-tools.c:136: wait on %s (pid %d) failed\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @WaitChild(i32 %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = call i32 @waitpid(i32 %0, i32* %3, i32 0)
%7 = icmp eq i32 %6, -1
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINTR
%10 = icmp eq i64 %8, %9
%11 = select i1 %7, i1 %10, i1 false
br i1 %11, label %5, label %12
12: ; preds = %5
br i1 %7, label %13, label %18
13: ; preds = %12
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([190 x i8], [190 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %0)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %12
%19 = load i32, i32* %3
ret i32 %19
}