#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;

/* Variables and functions */
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ errno;
scalar_t__ pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          void *(*)(void *), void *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void Pthread_create(pthread_t *tidp, void *(*start_rtn)(void *), void *arg) {
  if (pthread_create(tidp, NULL, start_rtn, arg) != 0)
    do {
      strerror(errno);
      puts("\n");
      err_quit("pthread create error");
    } while (1);
}


x86 assembly (clang, -O0):
<Pthread_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pthread_create@plt>
cmp    $0x0,%rax
je     11b2 <Pthread_create+0x72>
jmp    1178 <Pthread_create+0x38>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe69(%rip),%rdi
call   1040 <err_quit@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1178 <Pthread_create+0x38>
jmp    11ad <Pthread_create+0x6d>
jmp    11b2 <Pthread_create+0x72>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pthread_create>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rcx
mov    %rsi,%rdx
xor    %esi,%esi
call   1050 <pthread_create@plt>
test   %rax,%rax
je     118a <Pthread_create+0x4a>
mov    0x2e82(%rip),%r15
lea    0xe9b(%rip),%r14
lea    0xe96(%rip),%rbx
nopl   0x0(%rax)
mov    (%r15),%edi
call   1060 <strerror@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <err_quit@plt>
jmp    1170 <Pthread_create+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [21 x i8] c"pthread create error\00"
define void @Pthread_create(i32* %0, i8* (i8*)* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8* (i8*)*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* (i8*)* %1, i8* (i8*)** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %4
%8 = load i8* (i8*)*, i8* (i8*)** %5
%9 = load i8*, i8** %6
%10 = call i64 @pthread_create(i32* %7, i32* null, i8* (i8*)* %8, i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %3
br label %13
13: ; preds = %18, %12
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @err_quit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %13
br i1 true, label %13, label %19
19: ; preds = %18
br label %20
20: ; preds = %19, %3
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [21 x i8] c"pthread create error\00"
define void @Pthread_create(i32* %0, i8* (i8*)* %1, i8* %2) {
%4 = tail call i64 @pthread_create(i32* %0, i32* null, i8* (i8*)* %1, i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3, %6
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @err_quit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %6
11: ; preds = %3
ret void
}