#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;
};
typedef int /*<<< orphan*/ pthread_t;

/* Variables and functions */
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ pthread_self();
int pthread_setschedparam(int /*<<< orphan*/, int /*<<< orphan*/,
                          struct sched_param *);
int /*<<< orphan*/ stderr;
char *strerror(int);
void setThreadPriority() {
  pthread_t id;
  struct sched_param param;
  int ret;
  id = pthread_self();
  param.__sched_priority = 99;
  ret = pthread_setschedparam(id, SCHED_FIFO, &param);
  if (ret != 0) {
    fprintf(stderr, "pthread_setschedparam() failed : %d(%s)\n", ret,
            strerror(ret));
  }
}


x86 assembly (clang, -O0):
<setThreadPriority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %eax,-0x4(%rbp)
movl   $0x63,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1030 <pthread_setschedparam@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11aa <setThreadPriority+0x6a>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    %rax,%rcx
lea    0xe5b(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setThreadPriority>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <pthread_self@plt>
movl   $0x63,(%rsp)
mov    0x2e90(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rdx
mov    %eax,%edi
call   1030 <pthread_setschedparam@plt>
test   %eax,%eax
je     118d <setThreadPriority+0x4d>
mov    %eax,%ebx
mov    0x2e67(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe7f(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %rax,%rcx
call   1040 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"pthread_setschedparam() failed : %d(%s)\0A\00"
define void @setThreadPriority() {
%1 = alloca i32
%2 = alloca %struct.sched_param
%3 = alloca i32
%4 = call i32 (...) @pthread_self()
store i32 %4, i32* %1
%5 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %2, i32 0, i32 0
store i32 99, i32* %5
%6 = load i32, i32* %1
%7 = load i32, i32* @SCHED_FIFO
%8 = call i32 @pthread_setschedparam(i32 %6, i32 %7, %struct.sched_param* %2)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %15)
br label %17
17: ; preds = %11, %0
ret void
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"pthread_setschedparam() failed : %d(%s)\0A\00"
define void @setThreadPriority() {
%1 = alloca %struct.sched_param
%2 = bitcast %struct.sched_param* %1 to i8*
%3 = tail call i32 (...) @pthread_self()
%4 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
store i32 99, i32* %4
%5 = load i32, i32* @SCHED_FIFO
%6 = call i32 @pthread_setschedparam(i32 %3, i32 %5, %struct.sched_param* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i8* @strerror(i32 %6)
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %6, i8* %10)
br label %12
12: ; preds = %8, %0
ret void
}