#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 */
int /*<<< orphan*/ PTHREAD_EXPLICIT_SCHED;
int /*<<< orphan*/ PTHREAD_INHERIT_SCHED;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int pthread_attr_destroy(int /*<<< orphan*/ *);
int pthread_attr_init(int /*<<< orphan*/ *);
int pthread_attr_setinheritsched(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ verify_inheritsched(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int main(void) {
  int rc = 0;
  pthread_attr_t attr;
  rc = pthread_attr_init(&attr);
  if (rc != 0) {
    perror("unexpected error: "
           "pthread_attr_getinheritsched"
           " "
           "1-1"
           ": "
           "pthread_attr_init");
    exit(2);
  }
  rc = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
  if (rc != 0) {
    perror("unexpected error: "
           "pthread_attr_getinheritsched"
           " "
           "1-1"
           ": "
           "pthread_attr_setinheritsched");
    exit(2);
  }
  verify_inheritsched(&attr, PTHREAD_INHERIT_SCHED);
  rc = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
  if (rc != 0) {
    perror("unexpected error: "
           "pthread_attr_getinheritsched"
           " "
           "1-1"
           ": "
           "pthread_attr_setinheritsched");
    exit(2);
  }
  verify_inheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
  rc = pthread_attr_destroy(&attr);
  if (rc != 0) {
    perror("unexpected error: "
           "pthread_attr_getinheritsched"
           " "
           "1-1"
           ": "
           "pthread_attr_destroy");
    exit(2);
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <pthread_attr_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b2 <main+0x42>
lea    0xe5d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1040 <pthread_attr_setinheritsched@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11e7 <main+0x77>
lea    0xe6e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1030 <verify_inheritsched@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1040 <pthread_attr_setinheritsched@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     122e <main+0xbe>
lea    0xe27(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1030 <verify_inheritsched@plt>
lea    -0xc(%rbp),%rdi
call   1080 <pthread_attr_destroy@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     126c <main+0xfc>
lea    0xe3a(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1060 <pthread_attr_init@plt>
test   %eax,%eax
jne    11f9 <main+0x89>
mov    0x2e4f(%rip),%rbx
mov    (%rbx),%esi
lea    0x4(%rsp),%rdi
call   1040 <pthread_attr_setinheritsched@plt>
test   %eax,%eax
jne    11f0 <main+0x80>
mov    (%rbx),%esi
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <verify_inheritsched@plt>
mov    0x2e39(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1040 <pthread_attr_setinheritsched@plt>
test   %eax,%eax
jne    11f0 <main+0x80>
mov    (%r14),%esi
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <verify_inheritsched@plt>
mov    %rbx,%rdi
call   1080 <pthread_attr_destroy@plt>
test   %eax,%eax
jne    1202 <main+0x92>
lea    0xeff(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4f(%rip),%rdi
jmp    1209 <main+0x99>
lea    0xe00(%rip),%rdi
jmp    1209 <main+0x99>
lea    0xe8e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [70 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_init\00"
@PTHREAD_INHERIT_SCHED = global i32 0
@.str.1 = [81 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_setinheritsched\00"
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.2 = [73 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_destroy\00"
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @pthread_attr_init(i32* %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %0
%11 = load i32, i32* @PTHREAD_INHERIT_SCHED
%12 = call i32 @pthread_attr_setinheritsched(i32* %3, i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 @perror(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 2)
unreachable
18: ; preds = %10
%19 = load i32, i32* @PTHREAD_INHERIT_SCHED
%20 = call i32 @verify_inheritsched(i32* %3, i32 %19)
%21 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%22 = call i32 @pthread_attr_setinheritsched(i32* %3, i32 %21)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = call i32 @perror(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 2)
unreachable
28: ; preds = %18
%29 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%30 = call i32 @verify_inheritsched(i32* %3, i32 %29)
%31 = call i32 @pthread_attr_destroy(i32* %3)
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = call i32 @perror(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 2)
unreachable
37: ; preds = %28
%38 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [70 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_init\00"
@PTHREAD_INHERIT_SCHED = global i32 0
@.str.1 = [81 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_setinheritsched\00"
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.2 = [73 x i8] c"unexpected error: pthread_attr_getinheritsched 1-1: pthread_attr_destroy\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @pthread_attr_init(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 2)
unreachable
8: ; preds = %0
%9 = load i32, i32* @PTHREAD_INHERIT_SCHED
%10 = call i32 @pthread_attr_setinheritsched(i32* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 2)
unreachable
15: ; preds = %8
%16 = load i32, i32* @PTHREAD_INHERIT_SCHED
%17 = call i32 @verify_inheritsched(i32* %1, i32 %16)
%18 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%19 = call i32 @pthread_attr_setinheritsched(i32* %1, i32 %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = call i32 @perror(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %15
%25 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%26 = call i32 @verify_inheritsched(i32* %1, i32 %25)
%27 = call i32 @pthread_attr_destroy(i32* %1)
%28 = icmp eq i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = call i32 @perror(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %24
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
ret i32 0
}