#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 */
scalar_t__ queryall(int, int *, int);
scalar_t__ watchcns(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int watchoids(int n, int *oids) {
  if (queryall(n, oids, 0x05))
    return -1;
  if (watchcns(0, NULL, NULL))
    return -1;
  if (queryall(n, oids, 0x08))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<watchoids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1040 <queryall@plt>
cmp    $0x0,%rax
je     1156 <watchoids+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <watchoids+0x88>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1030 <watchcns@plt>
cmp    $0x0,%rax
je     117a <watchoids+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <watchoids+0x88>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1040 <queryall@plt>
cmp    $0x0,%rax
je     11a1 <watchoids+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <watchoids+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<watchoids>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x5,%edx
call   1040 <queryall@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    1161 <watchoids+0x41>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <watchcns@plt>
test   %rax,%rax
jne    1161 <watchoids+0x41>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1040 <queryall@plt>
neg    %rax
sbb    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @watchoids(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
%6 = load i32, i32* %4
%7 = load i32*, i32** %5
%8 = call i64 @queryall(i32 %6, i32* %7, i32 5)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %22
11: ; preds = %2
%12 = call i64 @watchcns(i32 0, i32* null, i32* null)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %3
br label %22
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32*, i32** %5
%18 = call i64 @queryall(i32 %16, i32* %17, i32 8)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %3
br label %22
21: ; preds = %15
store i32 0, i32* %3
br label %22
22: ; preds = %21, %20, %14, %10
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @watchoids(i32 %0, i32* %1) {
%3 = tail call i64 @queryall(i32 %0, i32* %1, i32 5)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 @watchcns(i32 0, i32* null, i32* null)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i64 @queryall(i32 %0, i32* %1, i32 8)
%10 = icmp ne i64 %9, 0
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %8, %5, %2
%13 = phi i32 [ -1, %2 ], [ -1, %5 ], [ %11, %8 ]
ret i32 %13
}