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

/* Variables and functions */
char *attrstr(char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ pthread_attr_getdetachstate(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ pthread_attr_getguardsize(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ pthread_attr_getinheritsched(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ pthread_attr_getschedparam(int /*<<< orphan*/ *,
                                              struct sched_param *);
int /*<<< orphan*/ pthread_attr_getschedpolicy(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ pthread_attr_getscope(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ pthread_attr_getstack(int /*<<< orphan*/ *, void **,
                                         size_t *);
int /*<<< orphan*/ pthread_attr_getstacksize(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ pthread_attr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
scalar_t__ pthread_self();
void *attrinfo(void *arg) {
  pthread_mutex_t *mutex;
  pthread_attr_t attr;
  void *stackaddr;
  size_t stacksize, guardsize;
  int detach, scope, isched, psched;
  struct sched_param sp;
  pthread_attr_init(&attr);
  pthread_attr_getstack(&attr, &stackaddr, &stacksize);
  pthread_attr_getstacksize(&attr, &stacksize);
  pthread_attr_getdetachstate(&attr, &detach);
  pthread_attr_getscope(&attr, &scope);
  pthread_attr_getinheritsched(&attr, &isched);
  pthread_attr_getschedpolicy(&attr, &psched);
  pthread_attr_getguardsize(&attr, &guardsize);
  pthread_attr_getschedparam(&attr, &sp);
  mutex = arg;
  pthread_mutex_lock(mutex);
  printf("thread id: %lx\n", (unsigned long)pthread_self());
  printf("thread stack addr: %p\n", stackaddr);
  printf("thread stack size: %zu bytes\n", stacksize);
  printf("thread guard size: %zu bytes\n", guardsize);
  printf("detach state: %s\n", attrstr('d', detach));
  printf("scope: %s\n", attrstr('s', scope));
  printf("inherit sched: %s\n", attrstr('i', isched));
  printf("sched policy: %s\n", attrstr('p', psched));
  printf("thread priority: %d\n", sp.sched_priority);
  printf("\n");
  pthread_mutex_unlock(mutex);
  return NULL;
}


x86 assembly (clang, -O0):
<attrinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <pthread_attr_init@plt>
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <pthread_attr_getstack@plt>
lea    -0x14(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1100 <pthread_attr_getstacksize@plt>
lea    -0x14(%rbp),%rdi
lea    -0x34(%rbp),%rsi
call   10e0 <pthread_attr_getdetachstate@plt>
lea    -0x14(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <pthread_attr_getscope@plt>
lea    -0x14(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   10b0 <pthread_attr_getinheritsched@plt>
lea    -0x14(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10c0 <pthread_attr_getschedpolicy@plt>
lea    -0x14(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <pthread_attr_getguardsize@plt>
lea    -0x14(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <pthread_attr_getschedparam@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <pthread_mutex_lock@plt>
mov    $0x0,%al
call   10d0 <pthread_self@plt>
mov    %rax,%rsi
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
mov    $0x64,%edi
call   1070 <attrstr@plt>
mov    %rax,%rsi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%esi
mov    $0x73,%edi
call   1070 <attrstr@plt>
mov    %rax,%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    $0x69,%edi
call   1070 <attrstr@plt>
mov    %rax,%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%esi
mov    $0x70,%edi
call   1070 <attrstr@plt>
mov    %rax,%rsi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <pthread_mutex_unlock@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attrinfo>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r14
lea    0x3c(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <pthread_attr_init@plt>
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1090 <pthread_attr_getstack@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1110 <pthread_attr_getstacksize@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   10f0 <pthread_attr_getdetachstate@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <pthread_attr_getscope@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <pthread_attr_getinheritsched@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10d0 <pthread_attr_getschedpolicy@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <pthread_attr_getguardsize@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <pthread_attr_getschedparam@plt>
mov    %r14,%rdi
call   1100 <pthread_mutex_lock@plt>
xor    %eax,%eax
call   10e0 <pthread_self@plt>
lea    0xd73(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%rsi
lea    0xd6d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%rsi
lea    0xd71(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xd7c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    $0x64,%edi
call   1080 <attrstr@plt>
lea    0xd7e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    $0x73,%edi
call   1080 <attrstr@plt>
lea    0xd71(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    $0x69,%edi
call   1080 <attrstr@plt>
lea    0xd5d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    $0x70,%edi
call   1080 <attrstr@plt>
lea    0xd51(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xd4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   10b0 <pthread_mutex_unlock@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [16 x i8] c"thread id: %lx\0A\00"
@.str.1 = [23 x i8] c"thread stack addr: %p\0A\00"
@.str.2 = [30 x i8] c"thread stack size: %zu bytes\0A\00"
@.str.3 = [30 x i8] c"thread guard size: %zu bytes\0A\00"
@.str.4 = [18 x i8] c"detach state: %s\0A\00"
@.str.5 = [11 x i8] c"scope: %s\0A\00"
@.str.6 = [19 x i8] c"inherit sched: %s\0A\00"
@.str.7 = [18 x i8] c"sched policy: %s\0A\00"
@.str.8 = [21 x i8] c"thread priority: %d\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i8* @attrinfo(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sched_param
store i8* %0, i8** %2
%13 = call i32 @pthread_attr_init(i32* %4)
%14 = call i32 @pthread_attr_getstack(i32* %4, i8** %5, i64* %6)
%15 = call i32 @pthread_attr_getstacksize(i32* %4, i64* %6)
%16 = call i32 @pthread_attr_getdetachstate(i32* %4, i32* %8)
%17 = call i32 @pthread_attr_getscope(i32* %4, i32* %9)
%18 = call i32 @pthread_attr_getinheritsched(i32* %4, i32* %10)
%19 = call i32 @pthread_attr_getschedpolicy(i32* %4, i32* %11)
%20 = call i32 @pthread_attr_getguardsize(i32* %4, i64* %7)
%21 = call i32 @pthread_attr_getschedparam(i32* %4, %struct.sched_param* %12)
%22 = load i8*, i8** %2
%23 = bitcast i8* %22 to i32*
store i32* %23, i32** %3
%24 = load i32*, i32** %3
%25 = call i32 @pthread_mutex_lock(i32* %24)
%26 = call i64 (...) @pthread_self()
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %26)
%28 = load i8*, i8** %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i64, i64* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i64 %30)
%32 = load i64, i64* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %32)
%34 = load i32, i32* %8
%35 = call i8* @attrstr(i8 signext 100, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %9
%38 = call i8* @attrstr(i8 signext 115, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %10
%41 = call i8* @attrstr(i8 signext 105, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %11
%44 = call i8* @attrstr(i8 signext 112, i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %12, i32 0, i32 0
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%50 = load i32*, i32** %3
%51 = call i32 @pthread_mutex_unlock(i32* %50)
ret i8* null
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str = [16 x i8] c"thread id: %lx\0A\00"
@.str.1 = [23 x i8] c"thread stack addr: %p\0A\00"
@.str.2 = [30 x i8] c"thread stack size: %zu bytes\0A\00"
@.str.3 = [30 x i8] c"thread guard size: %zu bytes\0A\00"
@.str.4 = [18 x i8] c"detach state: %s\0A\00"
@.str.5 = [11 x i8] c"scope: %s\0A\00"
@.str.6 = [19 x i8] c"inherit sched: %s\0A\00"
@.str.7 = [18 x i8] c"sched policy: %s\0A\00"
@.str.8 = [21 x i8] c"thread priority: %d\0A\00"
define noalias i8* @attrinfo(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sched_param
%11 = bitcast i32* %2 to i8*
%12 = bitcast i8** %3 to i8*
%13 = bitcast i64* %4 to i8*
%14 = bitcast i64* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast %struct.sched_param* %10 to i8*
%20 = call i32 @pthread_attr_init(i32* %2)
%21 = call i32 @pthread_attr_getstack(i32* %2, i8** %3, i64* %4)
%22 = call i32 @pthread_attr_getstacksize(i32* %2, i64* %4)
%23 = call i32 @pthread_attr_getdetachstate(i32* %2, i32* %6)
%24 = call i32 @pthread_attr_getscope(i32* %2, i32* %7)
%25 = call i32 @pthread_attr_getinheritsched(i32* %2, i32* %8)
%26 = call i32 @pthread_attr_getschedpolicy(i32* %2, i32* %9)
%27 = call i32 @pthread_attr_getguardsize(i32* %2, i64* %5)
%28 = call i32 @pthread_attr_getschedparam(i32* %2, %struct.sched_param* %10)
%29 = bitcast i8* %0 to i32*
%30 = call i32 @pthread_mutex_lock(i32* %29)
%31 = call i64 (...) @pthread_self()
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %31)
%33 = load i8*, i8** %3
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i64, i64* %4
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i64 %35)
%37 = load i64, i64* %5
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %37)
%39 = load i32, i32* %6
%40 = call i8* @attrstr(i8 signext 100, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %7
%43 = call i8* @attrstr(i8 signext 115, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = load i32, i32* %8
%46 = call i8* @attrstr(i8 signext 105, i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %46)
%48 = load i32, i32* %9
%49 = call i8* @attrstr(i8 signext 112, i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %10, i64 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %52)
%54 = call i32 @putchar(i32 10)
%55 = call i32 @pthread_mutex_unlock(i32* %29)
ret i8* null
}