#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 sched_param {
  int sched_priority;
};

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ printf(char *);
int sched_getparam(int /*<<< orphan*/, struct sched_param *);
int main(void) {
  struct sched_param param0;
  struct sched_param param1;
  int result0;
  int result1;
  param0.sched_priority = -1;
  param1.sched_priority = -1;
  result0 = sched_getparam(0, &param0);
  result1 = sched_getparam(getpid(), &param1);
  if (result0 == result1 && param0.sched_priority == param1.sched_priority &&
      errno == 0) {
    printf("Test PASSED\n");
    return 0;
  }
  printf("Different results between pid == 0 "
         "and pid == getpid().\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0x10(%rbp)
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1050 <sched_getparam@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1050 <sched_getparam@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11b1 <main+0x81>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11b1 <main+0x81>
mov    0x2e51(%rip),%rax
cmpq   $0x0,(%rax)
jne    11b1 <main+0x81>
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <main+0x94>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0xffffffff,0x10(%rsp)
ff
movl   $0xffffffff,0x8(%rsp)
ff
xor    %ebx,%ebx
lea    0x10(%rsp),%rsi
xor    %edi,%edi
call   1050 <sched_getparam@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1050 <sched_getparam@plt>
cmp    %eax,%ebp
jne    118d <main+0x5d>
mov    0x10(%rsp),%eax
cmp    0x8(%rsp),%eax
jne    118d <main+0x5d>
mov    0x2e62(%rip),%rax
cmpq   $0x0,(%rax)
jne    118d <main+0x5d>
lea    0xead(%rip),%rdi
jmp    1199 <main+0x69>
mov    $0x1,%ebx
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@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"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sched_param
%3 = alloca %struct.sched_param
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %2, i32 0, i32 0
store i32 -1, i32* %6
%7 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i32 0, i32 0
store i32 -1, i32* %7
%8 = call i32 @sched_getparam(i32 0, %struct.sched_param* %2)
store i32 %8, i32* %4
%9 = call i32 (...) @getpid()
%10 = call i32 @sched_getparam(i32 %9, %struct.sched_param* %3)
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %0
%15 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %2, i32 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i32 0, i32 0
%18 = load i32, i32* %17
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i64, i64* @errno
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %27
25: ; preds = %20, %14, %0
%26 = 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 %27
27: ; preds = %25, %23
%28 = load i32, i32* %1
ret i32 %28
}

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