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

/* Variables and functions */
int /*<<< orphan*/ SCHED_OTHER;
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_normal(pthread_t pthread) {
  struct sched_param sp;
  memset(&sp, 0, sizeof(sp));
  sp.sched_priority = 0;
  if (pthread_setschedparam(pthread, SCHED_OTHER, &sp) == -1)
    terminal_error("pthread_setschedparam");
}


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

x86 assembly (clang, -O2):
<set_thread_normal>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movq   $0x0,(%rsp)
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1030 <pthread_setschedparam@plt>
cmp    $0xffffffff,%eax
jne    1174 <set_thread_normal+0x44>
lea    0xe91(%rip),%rdi
call   1050 <terminal_error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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