#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(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 {
      printf("[err=%d][line = %d] %s\n", s, 70, "pthread_getschedparam");
      exit(EXIT_FAILURE);
    } while (0);
  printf("%s\n", 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     11af <display_thread_sched_attr+0x5f>
jmp    1184 <display_thread_sched_attr+0x34>
mov    -0x10(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x46,%edx
lea    0xe7e(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
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   1070 <pthread_self@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %eax,%edi
call   1050 <pthread_getschedparam@plt>
test   %eax,%eax
jne    11a0 <display_thread_sched_attr+0x40>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rsi
call   1060 <display_sched_attr@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe59(%rip),%rdi
lea    0xe6a(%rip),%rcx
mov    %eax,%esi
mov    $0x46,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [24 x i8] c"[err=%d][line = %d] %s\0A\00"
@.str.1 = [22 x i8] c"pthread_getschedparam\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"%s\0A\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
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %12, i32 70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, 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 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, 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 }
@.str = [24 x i8] c"[err=%d][line = %d] %s\0A\00"
@.str.1 = [22 x i8] c"pthread_getschedparam\00"
@EXIT_FAILURE = global i32 0
define void @display_thread_sched_attr(i8* nocapture %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
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %7, i32 70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = call i32 @puts(i8* dereferenceable(1) %0)
%15 = load i32, i32* %2
%16 = call i32 @display_sched_attr(i32 %15, %struct.sched_param* %3)
ret void
}