#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   void *(*)(void *), void *);
int /*<<< orphan*/ stderr;
char *strerror(int);
void x_cgo_sys_thread_create(void *(*func)(void *), void *arg) {
  pthread_t p;
  int err = pthread_create(&p, NULL, func, arg);
  if (err != 0) {
    fprintf(stderr, "pthread_create failed: %s", strerror(err));
    abort();
  }
}


x86 assembly (clang, -O0):
<x_cgo_sys_thread_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pthread_create@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     119f <x_cgo_sys_thread_create+0x5f>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_cgo_sys_thread_create>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xc(%rsp),%rdi
xor    %esi,%esi
call   1050 <pthread_create@plt>
test   %eax,%eax
jne    1161 <x_cgo_sys_thread_create+0x21>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e78(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe88(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"pthread_create failed: %s\00"
define void @x_cgo_sys_thread_create(i8* (i8*)* %0, i8* %1) {
%3 = alloca i8* (i8*)*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* (i8*)* %0, i8* (i8*)** %3
store i8* %1, i8** %4
%7 = load i8* (i8*)*, i8* (i8*)** %3
%8 = load i8*, i8** %4
%9 = call i32 @pthread_create(i32* %5, i32* null, i8* (i8*)* %7, i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32, i32* %6
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"pthread_create failed: %s\00"
define void @x_cgo_sys_thread_create(i8* (i8*)* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @pthread_create(i32* %3, i32* null, i8* (i8*)* %0, i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = call i8* @strerror(i32 %5)
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %2
ret void
}