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

/* Variables and functions */
#define SCHED_FIFO 130
#define SCHED_OTHER 129
#define SCHED_RR 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int pthread_attr_getschedpolicy(int /*<<< orphan*/ *, int *);
int verify_policy(pthread_attr_t *attr, int policytype) {
  int rc;
  int policy;
  rc = pthread_attr_getschedpolicy(attr, &policy);
  if (rc != 0) {
    printf("unexpected error: "
           "pthread_attr_getschedpolicy"
           " "
           "2-1"
           ": "
           "pthread_attr_getschedpolicy\n");
    exit(2);
  }
  switch (policytype) {
  case SCHED_FIFO:
    if (policy != SCHED_FIFO) {
      printf("unexpected error: "
             "pthread_attr_getschedpolicy"
             " "
             "2-1"
             ": "
             "got wrong policy param\n");
      exit(1);
    }
    break;
  case SCHED_RR:
    if (policy != SCHED_RR) {
      printf("unexpected error: "
             "pthread_attr_getschedpolicy"
             " "
             "2-1"
             ": "
             "got wrong policy param\n");
      exit(1);
    }
    break;
  case SCHED_OTHER:
    if (policy != SCHED_OTHER) {
      printf("unexpected error: "
             "pthread_attr_getschedpolicy"
             " "
             "2-1"
             ": "
             "got wrong policy param\n");
      exit(1);
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify_policy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <pthread_attr_getschedpolicy@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116f <verify_policy+0x3f>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x80,%eax
je     11d3 <verify_policy+0xa3>
jmp    1185 <verify_policy+0x55>
mov    -0x18(%rbp),%eax
sub    $0x81,%eax
je     11fb <verify_policy+0xcb>
jmp    1198 <verify_policy+0x68>
mov    -0x18(%rbp),%eax
sub    $0x82,%eax
jne    1223 <verify_policy+0xf3>
jmp    11ab <verify_policy+0x7b>
cmpl   $0x82,-0x14(%rbp)
je     11ce <verify_policy+0x9e>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1223 <verify_policy+0xf3>
cmpl   $0x80,-0x14(%rbp)
je     11f6 <verify_policy+0xc6>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1223 <verify_policy+0xf3>
cmpl   $0x81,-0x14(%rbp)
je     121e <verify_policy+0xee>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1223 <verify_policy+0xf3>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_policy>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
lea    0xc(%rsp),%rsi
call   1040 <pthread_attr_getschedpolicy@plt>
test   %eax,%eax
jne    119b <verify_policy+0x6b>
cmp    $0x80,%ebx
je     117d <verify_policy+0x4d>
cmp    $0x81,%ebx
je     1189 <verify_policy+0x59>
cmp    $0x82,%ebx
jne    1193 <verify_policy+0x63>
cmpl   $0x82,0xc(%rsp)
je     1193 <verify_policy+0x63>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x80,0xc(%rsp)
je     1193 <verify_policy+0x63>
jmp    1167 <verify_policy+0x37>
cmpl   $0x81,0xc(%rsp)
jne    1167 <verify_policy+0x37>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [80 x i8] c"unexpected error: pthread_attr_getschedpolicy 2-1: pthread_attr_getschedpolicy\0A\00"
@.str.1 = [75 x i8] c"unexpected error: pthread_attr_getschedpolicy 2-1: got wrong policy param\0A\00"
define i32 @verify_policy(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = call i32 @pthread_attr_getschedpolicy(i32* %7, i32* %6)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 2)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
switch i32 %15, label %37 [
i32 130, label %16
i32 128, label %23
i32 129, label %30
]
16: ; preds = %14
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 130
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %16
br label %37
23: ; preds = %14
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 128
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %23
br label %37
30: ; preds = %14
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 129
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %30
br label %37
37: ; preds = %14, %36, %29, %22
ret i32 0
}

LLVM IR (-O2):
@str.3 = [74 x i8] c"unexpected error: pthread_attr_getschedpolicy 2-1: got wrong policy param\00"
@str.4 = [79 x i8] c"unexpected error: pthread_attr_getschedpolicy 2-1: pthread_attr_getschedpolicy\00"
define i32 @verify_policy(i32* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @pthread_attr_getschedpolicy(i32* %0, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str.4, i64 0, i64 0))
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %2
switch i32 %1, label %29 [
i32 130, label %11
i32 128, label %17
i32 129, label %23
]
11: ; preds = %10
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 130
br i1 %13, label %29, label %14
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.3, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 128
br i1 %19, label %29, label %20
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %10
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 129
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %23, %17, %11, %10
ret i32 0
}