#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ display_pthread_attr(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int pthread_getattr_np(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_self();
void *thread_start_init(void *arg) {
  int s;
  pthread_attr_t gattr;
  s = pthread_getattr_np(pthread_self(), &gattr);
  if (s != 0)
    do {
      printf("[err=%d][line = %d] %s\n", s, 156, "pthread_getattr_np");
      exit(EXIT_FAILURE);
    } while (0);
  printf("Thread attributes:\n");
  display_pthread_attr(&gattr, "\t");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<thread_start_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <pthread_self@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1030 <pthread_getattr_np@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ab <thread_start_init+0x5b>
jmp    1180 <thread_start_init+0x30>
mov    -0xc(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x9c,%edx
lea    0xe82(%rip),%rcx
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x10(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <display_pthread_attr@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<thread_start_init>:
push   %rax
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1040 <pthread_getattr_np@plt>
test   %eax,%eax
jne    11a3 <thread_start_init+0x43>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1050 <display_pthread_attr@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xe56(%rip),%rdi
lea    0xe67(%rip),%rcx
mov    %eax,%esi
mov    $0x9c,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"[err=%d][line = %d] %s\0A\00"
@.str.1 = [19 x i8] c"pthread_getattr_np\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [20 x i8] c"Thread attributes:\0A\00"
@.str.3 = [2 x i8] c"\09\00"
@EXIT_SUCCESS = global i32 0
define i8* @thread_start_init(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 (...) @pthread_self()
%6 = call i32 @pthread_getattr_np(i32 %5, i32* %4)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %1
br label %10
10: ; preds = %9
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %11, i32 156, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; No predecessors!
br label %16
16: ; preds = %15, %1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @display_pthread_attr(i32* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
}

LLVM IR (-O2):
@.str = [24 x i8] c"[err=%d][line = %d] %s\0A\00"
@.str.1 = [19 x i8] c"pthread_getattr_np\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [2 x i8] c"\09\00"
@EXIT_SUCCESS = global i32 0
@str = [19 x i8] c"Thread attributes:\00"
define noalias i8* @thread_start_init(i8* nocapture readnone %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (...) @pthread_self()
%5 = call i32 @pthread_getattr_np(i32 %4, i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %5, i32 156, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%13 = call i32 @display_pthread_attr(i32* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* @EXIT_SUCCESS
%15 = call i32 @exit(i32 %14)
unreachable
}