#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*/ check_errno(int);
int /*<<< orphan*/ printf(char *, ...);
int pthread_attr_getstacksize(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ pthread_attr_init(int /*<<< orphan*/ *);
scalar_t__ pthread_self();
int /*<<< orphan*/ show_time();
int main(int argc, char *argv[]) {
  pthread_attr_t attr;
  pthread_attr_init(&attr);
  size_t stacksize = 0;
  int err = pthread_attr_getstacksize(&attr, &stacksize);
  if (0 != err) {
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("pthread_attr_getstacksize() faild");
      printf("\n");
    } while (0);
    check_errno(err);
  }
  printf("stacksize : [%lu]\n", stacksize);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <pthread_attr_init@plt>
movq   $0x0,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <pthread_attr_getstacksize@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     11ea <main+0x8a>
jmp    11a7 <main+0x47>
mov    $0x0,%al
call   1050 <show_time@plt>
mov    $0x0,%al
call   1060 <pthread_self@plt>
mov    %rax,%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%edi
call   1070 <check_errno@plt>
mov    -0x20(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <pthread_attr_init@plt>
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1090 <pthread_attr_getstacksize@plt>
test   %eax,%eax
je     11d9 <main+0x69>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <show_time@plt>
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0xe50(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1080 <check_errno@plt>
mov    (%rsp),%rsi
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [34 x i8] c"pthread_attr_getstacksize() faild\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [19 x i8] c"stacksize : [%lu]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @pthread_attr_init(i32* %6)
store i64 0, i64* %7
%10 = call i32 @pthread_attr_getstacksize(i32* %6, i64* %7)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp ne i32 0, %11
br i1 %12, label %13, label %23
13: ; preds = %2
br label %14
14: ; preds = %13
%15 = call i32 (...) @show_time()
%16 = call i64 (...) @pthread_self()
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %14
%21 = load i32, i32* %8
%22 = call i32 @check_errno(i32 %21)
br label %23
23: ; preds = %20, %2
%24 = load i64, i64* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [34 x i8] c"pthread_attr_getstacksize() faild\00"
@.str.3 = [19 x i8] c"stacksize : [%lu]\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i64
%5 = bitcast i32* %3 to i8*
%6 = call i32 @pthread_attr_init(i32* %3)
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = call i32 @pthread_attr_getstacksize(i32* %3, i64* %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = call i32 (...) @show_time()
%12 = call i64 (...) @pthread_self()
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @putchar(i32 10)
%16 = call i32 @check_errno(i32 %8)
br label %17
17: ; preds = %10, %2
%18 = load i64, i64* %4
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %18)
ret i32 0
}