#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*/ assert(int);
int /*<<< orphan*/ printf(char *, size_t);
int pthread_attr_destroy(int /*<<< orphan*/ *);
int pthread_attr_getstacksize(int /*<<< orphan*/ *, size_t *);
int pthread_getattr_np(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_self();
void print_it() {
  int rc;
  pthread_attr_t foo;
  size_t size;
  rc = pthread_getattr_np(pthread_self(), &foo);
  assert(rc == 0);
  rc = pthread_attr_getstacksize(&foo, &size);
  assert(rc == 0);
  printf("stacksize=%u\n", size);
  rc = pthread_attr_destroy(&foo);
  assert(rc == 0);
}


x86 assembly (clang, -O0):
<print_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <pthread_self@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1030 <pthread_getattr_np@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <pthread_attr_getstacksize@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1070 <pthread_attr_destroy@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_it>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <pthread_self@plt>
lea    0xc(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <pthread_getattr_np@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <pthread_attr_getstacksize@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    (%rsp),%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <pthread_attr_destroy@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"stacksize=%u\0A\00"
define void @print_it() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = call i32 (...) @pthread_self()
%5 = call i32 @pthread_getattr_np(i32 %4, i32* %2)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @pthread_attr_getstacksize(i32* %2, i64* %3)
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i64, i64* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %15)
%17 = call i32 @pthread_attr_destroy(i32* %2)
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"stacksize=%u\0A\00"
define void @print_it() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (...) @pthread_self()
%6 = call i32 @pthread_getattr_np(i32 %5, i32* %1)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @pthread_attr_getstacksize(i32* %1, i64* %2)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i64, i64* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %14)
%16 = call i32 @pthread_attr_destroy(i32* %1)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret void
}