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

/* Variables and functions */
int PTHREAD_CREATE_DETACHED;
int PTHREAD_CREATE_JOINABLE;
int PTHREAD_EXPLICIT_SCHED;
int PTHREAD_INHERIT_SCHED;
int PTHREAD_SCOPE_PROCESS;
int PTHREAD_SCOPE_SYSTEM;
int SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int /*<<< orphan*/ printf(char *, ...);
int pthread_attr_getdetachstate(int /*<<< orphan*/ *, int *);
int pthread_attr_getguardsize(int /*<<< orphan*/ *, size_t *);
int pthread_attr_getinheritsched(int /*<<< orphan*/ *, int *);
int pthread_attr_getschedparam(int /*<<< orphan*/ *, struct sched_param *);
int pthread_attr_getschedpolicy(int /*<<< orphan*/ *, int *);
int pthread_attr_getscope(int /*<<< orphan*/ *, int *);
int pthread_attr_getstack(int /*<<< orphan*/ *, void **, size_t *);
char *strerror(int);
int get_attr(pthread_attr_t *attr) {
  void *stkaddr = NULL;
  size_t size = 0;
  int i = -1;
  struct sched_param sp;
  printf("//////////////////////////////////////////////////////////////\n");
  int r = pthread_attr_getstack(attr, &stkaddr, &size);
  if (r != 0)
    printf("ERROR: failed to get stack %s\n", strerror(r));
  else
    printf("DEBUG: stack addr %p size %ld\n", stkaddr, size);
  r = pthread_attr_getdetachstate(attr, &i);
  if (r != 0) {
    printf("ERROR: failed to get detach state %s\n", strerror(r));
  } else {
    printf("DEBUG: %s\n",
           (i == PTHREAD_CREATE_DETACHED)   ? "PTHREAD_CREATE_DETACHED"
           : (i == PTHREAD_CREATE_JOINABLE) ? "PTHREAD_CREATE_JOINABLE"
                                            : "???");
  }
  r = pthread_attr_getscope(attr, &i);
  if (r != 0) {
    printf("ERROR: failed to get scope %s\n", strerror(r));
  } else {
    printf("DEBUG: %s\n", (i == PTHREAD_SCOPE_SYSTEM) ? "PTHREAD_SCOPE_SYSTEM"
                          : (i == PTHREAD_SCOPE_PROCESS)
                              ? "PTHREAD_SCOPE_PROCESS"
                              : "???");
  }
  r = pthread_attr_getinheritsched(attr, &i);
  if (r != 0) {
    printf("ERROR: failed to get inherit sched %s\n", strerror(r));
  } else {
    printf("DEBUG: %s\n", (i == PTHREAD_INHERIT_SCHED) ? "PTHREAD_INHERIT_SCHED"
                          : (i == PTHREAD_EXPLICIT_SCHED)
                              ? "PTHREAD_EXPLICIT_SCHED"
                              : "???");
  }
  r = pthread_attr_getschedpolicy(attr, &i);
  if (r != 0) {
    printf("ERROR: failed to get sched policy %s\n", strerror(r));
  } else {
    printf("DEBUG: %s\n", (i == SCHED_OTHER)  ? "SCHED_OTHER"
                          : (i == SCHED_FIFO) ? "SCHED_FIFO"
                          : (i == SCHED_RR)   ? "SCHED_RR"
                                              : "???");
  }
  r = pthread_attr_getschedparam(attr, &sp);
  if (r != 0)
    printf("ERROR: failed to get sched param %s\n", strerror(r));
  else
    printf("DEBUG: %d\n", sp.sched_priority);
  r = pthread_attr_getguardsize(attr, &size);
  if (r != 0)
    printf("ERROR: failed to get guard size %s\n", strerror(r));
  else
    printf("DEBUG: guard size %ld\n", size);
  printf("//////////////////////////////////////////////////////////////\n");
  return r;
}


