#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*/ printf(char *, ...);
scalar_t__ pthread_attr_getstacksize(int /*<<< orphan*/ *, size_t *);
scalar_t__ pthread_attr_init(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  pthread_attr_t attr;
  size_t stack_size;
  if (pthread_attr_init(&attr)) {
    printf("pthread_attr_init failed\n");
    return 1;
  }
  if (pthread_attr_getstacksize(&attr, &stack_size)) {
    printf("pthread_attr_getstacksize failed\n");
    return 1;
  }
  printf("Default stack size: %iB  %ikB  %gMB\n", ((int)stack_size),
         ((int)(stack_size >> 10)), stack_size / (1024.0 * 1024.0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <pthread_attr_init@plt>
cmp    $0x0,%rax
je     1173 <main+0x43>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xcb>
lea    -0x14(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <pthread_attr_getstacksize@plt>
cmp    $0x0,%rax
je     11a4 <main+0x74>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xcb>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    %rax,%rcx
shr    $0xa,%rcx
mov    %ecx,%edx
movq   %rax,%xmm0
movaps 0xe51(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe55(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1e(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdi
call   1050 <pthread_attr_init@plt>
test   %rax,%rax
je     115c <main+0x1c>
lea    0xf14(%rip),%rdi
jmp    1177 <main+0x37>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1060 <pthread_attr_getstacksize@plt>
test   %rax,%rax
je     1186 <main+0x46>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret
mov    0x10(%rsp),%rsi
movq   %rsi,%xmm1
mov    %rsi,%rdx
shr    $0xa,%rdx
punpckldq 0xe61(%rip),%xmm1
subpd  0xe69(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe65(%rip),%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"pthread_attr_init failed\0A\00"
@.str.1 = [34 x i8] c"pthread_attr_getstacksize failed\0A\00"
@.str.2 = [37 x i8] c"Default stack size: %iB %ikB %gMB\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @pthread_attr_init(i32* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %27
12: ; preds = %2
%13 = call i64 @pthread_attr_getstacksize(i32* %6, i64* %7)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %27
17: ; preds = %12
%18 = load i64, i64* %7
%19 = trunc i64 %18 to i32
%20 = load i64, i64* %7
%21 = lshr i64 %20, 10
%22 = trunc i64 %21 to i32
%23 = load i64, i64* %7
%24 = uitofp i64 %23 to double
%25 = fdiv double %24, 0x4130000000000000
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22, double %25)
store i32 0, i32* %3
br label %27
27: ; preds = %17, %15, %10
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str.2 = [37 x i8] c"Default stack size: %iB %ikB %gMB\0A\00"
@str = [33 x i8] c"pthread_attr_getstacksize failed\00"
@str.3 = [25 x i8] c"pthread_attr_init failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i64
%5 = bitcast i32* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = call i64 @pthread_attr_init(i32* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
br label %24
11: ; preds = %2
%12 = call i64 @pthread_attr_getstacksize(i32* %3, i64* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %24
16: ; preds = %11
%17 = load i64, i64* %4
%18 = trunc i64 %17 to i32
%19 = lshr i64 %17, 10
%20 = trunc i64 %19 to i32
%21 = uitofp i64 %17 to double
%22 = fmul double %21, 0x3EB0000000000000
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %20, double %22)
br label %24
24: ; preds = %16, %14, %9
%25 = phi i32 [ 1, %9 ], [ 1, %14 ], [ 0, %16 ]
ret i32 %25
}