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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ printf(char *, ...);
int pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                   void *(*)(void *), void *);
char *strerror(int);
int PTHREAD_CREATE(pthread_t *new_thread_ID, const pthread_attr_t *attr,
                   void *(*start_func)(void *), void *arg) {
  int err;
  pthread_t tid;
  if (!new_thread_ID) {
    printf("TID cannot be NULL.\n");
    abort();
  }
  if (err = pthread_create(new_thread_ID, attr, start_func, arg)) {
    printf("%s\n", strerror(err));
    abort();
  }
}


x86 assembly (clang, -O0):
<PTHREAD_CREATE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1178 <PTHREAD_CREATE+0x38>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <pthread_create@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     11b9 <PTHREAD_CREATE+0x79>
mov    -0x2c(%rbp),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PTHREAD_CREATE>:
push   %rax
test   %rdi,%rdi
je     1151 <PTHREAD_CREATE+0x11>
call   1050 <pthread_create@plt>
test   %eax,%eax
jne    115a <PTHREAD_CREATE+0x1a>
pop    %rcx
ret
lea    0xea8(%rip),%rdi
jmp    1164 <PTHREAD_CREATE+0x24>
mov    %eax,%edi
call   1060 <strerror@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"TID cannot be NULL.\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @PTHREAD_CREATE(i32* %0, i32* %1, i8* (i8*)* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8* (i8*)*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i8* (i8*)* %2, i8* (i8*)** %8
store i8* %3, i8** %9
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = load i32*, i32** %7
%20 = load i8* (i8*)*, i8* (i8*)** %8
%21 = load i8*, i8** %9
%22 = call i32 @pthread_create(i32* %18, i32* %19, i8* (i8*)* %20, i8* %21)
store i32 %22, i32* %10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i32, i32* %10
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 (...) @abort()
unreachable
29: ; preds = %17
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@str = [20 x i8] c"TID cannot be NULL.\00"
define i32 @PTHREAD_CREATE(i32* %0, i32* %1, i8* (i8*)* %2, i8* %3) {
%5 = icmp eq i32* %0, null
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %4
%10 = tail call i32 @pthread_create(i32* %0, i32* %1, i8* (i8*)* %2, i8* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i8* @strerror(i32 %10)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %9
ret i32 undef
}