x86 assembly (clang, -O0):
<get_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <pthread_attr_getstack@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11fd <get_attr+0x6d>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1213 <get_attr+0x83>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   10b0 <pthread_attr_getdetachstate@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     124b <get_attr+0xbb>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a3 <get_attr+0x113>
mov    -0x1c(%rbp),%eax
mov    0x2d6b(%rip),%rcx
cmp    (%rcx),%eax
jne    126d <get_attr+0xdd>
lea    0xe4b(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1291 <get_attr+0x101>
mov    -0x1c(%rbp),%edx
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rax
lea    0xe40(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <pthread_attr_getscope@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12db <get_attr+0x14b>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1333 <get_attr+0x1a3>
mov    -0x1c(%rbp),%eax
mov    0x2cf3(%rip),%rcx
cmp    (%rcx),%eax
jne    12fd <get_attr+0x16d>
lea    0xe0e(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1321 <get_attr+0x191>
mov    -0x1c(%rbp),%edx
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
lea    0xdcf(%rip),%rax
lea    0xe00(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1080 <pthread_attr_getinheritsched@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     136b <get_attr+0x1db>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13c3 <get_attr+0x233>
mov    -0x1c(%rbp),%eax
mov    0x2c33(%rip),%rcx
cmp    (%rcx),%eax
jne    138d <get_attr+0x1fd>
lea    0xdd0(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    13b1 <get_attr+0x221>
mov    -0x1c(%rbp),%edx
mov    0x2c49(%rip),%rax
mov    (%rax),%esi
lea    0xd3f(%rip),%rax
lea    0xdc3(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1090 <pthread_attr_getschedpolicy@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     13fb <get_attr+0x26b>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    147d <get_attr+0x2ed>
mov    -0x1c(%rbp),%eax
mov    0x2bb3(%rip),%rcx
cmp    (%rcx),%eax
jne    141d <get_attr+0x28d>
lea    0xd93(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    146b <get_attr+0x2db>
mov    -0x1c(%rbp),%eax
mov    0x2ba9(%rip),%rcx
cmp    (%rcx),%eax
jne    143f <get_attr+0x2af>
lea    0xd7d(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    1463 <get_attr+0x2d3>
mov    -0x1c(%rbp),%edx
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
lea    0xc8d(%rip),%rax
lea    0xd65(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <pthread_attr_getschedparam@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     14b5 <get_attr+0x325>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14c6 <get_attr+0x336>
mov    -0x20(%rbp),%esi
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <pthread_attr_getguardsize@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     14fe <get_attr+0x36e>
mov    -0x24(%rbp),%edi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1510 <get_attr+0x380>
mov    -0x18(%rbp),%rsi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xae9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_attr>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movq   $0x0,0x18(%rsp)
movq   $0x0,0x8(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
lea    0x1029(%rip),%rdi
call   1040 <puts@plt>
lea    0x18(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <pthread_attr_getstack@plt>
test   %eax,%eax
je     11fe <get_attr+0x5e>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xe0e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1216 <get_attr+0x76>
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%rdx
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <pthread_attr_getdetachstate@plt>
test   %eax,%eax
je     123a <get_attr+0x9a>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xe09(%rip),%rdi
mov    %rax,%rsi
jmp    1274 <get_attr+0xd4>
mov    0x4(%rsp),%eax
mov    0x2d7b(%rip),%rcx
mov    0x2d9c(%rip),%rdx
cmp    (%rdx),%eax
lea    0xe32(%rip),%rdx
lea    0xe43(%rip),%rdi
cmove  %rdx,%rdi
cmp    (%rcx),%eax
lea    0xe06(%rip),%rsi
cmovne %rdi,%rsi
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <pthread_attr_getscope@plt>
test   %eax,%eax
je     129f <get_attr+0xff>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xe09(%rip),%rdi
mov    %rax,%rsi
jmp    12d9 <get_attr+0x139>
mov    0x4(%rsp),%eax
mov    0x2d2e(%rip),%rcx
mov    0x2cff(%rip),%rdx
cmp    (%rdx),%eax
lea    0xe1d(%rip),%rdx
lea    0xdde(%rip),%rdi
cmove  %rdx,%rdi
cmp    (%rcx),%eax
lea    0xdf4(%rip),%rsi
cmovne %rdi,%rsi
lea    0xd8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <pthread_attr_getinheritsched@plt>
test   %eax,%eax
je     1304 <get_attr+0x164>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xdee(%rip),%rdi
mov    %rax,%rsi
jmp    133e <get_attr+0x19e>
mov    0x4(%rsp),%eax
mov    0x2c99(%rip),%rcx
mov    0x2cca(%rip),%rdx
cmp    (%rdx),%eax
lea    0xe0b(%rip),%rdx
lea    0xd79(%rip),%rdi
cmove  %rdx,%rdi
cmp    (%rcx),%eax
lea    0xde1(%rip),%rsi
cmovne %rdi,%rsi
lea    0xd26(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <pthread_attr_getschedpolicy@plt>
test   %eax,%eax
je     1369 <get_attr+0x1c9>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xddd(%rip),%rdi
mov    %rax,%rsi
jmp    13b7 <get_attr+0x217>
mov    0x4(%rsp),%eax
mov    0x2c44(%rip),%rcx
cmp    (%rcx),%eax
jne    1381 <get_attr+0x1e1>
lea    0xde8(%rip),%rsi
jmp    13b0 <get_attr+0x210>
mov    0x2c48(%rip),%rcx
cmp    (%rcx),%eax
jne    1395 <get_attr+0x1f5>
lea    0xde0(%rip),%rsi
jmp    13b0 <get_attr+0x210>
mov    0x2bfc(%rip),%rcx
cmp    (%rcx),%eax
lea    0xdd9(%rip),%rax
lea    0xcf3(%rip),%rsi
cmove  %rax,%rsi
lea    0xcad(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <pthread_attr_getschedparam@plt>
test   %eax,%eax
je     13e9 <get_attr+0x249>
mov    %eax,%edi
call   10b0 <strerror@plt>
lea    0xdaa(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13fb <get_attr+0x25b>
mov    0x10(%rsp),%esi
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <pthread_attr_getguardsize@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1421 <get_attr+0x281>
mov    %ebx,%edi
call   10b0 <strerror@plt>
lea    0xd9b(%rip),%rdi
mov    %rax,%rsi
jmp    142d <get_attr+0x28d>
mov    0x8(%rsp),%rsi
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb7(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [64 x i8] c"//////////////////////////////////////////////////////////////\0A\00"
@.str.1 = [31 x i8] c"ERROR: failed to get stack %s\0A\00"
@.str.2 = [31 x i8] c"DEBUG: stack addr %p size %ld\0A\00"
@.str.3 = [38 x i8] c"ERROR: failed to get detach state %s\0A\00"
@.str.4 = [11 x i8] c"DEBUG: %s\0A\00"
@PTHREAD_CREATE_DETACHED = global i32 0
@.str.5 = [24 x i8] c"PTHREAD_CREATE_DETACHED\00"
@PTHREAD_CREATE_JOINABLE = global i32 0
@.str.6 = [24 x i8] c"PTHREAD_CREATE_JOINABLE\00"
@.str.7 = [4 x i8] c"???\00"
@.str.8 = [31 x i8] c"ERROR: failed to get scope %s\0A\00"
@PTHREAD_SCOPE_SYSTEM = global i32 0
@.str.9 = [21 x i8] c"PTHREAD_SCOPE_SYSTEM\00"
@PTHREAD_SCOPE_PROCESS = global i32 0
@.str.10 = [22 x i8] c"PTHREAD_SCOPE_PROCESS\00"
@.str.11 = [39 x i8] c"ERROR: failed to get inherit sched %s\0A\00"
@PTHREAD_INHERIT_SCHED = global i32 0
@.str.12 = [22 x i8] c"PTHREAD_INHERIT_SCHED\00"
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.13 = [23 x i8] c"PTHREAD_EXPLICIT_SCHED\00"
@.str.14 = [38 x i8] c"ERROR: failed to get sched policy %s\0A\00"
@SCHED_OTHER = global i32 0
@.str.15 = [12 x i8] c"SCHED_OTHER\00"
@SCHED_FIFO = global i32 0
@.str.16 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_RR = global i32 0
@.str.17 = [9 x i8] c"SCHED_RR\00"
@.str.18 = [37 x i8] c"ERROR: failed to get sched param %s\0A\00"
@.str.19 = [11 x i8] c"DEBUG: %d\0A\00"
@.str.20 = [36 x i8] c"ERROR: failed to get guard size %s\0A\00"
@.str.21 = [23 x i8] c"DEBUG: guard size %ld\0A\00"
define i32 @get_attr(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca %struct.sched_param
%7 = alloca i32
store i32* %0, i32** %2
store i8* null, i8** %3
store i64 0, i64* %4
store i32 -1, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @pthread_attr_getstack(i32* %9, i8** %3, i64* %4)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* %7
%15 = call i8* @strerror(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %21
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = load i64, i64* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %18, i64 %19)
br label %21
21: ; preds = %17, %13
%22 = load i32*, i32** %2
%23 = call i32 @pthread_attr_getdetachstate(i32* %22, i32* %5)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i32, i32* %7
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %44
30: ; preds = %21
%31 = load i32, i32* %5
%32 = load i32, i32* @PTHREAD_CREATE_DETACHED
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30
br label %41
35: ; preds = %30
%36 = load i32, i32* %5
%37 = load i32, i32* @PTHREAD_CREATE_JOINABLE
%38 = icmp eq i32 %36, %37
%39 = zext i1 %38 to i64
%40 = select i1 %38, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %41
41: ; preds = %35, %34
%42 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), %34 ], [ %40, %35 ]
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %26
%45 = load i32*, i32** %2
%46 = call i32 @pthread_attr_getscope(i32* %45, i32* %5)
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %44
%50 = load i32, i32* %7
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %51)
br label %67
53: ; preds = %44
%54 = load i32, i32* %5
%55 = load i32, i32* @PTHREAD_SCOPE_SYSTEM
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %58
57: ; preds = %53
br label %64
58: ; preds = %53
%59 = load i32, i32* %5
%60 = load i32, i32* @PTHREAD_SCOPE_PROCESS
%61 = icmp eq i32 %59, %60
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %64
64: ; preds = %58, %57
%65 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), %57 ], [ %63, %58 ]
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %49
%68 = load i32*, i32** %2
%69 = call i32 @pthread_attr_getinheritsched(i32* %68, i32* %5)
store i32 %69, i32* %7
%70 = load i32, i32* %7
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %67
%73 = load i32, i32* %7
%74 = call i8* @strerror(i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i8* %74)
br label %90
76: ; preds = %67
%77 = load i32, i32* %5
%78 = load i32, i32* @PTHREAD_INHERIT_SCHED
%79 = icmp eq i32 %77, %78
br i1 %79, label %80, label %81
80: ; preds = %76
br label %87
81: ; preds = %76
%82 = load i32, i32* %5
%83 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%84 = icmp eq i32 %82, %83
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %87
87: ; preds = %81, %80
%88 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), %80 ], [ %86, %81 ]
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %87, %72
%91 = load i32*, i32** %2
%92 = call i32 @pthread_attr_getschedpolicy(i32* %91, i32* %5)
store i32 %92, i32* %7
%93 = load i32, i32* %7
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %90
%96 = load i32, i32* %7
%97 = call i8* @strerror(i32 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), i8* %97)
br label %120
99: ; preds = %90
%100 = load i32, i32* %5
%101 = load i32, i32* @SCHED_OTHER
%102 = icmp eq i32 %100, %101
br i1 %102, label %103, label %104
103: ; preds = %99
br label %117
104: ; preds = %99
%105 = load i32, i32* %5
%106 = load i32, i32* @SCHED_FIFO
%107 = icmp eq i32 %105, %106
br i1 %107, label %108, label %109
108: ; preds = %104
br label %115
109: ; preds = %104
%110 = load i32, i32* %5
%111 = load i32, i32* @SCHED_RR
%112 = icmp eq i32 %110, %111
%113 = zext i1 %112 to i64
%114 = select i1 %112, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %115
115: ; preds = %109, %108
%116 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0), %108 ], [ %114, %109 ]
br label %117
117: ; preds = %115, %103
%118 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), %103 ], [ %116, %115 ]
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %118)
br label %120
120: ; preds = %117, %95
%121 = load i32*, i32** %2
%122 = call i32 @pthread_attr_getschedparam(i32* %121, %struct.sched_param* %6)
store i32 %122, i32* %7
%123 = load i32, i32* %7
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %120
%126 = load i32, i32* %7
%127 = call i8* @strerror(i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.18, i64 0, i64 0), i8* %127)
br label %133
129: ; preds = %120
%130 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
%131 = load i32, i32* %130
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %131)
br label %133
133: ; preds = %129, %125
%134 = load i32*, i32** %2
%135 = call i32 @pthread_attr_getguardsize(i32* %134, i64* %4)
store i32 %135, i32* %7
%136 = load i32, i32* %7
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %142
138: ; preds = %133
%139 = load i32, i32* %7
%140 = call i8* @strerror(i32 %139)
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.20, i64 0, i64 0), i8* %140)
br label %145
142: ; preds = %133
%143 = load i64, i64* %4
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.21, i64 0, i64 0), i64 %143)
br label %145
145: ; preds = %142, %138
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%147 = load i32, i32* %7
ret i32 %147
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str.1 = [31 x i8] c"ERROR: failed to get stack %s\0A\00"
@.str.2 = [31 x i8] c"DEBUG: stack addr %p size %ld\0A\00"
@.str.3 = [38 x i8] c"ERROR: failed to get detach state %s\0A\00"
@.str.4 = [11 x i8] c"DEBUG: %s\0A\00"
@PTHREAD_CREATE_DETACHED = global i32 0
@.str.5 = [24 x i8] c"PTHREAD_CREATE_DETACHED\00"
@PTHREAD_CREATE_JOINABLE = global i32 0
@.str.6 = [24 x i8] c"PTHREAD_CREATE_JOINABLE\00"
@.str.7 = [4 x i8] c"???\00"
@.str.8 = [31 x i8] c"ERROR: failed to get scope %s\0A\00"
@PTHREAD_SCOPE_SYSTEM = global i32 0
@.str.9 = [21 x i8] c"PTHREAD_SCOPE_SYSTEM\00"
@PTHREAD_SCOPE_PROCESS = global i32 0
@.str.10 = [22 x i8] c"PTHREAD_SCOPE_PROCESS\00"
@.str.11 = [39 x i8] c"ERROR: failed to get inherit sched %s\0A\00"
@PTHREAD_INHERIT_SCHED = global i32 0
@.str.12 = [22 x i8] c"PTHREAD_INHERIT_SCHED\00"
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.13 = [23 x i8] c"PTHREAD_EXPLICIT_SCHED\00"
@.str.14 = [38 x i8] c"ERROR: failed to get sched policy %s\0A\00"
@SCHED_OTHER = global i32 0
@.str.15 = [12 x i8] c"SCHED_OTHER\00"
@SCHED_FIFO = global i32 0
@.str.16 = [11 x i8] c"SCHED_FIFO\00"
@SCHED_RR = global i32 0
@.str.17 = [9 x i8] c"SCHED_RR\00"
@.str.18 = [37 x i8] c"ERROR: failed to get sched param %s\0A\00"
@.str.19 = [11 x i8] c"DEBUG: %d\0A\00"
@.str.20 = [36 x i8] c"ERROR: failed to get guard size %s\0A\00"
@.str.21 = [23 x i8] c"DEBUG: guard size %ld\0A\00"
@str.22 = [63 x i8] c"//////////////////////////////////////////////////////////////\00"
define i32 @get_attr(i32* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca %struct.sched_param
%6 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%7 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%8 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%9 = bitcast %struct.sched_param* %5 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.22, i64 0, i64 0))
%11 = call i32 @pthread_attr_getstack(i32* %0, i8** %2, i64* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = call i8* @strerror(i32 %11)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %17, i64 %18)
br label %20
20: ; preds = %16, %13
%21 = call i32 @pthread_attr_getdetachstate(i32* %0, i32* %4)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = call i8* @strerror(i32 %21)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %35
26: ; preds = %20
%27 = load i32, i32* %4
%28 = load i32, i32* @PTHREAD_CREATE_DETACHED
%29 = icmp eq i32 %27, %28
%30 = load i32, i32* @PTHREAD_CREATE_JOINABLE
%31 = icmp eq i32 %27, %30
%32 = select i1 %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%33 = select i1 %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %26, %23
%36 = call i32 @pthread_attr_getscope(i32* %0, i32* %4)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = call i8* @strerror(i32 %36)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %39)
br label %50
41: ; preds = %35
%42 = load i32, i32* %4
%43 = load i32, i32* @PTHREAD_SCOPE_SYSTEM
%44 = icmp eq i32 %42, %43
%45 = load i32, i32* @PTHREAD_SCOPE_PROCESS
%46 = icmp eq i32 %42, %45
%47 = select i1 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%48 = select i1 %44, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %41, %38
%51 = call i32 @pthread_attr_getinheritsched(i32* %0, i32* %4)
%52 = icmp eq i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = call i8* @strerror(i32 %51)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i8* %54)
br label %65
56: ; preds = %50
%57 = load i32, i32* %4
%58 = load i32, i32* @PTHREAD_INHERIT_SCHED
%59 = icmp eq i32 %57, %58
%60 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%61 = icmp eq i32 %57, %60
%62 = select i1 %61, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%63 = select i1 %59, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %56, %53
%66 = call i32 @pthread_attr_getschedpolicy(i32* %0, i32* %4)
%67 = icmp eq i32 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = call i8* @strerror(i32 %66)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0), i8* %69)
br label %85
71: ; preds = %65
%72 = load i32, i32* %4
%73 = load i32, i32* @SCHED_OTHER
%74 = icmp eq i32 %72, %73
br i1 %74, label %82, label %75
75: ; preds = %71
%76 = load i32, i32* @SCHED_FIFO
%77 = icmp eq i32 %72, %76
br i1 %77, label %82, label %78
78: ; preds = %75
%79 = load i32, i32* @SCHED_RR
%80 = icmp eq i32 %72, %79
%81 = select i1 %80, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %82
82: ; preds = %78, %75, %71
%83 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), %71 ], [ %81, %78 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0), %75 ]
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %83)
br label %85
85: ; preds = %82, %68
%86 = call i32 @pthread_attr_getschedparam(i32* %0, %struct.sched_param* %5)
%87 = icmp eq i32 %86, 0
br i1 %87, label %91, label %88
88: ; preds = %85
%89 = call i8* @strerror(i32 %86)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.18, i64 0, i64 0), i8* %89)
br label %95
91: ; preds = %85
%92 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %5, i64 0, i32 0
%93 = load i32, i32* %92
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %91, %88
%96 = call i32 @pthread_attr_getguardsize(i32* %0, i64* %3)
%97 = icmp eq i32 %96, 0
br i1 %97, label %101, label %98
98: ; preds = %95
%99 = call i8* @strerror(i32 %96)
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.20, i64 0, i64 0), i8* %99)
br label %104
101: ; preds = %95
%102 = load i64, i64* %3
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.21, i64 0, i64 0), i64 %102)
br label %104
104: ; preds = %101, %98
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.22, i64 0, i64 0))
ret i32 %96
}