#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int pthread_self();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
void dispatch_threadpool_to_me(void *arg) {
  int seconds = (int)arg;
  fprintf(stdout, "  in dispatch_threadpool %d\n", seconds);
  fprintf(stdout, "  thread#%ld\n", pthread_self());
  sleep(seconds);
  fprintf(stdout, "  done dispatch_threadpool %d\n", seconds);
}


x86 assembly (clang, -O0):
<dispatch_threadpool_to_me>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <pthread_self@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%edi
call   1050 <sleep@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe91(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispatch_threadpool_to_me>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
mov    (%r14),%edi
lea    0xeb8(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1040 <pthread_self@plt>
lea    0xebd(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    %ebx,%edi
call   1050 <sleep@plt>
mov    (%r14),%edi
lea    0xeb1(%rip),%rsi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [29 x i8] c" in dispatch_threadpool %d\0A\00"
@.str.1 = [14 x i8] c" thread#%ld\0A\00"
@.str.2 = [31 x i8] c" done dispatch_threadpool %d\0A\00"
define void @dispatch_threadpool_to_me(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = ptrtoint i8* %4 to i32
store i32 %5, i32* %3
%6 = load i32, i32* @stdout
%7 = load i32, i32* %3
%8 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 (...) @pthread_self()
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @sleep(i32 %12)
%14 = load i32, i32* @stdout
%15 = load i32, i32* %3
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %15)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [29 x i8] c" in dispatch_threadpool %d\0A\00"
@.str.1 = [14 x i8] c" thread#%ld\0A\00"
@.str.2 = [31 x i8] c" done dispatch_threadpool %d\0A\00"
define void @dispatch_threadpool_to_me(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = load i32, i32* @stdout
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = load i32, i32* @stdout
%7 = tail call i32 (...) @pthread_self()
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @sleep(i32 %3)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %3)
ret void
}