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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
scalar_t__ value(char *);
scalar_t__ wait_child(int);
int wait_command(int pid) {
  if (wait_child(pid) < 0 && (value("bsdcompat") || value("bsdmsgs"))) {
    printf(("Fatal error in process.\n"));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<wait_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <wait_child@plt>
cmp    $0x0,%rax
jge    1191 <wait_command+0x61>
lea    0xeac(%rip),%rdi
call   1040 <value@plt>
cmp    $0x0,%rax
jne    1179 <wait_command+0x49>
lea    0xea0(%rip),%rdi
call   1040 <value@plt>
cmp    $0x0,%rax
je     1191 <wait_command+0x61>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <wait_command+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_command>:
push   %rbx
call   1050 <wait_child@plt>
xor    %ebx,%ebx
test   %rax,%rax
jns    1170 <wait_command+0x40>
lea    0xebc(%rip),%rdi
call   1040 <value@plt>
test   %rax,%rax
jne    115f <wait_command+0x2f>
lea    0xeb5(%rip),%rdi
call   1040 <value@plt>
test   %rax,%rax
je     1170 <wait_command+0x40>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"bsdcompat\00"
@.str.1 = [8 x i8] c"bsdmsgs\00"
@.str.2 = [25 x i8] c"Fatal error in process.\0A\00"
define i32 @wait_command(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @wait_child(i32 %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = call i64 @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i64 @value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %7
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %16
15: ; preds = %10, %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %13
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [10 x i8] c"bsdcompat\00"
@.str.1 = [8 x i8] c"bsdmsgs\00"
@str = [24 x i8] c"Fatal error in process.\00"
define i32 @wait_command(i32 %0) {
%2 = tail call i64 @wait_child(i32 %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = tail call i64 @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i64 @value(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %1, %7, %10
%13 = phi i32 [ -1, %10 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %13
}