#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 dummy;
};

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, char *);
int /*<<< orphan*/ quit(char *);
scalar_t__ sched_getparam(int /*<<< orphan*/, struct sched_param *);
int sched_getscheduler(int /*<<< orphan*/);
char *sched_text(int);
int /*<<< orphan*/ stderr;
int sched_is(int line, struct sched_param *p, int shouldbe) {
  int scheduler;
  struct sched_param param;
  errno = 0;
  scheduler = sched_getscheduler(0);
  if (sched_getparam(0, &param))
    quit("sched_getparam");
  if (p)
    *p = param;
  if (shouldbe != -1 && scheduler != shouldbe) {
    fprintf(stderr, "At line %d the scheduler should be %s yet it is %s.\n",
            line, sched_text(shouldbe), sched_text(scheduler));
    exit(-1);
  }
  return scheduler;
}


x86 assembly (clang, -O0):
<sched_is>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2e5f(%rip),%rax
movq   $0x0,(%rax)
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x18(%rbp)
xor    %edi,%edi
lea    -0x20(%rbp),%rsi
call   1050 <sched_getparam@plt>
cmp    $0x0,%rax
je     11ab <sched_is+0x4b>
lea    0xe5a(%rip),%rdi
call   1040 <quit@plt>
cmpq   $0x0,-0x10(%rbp)
je     11bf <sched_is+0x5f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,(%rax)
cmpl   $0xffffffff,-0x14(%rbp)
je     121e <sched_is+0xbe>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     121e <sched_is+0xbe>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <sched_text@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <sched_text@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sched_is>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %edi,%r14d
mov    0x2e5c(%rip),%rax
movq   $0x0,(%rax)
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1050 <sched_getparam@plt>
test   %rax,%rax
je     11a9 <sched_is+0x49>
lea    0xe5c(%rip),%rdi
call   1040 <quit@plt>
test   %rbp,%rbp
je     11b5 <sched_is+0x55>
mov    0x8(%rsp),%eax
mov    %eax,0x0(%rbp)
cmp    $0xffffffff,%r15d
je     11c0 <sched_is+0x60>
cmp    %r15d,%ebx
jne    11cf <sched_is+0x6f>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e0a(%rip),%rax
mov    (%rax),%r12d
mov    %r15d,%edi
call   1070 <sched_text@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1070 <sched_text@plt>
lea    0xe1d(%rip),%rsi
mov    %r12d,%edi
mov    %r14d,%edx
mov    %rbp,%rcx
mov    %rax,%r8
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@errno = global i64 0
@.str = [15 x i8] c"sched_getparam\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"At line %d the scheduler should be %s yet it is %s.\0A\00"
define i32 @sched_is(i32 %0, %struct.sched_param* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sched_param*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sched_param
store i32 %0, i32* %4
store %struct.sched_param* %1, %struct.sched_param** %5
store i32 %2, i32* %6
store i64 0, i64* @errno
%9 = call i32 @sched_getscheduler(i32 0)
store i32 %9, i32* %7
%10 = call i64 @sched_getparam(i32 0, %struct.sched_param* %8)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @quit(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %3
%15 = load %struct.sched_param*, %struct.sched_param** %5
%16 = icmp ne %struct.sched_param* %15, null
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load %struct.sched_param*, %struct.sched_param** %5
%19 = bitcast %struct.sched_param* %18 to i8*
%20 = bitcast %struct.sched_param* %8 to i8*
br label %21
21: ; preds = %17, %14
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i32, i32* %4
%31 = load i32, i32* %6
%32 = call i8* @sched_text(i32 %31)
%33 = load i32, i32* %7
%34 = call i8* @sched_text(i32 %33)
%35 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %32, i8* %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %24, %21
%38 = load i32, i32* %7
ret i32 %38
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@errno = global i64 0
@.str = [15 x i8] c"sched_getparam\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"At line %d the scheduler should be %s yet it is %s.\0A\00"
define i32 @sched_is(i32 %0, %struct.sched_param* writeonly %1, i32 %2) {
%4 = alloca %struct.sched_param
%5 = bitcast %struct.sched_param* %4 to i8*
store i64 0, i64* @errno
%6 = tail call i32 @sched_getscheduler(i32 0)
%7 = call i64 @sched_getparam(i32 0, %struct.sched_param* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = call i32 @quit(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
%12 = icmp eq %struct.sched_param* %1, null
br i1 %12, label %17, label %13
13: ; preds = %11
%14 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %4, i64 0, i32 0
%15 = getelementptr %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
%16 = load i32, i32* %14
store i32 %16, i32* %15
br label %17
17: ; preds = %13, %11
%18 = icmp eq i32 %2, -1
%19 = icmp eq i32 %6, %2
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %27, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i8* @sched_text(i32 %2)
%24 = call i8* @sched_text(i32 %6)
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %23, i8* %24)
%26 = call i32 @exit(i32 -1)
unreachable
27: ; preds = %17
ret i32 %6
}