#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__ EINVAL;
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int sched_get_priority_max(int);
int main(void) {
  int result = -1;
  result = sched_get_priority_max(-1);
  if (result == -1 && errno == EINVAL) {
    printf("Test PASSED\n");
    return 0;
  }
  if (result != -1) {
    printf("did no returned -1.\n");
    return 1;
  }
  if (errno != EINVAL) {
    perror("error is not EINVAL");
    return 1;
  }
  printf("Unresolved test error\n");
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
mov    $0xffffffff,%edi
call   1050 <sched_get_priority_max@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    118f <main+0x5f>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
jne    118f <main+0x5f>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xc6>
cmpl   $0xffffffff,-0x8(%rbp)
je     11b1 <main+0x81>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xc6>
mov    0x2e28(%rip),%rax
mov    (%rax),%rax
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%rax
je     11e3 <main+0xb3>
lea    0xe50(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xc6>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xffffffff,%edi
call   1050 <sched_get_priority_max@plt>
cmp    $0xffffffff,%eax
je     1153 <main+0x23>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <main+0x49>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe80(%rip),%rdi
call   1040 <perror@plt>
jmp    114c <main+0x1c>

LLVM IR (-O0):
@errno = global i64 0
@EINVAL = global i64 0
@.str = [13 x i8] c"Test PASSED\0A\00"
@.str.1 = [21 x i8] c"did no returned -1.\0A\00"
@.str.2 = [20 x i8] c"error is not EINVAL\00"
@.str.3 = [23 x i8] c"Unresolved test error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%3 = call i32 @sched_get_priority_max(i32 -1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @EINVAL
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %25
12: ; preds = %6, %0
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %25
17: ; preds = %12
%18 = load i64, i64* @errno
%19 = load i64, i64* @EINVAL
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %1
br label %25
25: ; preds = %23, %21, %15, %10
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@.str.2 = [20 x i8] c"error is not EINVAL\00"
@str.4 = [20 x i8] c"did no returned -1.\00"
@str.5 = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = tail call i32 @sched_get_priority_max(i32 -1)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = load i64, i64* @errno
%5 = load i64, i64* @EINVAL
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0))
br label %13
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
br label %13
11: ; preds = %3
%12 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7
%14 = phi i32 [ 0, %7 ], [ 1, %9 ], [ 1, %11 ]
ret i32 %14
}