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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ pm_errormsg(char *, char const *);
int /*<<< orphan*/ pm_longjmp();
int /*<<< orphan*/ pm_strfree(char const *);
int /*<<< orphan*/ pm_waitpid(scalar_t__ const, int *, int /*<<< orphan*/,
                              scalar_t__ *, char const **);
void pm_waitpidSimple(pid_t const pid) {
  int status;
  pid_t exitedPid;
  const char *error;
  pm_waitpid(pid, &status, 0, &exitedPid, &error);
  if (error) {
    pm_errormsg("%s", error);
    pm_strfree(error);
    pm_longjmp();
  } else {
    assert(exitedPid != 0);
  }
}


x86 assembly (clang, -O0):
<pm_waitpidSimple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
xor    %edx,%edx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1030 <pm_waitpid@plt>
cmpq   $0x0,-0x20(%rbp)
je     11a3 <pm_waitpidSimple+0x53>
mov    -0x20(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1070 <pm_errormsg@plt>
mov    -0x20(%rbp),%rdi
call   1050 <pm_strfree@plt>
mov    $0x0,%al
call   1060 <pm_longjmp@plt>
jmp    11b5 <pm_waitpidSimple+0x65>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_waitpidSimple>:
sub    $0x18,%rsp
lea    0x14(%rsp),%rsi
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
xor    %edx,%edx
call   1030 <pm_waitpid@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     1192 <pm_waitpidSimple+0x42>
lea    0xe88(%rip),%rdi
call   1070 <pm_errormsg@plt>
mov    (%rsp),%rdi
call   1050 <pm_strfree@plt>
xor    %eax,%eax
call   1060 <pm_longjmp@plt>
add    $0x18,%rsp
ret
xor    %edi,%edi
cmpq   $0x0,0x8(%rsp)
setne  %dil
call   1040 <assert@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @pm_waitpidSimple(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = call i32 @pm_waitpid(i64 %6, i32* %3, i32 0, i64* %4, i8** %5)
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i8*, i8** %5
%12 = call i32 @pm_errormsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %5
%14 = call i32 @pm_strfree(i8* %13)
%15 = call i32 (...) @pm_longjmp()
br label %21
16: ; preds = %1
%17 = load i64, i64* %4
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
br label %21
21: ; preds = %16, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @pm_waitpidSimple(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = call i32 @pm_waitpid(i64 %0, i32* %2, i32 0, i64* %3, i8** %4)
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %1
%12 = call i32 @pm_errormsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%13 = load i8*, i8** %4
%14 = call i32 @pm_strfree(i8* %13)
%15 = call i32 (...) @pm_longjmp()
br label %21
16: ; preds = %1
%17 = load i64, i64* %3
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
br label %21
21: ; preds = %16, %11
ret void
}