#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*/ PTHREAD_CREATE_DETACHED;
int /*<<< orphan*/ pthread_attr_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_attr_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_attr_setdetachstate(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ pthread_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  void *(*)(void *), void *);
void makethread(void *(*fn)(void *), void *arg) {
  pthread_t tid;
  pthread_attr_t attr;
  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  pthread_create(&tid, &attr, fn, arg);
  pthread_attr_destroy(&attr);
}


x86 assembly (clang, -O0):
<makethread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <pthread_attr_init@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdi
call   1040 <pthread_attr_setdetachstate@plt>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <pthread_create@plt>
lea    -0x18(%rbp),%rdi
call   1060 <pthread_attr_destroy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makethread>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <pthread_attr_init@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <pthread_attr_setdetachstate@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <pthread_create@plt>
mov    %rbx,%rdi
call   1060 <pthread_attr_destroy@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PTHREAD_CREATE_DETACHED = global i32 0
define void @makethread(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 = call i32 @pthread_attr_init(i32* %6)
%8 = load i32, i32* @PTHREAD_CREATE_DETACHED
%9 = call i32 @pthread_attr_setdetachstate(i32* %6, i32 %8)
%10 = load i8* (i8*)*, i8* (i8*)** %3
%11 = load i8*, i8** %4
%12 = call i32 @pthread_create(i32* %5, i32* %6, i8* (i8*)* %10, i8* %11)
%13 = call i32 @pthread_attr_destroy(i32* %6)
ret void
}

LLVM IR (-O2):
@PTHREAD_CREATE_DETACHED = global i32 0
define void @makethread(i8* (i8*)* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @pthread_attr_init(i32* %4)
%8 = load i32, i32* @PTHREAD_CREATE_DETACHED
%9 = call i32 @pthread_attr_setdetachstate(i32* %4, i32 %8)
%10 = call i32 @pthread_create(i32* %3, i32* %4, i8* (i8*)* %0, i8* %1)
%11 = call i32 @pthread_attr_destroy(i32* %4)
ret void
}