#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 */
struct rusage {
  int dummy;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
int WNOHANG;
int WUNTRACED;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
pid_t __wait3(int *stat_loc, int options, struct rusage *usage) {
  if ((options & ~(WNOHANG | WUNTRACED)) != 0) {
    __set_errno(EINVAL);
    return (pid_t)-1;
  }
  __set_errno(ENOSYS);
  return (pid_t)-1;
}


x86 assembly (clang, -O0):
<__wait3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2eb3(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e9a(%rip),%rdx
or     (%rdx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1160 <__wait3+0x50>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1175 <__wait3+0x65>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__wait3>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
test   %esi,%ecx
jne    1132 <__wait3+0x22>
mov    0x2eb8(%rip),%rax
jmp    1139 <__wait3+0x29>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.rusage = type { i32 }
@WNOHANG = global i32 0
@WUNTRACED = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @__wait3(i32* %0, i32 %1, %struct.rusage* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.rusage*
store i32* %0, i32** %5
store i32 %1, i32* %6
store %struct.rusage* %2, %struct.rusage** %7
%8 = load i32, i32* %6
%9 = load i32, i32* @WNOHANG
%10 = load i32, i32* @WUNTRACED
%11 = or i32 %9, %10
%12 = xor i32 %11, -1
%13 = and i32 %8, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @EINVAL
%17 = call i32 @__set_errno(i32 %16)
store i32 -1, i32* %4
br label %21
18: ; preds = %3
%19 = load i32, i32* @ENOSYS
%20 = call i32 @__set_errno(i32 %19)
store i32 -1, i32* %4
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
%struct.rusage = type { i32 }
@WNOHANG = global i32 0
@WUNTRACED = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @__wait3(i32* nocapture readnone %0, i32 %1, %struct.rusage* nocapture readnone %2) {
%4 = load i32, i32* @WNOHANG
%5 = load i32, i32* @WUNTRACED
%6 = or i32 %5, %4
%7 = xor i32 %6, -1
%8 = and i32 %7, %1
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @ENOSYS
%11 = load i32, i32* @EINVAL
%12 = select i1 %9, i32 %10, i32 %11
%13 = tail call i32 @__set_errno(i32 %12)
ret i32 -1
}