#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__ errno;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int sched_getscheduler(int /*<<< orphan*/);
int main(void) {
  int result0 = -1;
  int result1 = -1;
  result0 = sched_getscheduler(0);
  result1 = sched_getscheduler(getpid());
  if (result0 == result1 && errno == 0) {
    printf("Test PASSED\n");
    return 0;
  }
  if (result0 != result1) {
    printf("Different results between pid == 0 "
           "and pid == getpid().\n");
    return 1;
  }
  perror("Unexpected error");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ad <main+0x6d>
mov    0x2e55(%rip),%rax
cmpq   $0x0,(%rax)
jne    11ad <main+0x6d>
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <main+0xa4>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11d1 <main+0x91>
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <main+0xa4>
lea    0xe6e(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%edi
call   1030 <sched_getscheduler@plt>
cmp    %eax,%ebx
jne    1179 <main+0x39>
mov    0x2e7d(%rip),%rcx
cmpq   $0x0,(%rcx)
jne    1179 <main+0x39>
lea    0xed9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
cmp    %eax,%ebx
je     1190 <main+0x50>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe69(%rip),%rdi
call   1060 <perror@plt>
jmp    1189 <main+0x49>

LLVM IR (-O0):
@errno = global i64 0
@.str = [13 x i8] c"Test PASSED\0A\00"
@.str.1 = [57 x i8] c"Different results between pid == 0 and pid == getpid().\0A\00"
@.str.2 = [17 x i8] c"Unexpected error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 -1, i32* %3
%4 = call i32 @sched_getscheduler(i32 0)
store i32 %4, i32* %2
%5 = call i32 (...) @getpid()
%6 = call i32 @sched_getscheduler(i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load i64, i64* @errno
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %23
15: ; preds = %10, %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %23
21: ; preds = %15
%22 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %23
23: ; preds = %21, %19, %13
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@errno = global i64 0
@.str.2 = [17 x i8] c"Unexpected error\00"
@str = [56 x i8] c"Different results between pid == 0 and pid == getpid().\00"
@str.3 = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = tail call i32 @sched_getscheduler(i32 0)
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 @sched_getscheduler(i32 %2)
%4 = icmp eq i32 %1, %3
%5 = load i64, i64* @errno
%6 = icmp eq i64 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
br label %15
10: ; preds = %0
br i1 %4, label %13, label %11
11: ; preds = %10
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
br label %15
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %8
%16 = phi i32 [ 0, %8 ], [ 1, %11 ], [ 1, %13 ]
ret i32 %16
}