#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 */
int EXIT_SUCCESS;
int WEXITSTATUS(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int pipexec_pipe_wait(void *data, pid_t pid) {
  int st = 0, r;
  r = waitpid(pid, &st, 0);
  if (st != EXIT_SUCCESS)
    fprintf(stderr, "Error: Child exited with status %d\n", WEXITSTATUS(st));
  return r;
  (void)data;
}


x86 assembly (clang, -O0):
<pipexec_pipe_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     118e <pipexec_pipe_wait+0x5e>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipexec_pipe_wait>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%edi
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    0x2e82(%rip),%rax
cmp    (%rax),%edi
je     1178 <pipexec_pipe_wait+0x48>
mov    0x2e7f(%rip),%rax
mov    (%rax),%ebp
call   1040 <WEXITSTATUS@plt>
lea    0xe91(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Error: Child exited with status %d\0A\00"
define i32 @pipexec_pipe_wait(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %4
%8 = call i32 @waitpid(i32 %7, i32* %5, i32 0)
store i32 %8, i32* %6
%9 = load i32, i32* %5
%10 = load i32, i32* @EXIT_SUCCESS
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32, i32* %5
%15 = call i32 @WEXITSTATUS(i32 %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %6
ret i32 %18
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Error: Child exited with status %d\0A\00"
define i32 @pipexec_pipe_wait(i8* nocapture readnone %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @waitpid(i32 %1, i32* %3, i32 0)
%6 = load i32, i32* %3
%7 = load i32, i32* @EXIT_SUCCESS
%8 = icmp eq i32 %6, %7
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @WEXITSTATUS(i32 %6)
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %9, %2
ret i32 %5
}