#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ display_sched_attr(int, struct sched_param *);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int pthread_getschedparam(int /*<<< orphan*/, int *, struct sched_param *);
int /*<<< orphan*/ pthread_self();
void display_thread_sched_attr(char *msg) {
  int policy, s;
  struct sched_param param;
  s = pthread_getschedparam(pthread_self(), &policy, &param);
  if (s != 0)
    do {
      errno = s;
      perror("pthread_getschedparam");
      exit(EXIT_FAILURE);
    } while (0);
  printf("\n%s ", msg);
  display_sched_attr(policy, &param);
}


x86 assembly (clang, -O0):
<display_thread_sched_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <pthread_self@plt>
mov    %eax,%edi
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <pthread_getschedparam@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11ba <display_thread_sched_attr+0x5a>
jmp    1194 <display_thread_sched_attr+0x34>
mov    -0x10(%rbp),%ecx
mov    0x2e42(%rip),%rax
mov    %ecx,(%rax)
lea    0xe59(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <display_sched_attr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_thread_sched_attr>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <pthread_self@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %eax,%edi
call   1040 <pthread_getschedparam@plt>
test   %eax,%eax
jne    11a7 <display_thread_sched_attr+0x47>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rsi
call   1050 <display_sched_attr@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e32(%rip),%rcx
mov    %eax,(%rcx)
lea    0xe49(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@errno = global i32 0
@.str = [22 x i8] c"pthread_getschedparam\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"\0A%s \00"
define void @display_thread_sched_attr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sched_param
store i8* %0, i8** %2
%6 = call i32 (...) @pthread_self()
%7 = call i32 @pthread_getschedparam(i32 %6, i32* %3, %struct.sched_param* %5)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %1
br label %11
11: ; preds = %10
%12 = load i32, i32* %4
store i32 %12, i32* @errno
%13 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; No predecessors!
br label %17
17: ; preds = %16, %1
%18 = load i8*, i8** %2
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %3
%21 = call i32 @display_sched_attr(i32 %20, %struct.sched_param* %5)
ret void
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@errno = global i32 0
@.str = [22 x i8] c"pthread_getschedparam\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"\0A%s \00"
define void @display_thread_sched_attr(i8* %0) {
%2 = alloca i32
%3 = alloca %struct.sched_param
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.sched_param* %3 to i8*
%6 = tail call i32 (...) @pthread_self()
%7 = call i32 @pthread_getschedparam(i32 %6, i32* %2, %struct.sched_param* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %1
store i32 %7, i32* @errno
%10 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = load i32, i32* %2
%16 = call i32 @display_sched_attr(i32 %15, %struct.sched_param* %3)
ret void
}