#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int __policy;
};
typedef TYPE_1__ posix_spawnattr_t;

/* Variables and functions */
int EINVAL;
int SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int posix_spawnattr_setschedpolicy(posix_spawnattr_t *attr, int schedpolicy) {
  if (schedpolicy != SCHED_OTHER && schedpolicy != SCHED_FIFO &&
      schedpolicy != SCHED_RR)
    return EINVAL;
  attr->__policy = schedpolicy;
  return 0;
}


x86 assembly (clang, -O0):
<posix_spawnattr_setschedpolicy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ec3(%rip),%rcx
cmp    (%rcx),%eax
je     1152 <posix_spawnattr_setschedpolicy+0x52>
mov    -0x14(%rbp),%eax
mov    0x2ec1(%rip),%rcx
cmp    (%rcx),%eax
je     1152 <posix_spawnattr_setschedpolicy+0x52>
mov    -0x14(%rbp),%eax
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%eax
je     1152 <posix_spawnattr_setschedpolicy+0x52>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1162 <posix_spawnattr_setschedpolicy+0x62>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<posix_spawnattr_setschedpolicy>:
mov    0x2ed1(%rip),%rax
cmp    %esi,(%rax)
je     112b <posix_spawnattr_setschedpolicy+0x2b>
mov    0x2ed6(%rip),%rax
cmp    %esi,(%rax)
je     112b <posix_spawnattr_setschedpolicy+0x2b>
mov    0x2ea3(%rip),%rax
cmp    %esi,(%rax)
je     112b <posix_spawnattr_setschedpolicy+0x2b>
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
ret
mov    %esi,(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@SCHED_OTHER = global i32 0
@SCHED_FIFO = global i32 0
@SCHED_RR = global i32 0
@EINVAL = global i32 0
define i32 @posix_spawnattr_setschedpolicy(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = load i32, i32* @SCHED_OTHER
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i32, i32* %5
%11 = load i32, i32* @SCHED_FIFO
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i32, i32* @SCHED_RR
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* @EINVAL
store i32 %18, i32* %3
br label %23
19: ; preds = %13, %9, %2
%20 = load i32, i32* %5
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
store i32 %20, i32* %22
store i32 0, i32* %3
br label %23
23: ; preds = %19, %17
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@SCHED_OTHER = global i32 0
@SCHED_FIFO = global i32 0
@SCHED_RR = global i32 0
@EINVAL = global i32 0
define i32 @posix_spawnattr_setschedpolicy(%struct.TYPE_3__* nocapture writeonly %0, i32 %1) {
%3 = load i32, i32* @SCHED_OTHER
%4 = icmp eq i32 %3, %1
%5 = load i32, i32* @SCHED_FIFO
%6 = icmp eq i32 %5, %1
%7 = select i1 %4, i1 true, i1 %6
%8 = load i32, i32* @SCHED_RR
%9 = icmp eq i32 %8, %1
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = load i32, i32* @EINVAL
br label %15
13: ; preds = %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i32 %1, i32* %14
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ 0, %13 ]
ret i32 %16
}