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

/* Variables and functions */
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ memset(struct sched_param *, int /*<<< orphan*/, int);
int pthread_setschedparam(int /*<<< orphan*/, int /*<<< orphan*/,
                          struct sched_param *);
int /*<<< orphan*/ terminal_error(char *);
void set_thread_fifo(pthread_t pthread, int prio) {
  struct sched_param sp;
  memset(&sp, 0, sizeof(sp));
  sp.sched_priority = prio;
  if (pthread_setschedparam(pthread, SCHED_FIFO, &sp) == -1)
    terminal_error("pthread_setschedparam");
}


x86 assembly (clang, -O0):
<set_thread_fifo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1030 <pthread_setschedparam@plt>
cmp    $0xffffffff,%eax
jne    117e <set_thread_fifo+0x4e>
lea    0xe87(%rip),%rdi
call   1050 <terminal_error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_thread_fifo>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,0x8(%rsp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1030 <pthread_setschedparam@plt>
cmp    $0xffffffff,%eax
jne    1178 <set_thread_fifo+0x48>
lea    0xe8d(%rip),%rdi
call   1050 <terminal_error@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [22 x i8] c"pthread_setschedparam\00"
define void @set_thread_fifo(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sched_param
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @memset(%struct.sched_param* %5, i32 0, i32 4)
%7 = load i32, i32* %4
%8 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %5, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* %3
%10 = load i32, i32* @SCHED_FIFO
%11 = call i32 @pthread_setschedparam(i32 %9, i32 %10, %struct.sched_param* %5)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @terminal_error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
ret void
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [22 x i8] c"pthread_setschedparam\00"
define void @set_thread_fifo(i32 %0, i32 %1) {
%3 = alloca %struct.sched_param
%4 = bitcast %struct.sched_param* %3 to i8*
%5 = call i32 @memset(%struct.sched_param* %3, i32 0, i32 4)
%6 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i64 0, i32 0
store i32 %1, i32* %6
%7 = load i32, i32* @SCHED_FIFO
%8 = call i32 @pthread_setschedparam(i32 %0, i32 %7, %struct.sched_param* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @terminal_error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
ret void
}