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

/* Variables and functions */
scalar_t__ SIGPIPE;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int WTERMSIG(int);
int /*<<< orphan*/ pm_message(char *, ...);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/ const, int *, int /*<<< orphan*/);
void cleanupFeederProcess(pid_t const feederPid) {
  int status;
  waitpid(feederPid, &status, 0);
  if (WIFSIGNALED(status)) {
    if (WTERMSIG(status) == SIGPIPE)
      pm_message("WARNING: "
                 "Standard Input feeder process was terminated by a "
                 "SIGPIPE signal because the program closed its "
                 "Standard Input before the Standard Input feeder was "
                 "through feeding it.");
    else
      pm_message("WARNING: "
                 "Standard Input feeder was terminated by a Signal %d.",
                 WTERMSIG(status));
  } else if (WIFEXITED(status)) {
    if (WEXITSTATUS(status) != 0)
      pm_message("WARNING: "
                 "Standard Input feeder process ended abnormally.  "
                 "exit status = %d",
                 WEXITSTATUS(status));
  } else
    pm_message("WARNING: "
               "Unrecognized process completion status from "
               "Standard Input feeder: %d",
               status);
}


x86 assembly (clang, -O0):
<cleanupFeederProcess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x8(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11d5 <cleanupFeederProcess+0x75>
mov    -0x8(%rbp),%edi
call   1050 <WTERMSIG@plt>
cltq
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
jne    11b8 <cleanupFeederProcess+0x58>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <pm_message@plt>
jmp    11d0 <cleanupFeederProcess+0x70>
mov    -0x8(%rbp),%edi
call   1050 <WTERMSIG@plt>
mov    %eax,%esi
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <pm_message@plt>
jmp    122b <cleanupFeederProcess+0xcb>
mov    -0x8(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1215 <cleanupFeederProcess+0xb5>
mov    -0x8(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
cmp    $0x0,%eax
je     1210 <cleanupFeederProcess+0xb0>
mov    -0x8(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <pm_message@plt>
jmp    1226 <cleanupFeederProcess+0xc6>
mov    -0x8(%rbp),%esi
lea    0xf1b(%rip),%rdi
mov    $0x0,%al
call   1030 <pm_message@plt>
jmp    122b <cleanupFeederProcess+0xcb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanupFeederProcess>:
push   %rax
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    0x4(%rsp),%edi
call   1040 <WIFSIGNALED@plt>
mov    0x4(%rsp),%edi
test   %rax,%rax
je     11a2 <cleanupFeederProcess+0x42>
call   1050 <WTERMSIG@plt>
cltq
mov    0x2e53(%rip),%rcx
cmp    %rax,(%rcx)
jne    11cf <cleanupFeederProcess+0x6f>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1030 <pm_message@plt>
pop    %rax
ret
call   1080 <WIFEXITED@plt>
mov    0x4(%rsp),%esi
test   %rax,%rax
je     11e3 <cleanupFeederProcess+0x83>
mov    %esi,%edi
call   1060 <WEXITSTATUS@plt>
test   %eax,%eax
je     11f1 <cleanupFeederProcess+0x91>
mov    0x4(%rsp),%edi
call   1060 <WEXITSTATUS@plt>
lea    0xf24(%rip),%rdi
mov    %eax,%esi
jmp    11ea <cleanupFeederProcess+0x8a>
mov    0x4(%rsp),%edi
call   1050 <WTERMSIG@plt>
lea    0xed2(%rip),%rdi
mov    %eax,%esi
jmp    11ea <cleanupFeederProcess+0x8a>
lea    0xf50(%rip),%rdi
xor    %eax,%eax
call   1030 <pm_message@plt>
pop    %rax
ret

LLVM IR (-O0):
@SIGPIPE = global i64 0
@.str = [177 x i8] c"WARNING: Standard Input feeder process was terminated by a SIGPIPE signal because the program closed its Standard Input before the Standard Input feeder was through feeding it.\00"
@.str.1 = [62 x i8] c"WARNING: Standard Input feeder was terminated by a Signal %d.\00"
@.str.2 = [75 x i8] c"WARNING: Standard Input feeder process ended abnormally. exit status = %d\00"
@.str.3 = [79 x i8] c"WARNING: Unrecognized process completion status from Standard Input feeder: %d\00"
define void @cleanupFeederProcess(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @waitpid(i32 %4, i32* %3, i32 0)
%6 = load i32, i32* %3
%7 = call i64 @WIFSIGNALED(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @WTERMSIG(i32 %10)
%12 = sext i32 %11 to i64
%13 = load i64, i64* @SIGPIPE
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0))
br label %21
17: ; preds = %9
%18 = load i32, i32* %3
%19 = call i32 @WTERMSIG(i32 %18)
%20 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17, %15
br label %39
22: ; preds = %1
%23 = load i32, i32* %3
%24 = call i64 @WIFEXITED(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %3
%28 = call i32 @WEXITSTATUS(i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* %3
%32 = call i32 @WEXITSTATUS(i32 %31)
%33 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %26
br label %38
35: ; preds = %22
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %34
br label %39
39: ; preds = %38, %21
ret void
}

LLVM IR (-O2):
@SIGPIPE = global i64 0
@.str = [177 x i8] c"WARNING: Standard Input feeder process was terminated by a SIGPIPE signal because the program closed its Standard Input before the Standard Input feeder was through feeding it.\00"
@.str.1 = [62 x i8] c"WARNING: Standard Input feeder was terminated by a Signal %d.\00"
@.str.2 = [75 x i8] c"WARNING: Standard Input feeder process ended abnormally. exit status = %d\00"
@.str.3 = [79 x i8] c"WARNING: Unrecognized process completion status from Standard Input feeder: %d\00"
define void @cleanupFeederProcess(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @waitpid(i32 %0, i32* %2, i32 0)
%5 = load i32, i32* %2
%6 = call i64 @WIFSIGNALED(i32 %5)
%7 = icmp eq i64 %6, 0
%8 = load i32, i32* %2
br i1 %7, label %20, label %9
9: ; preds = %1
%10 = call i32 @WTERMSIG(i32 %8)
%11 = sext i32 %10 to i64
%12 = load i64, i64* @SIGPIPE
%13 = icmp eq i64 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0))
br label %33
16: ; preds = %9
%17 = load i32, i32* %2
%18 = call i32 @WTERMSIG(i32 %17)
%19 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %33
20: ; preds = %1
%21 = call i64 @WIFEXITED(i32 %8)
%22 = icmp eq i64 %21, 0
%23 = load i32, i32* %2
br i1 %22, label %31, label %24
24: ; preds = %20
%25 = call i32 @WEXITSTATUS(i32 %23)
%26 = icmp eq i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i32, i32* %2
%29 = call i32 @WEXITSTATUS(i32 %28)
%30 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %33
31: ; preds = %20
%32 = call i32 (i8*, ...) @pm_message(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %33
33: ; preds = %31, %27, %24, %14, %16
ret void
}