#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*/ _SC_ASYNCHRONOUS_IO;
int aio_cancel(int, int /*<<< orphan*/ *);
scalar_t__ errno;
int /*<<< orphan*/ printf(char *);
long sysconf(int /*<<< orphan*/);
int main(void) {
  if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
    return 4;
  if (aio_cancel(-1, NULL) != -1) {
    printf("aio_cancel/9-1.c"
           " bad aio_cancel return value()\n");
    return 1;
  }
  if (errno == 0) {
    printf("aio_cancel/9-1.c"
           " bad errno value()\n");
    return 1;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
cmp    $0x30db0,%rax
jge    1165 <main+0x35>
movl   $0x4,-0x4(%rbp)
jmp    11d0 <main+0xa0>
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <aio_cancel@plt>
cmp    $0xffffffff,%eax
je     1194 <main+0x64>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <main+0xa0>
mov    0x2e3d(%rip),%rax
cmpq   $0x0,(%rax)
jne    11bd <main+0x8d>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <main+0xa0>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    $0x4,%ebx
cmp    $0x30db0,%rax
jl     1193 <main+0x63>
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <aio_cancel@plt>
mov    0x2e79(%rip),%rcx
cmpq   $0x0,(%rcx)
lea    0xea2(%rip),%rcx
lea    0xe8f(%rip),%rdx
cmove  %rcx,%rdx
sete   %cl
cmp    $0xffffffff,%eax
setne  %al
lea    0xeaa(%rip),%rdi
cmove  %rdx,%rdi
or     %cl,%al
movzbl %al,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [48 x i8] c"aio_cancel/9-1.c bad aio_cancel return value()\0A\00"
@errno = global i64 0
@.str.1 = [36 x i8] c"aio_cancel/9-1.c bad errno value()\0A\00"
@.str.2 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%3 = call i64 @sysconf(i32 %2)
%4 = icmp slt i64 %3, 200112
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 4, i32* %1
br label %18
6: ; preds = %0
%7 = call i32 @aio_cancel(i32 -1, i32* null)
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %18
11: ; preds = %6
%12 = load i64, i64* @errno
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %18
18: ; preds = %16, %14, %9, %5
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@_SC_ASYNCHRONOUS_IO = global i32 0
@errno = global i64 0
@str = [12 x i8] c"Test PASSED\00"
@str.3 = [35 x i8] c"aio_cancel/9-1.c bad errno value()\00"
@str.4 = [47 x i8] c"aio_cancel/9-1.c bad aio_cancel return value()\00"
define i32 @main() {
%1 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%2 = tail call i64 @sysconf(i32 %1)
%3 = icmp slt i64 %2, 200112
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = tail call i32 @aio_cancel(i32 -1, i32* null)
%6 = icmp eq i32 %5, -1
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0)
%10 = select i1 %6, i8* %9, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @str.4, i64 0, i64 0)
%11 = xor i1 %6, true
%12 = select i1 %11, i1 true, i1 %8
%13 = zext i1 %12 to i32
%14 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %15
15: ; preds = %4, %0
%16 = phi i32 [ 4, %0 ], [ %13, %4 ]
ret i32 %16
}