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

/* Variables and functions */
int getpid();
int /*<<< orphan*/ printf(char *, char *, int, int, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ pthread_self();
int rand();
int /*<<< orphan*/ usleep(int);
void *start_routine(void *arg) {
  pid_t pid = getpid();
  pthread_t ptid = pthread_self();
  usleep(rand() % 100);
  printf("[%s], process_id = %d (0x%lx), thread_id = %lu (0x%lx)\n",
         (char *)arg, pid, pid, ptid, ptid);
  return arg;
}


x86 assembly (clang, -O0):
<start_routine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1070 <usleep@plt>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_routine>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <pthread_self@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1070 <usleep@plt>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %ebx,%r9d
call   1040 <printf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"[%s], process_id = %d (0x%lx), thread_id = %lu (0x%lx)\0A\00"
define i8* @start_routine(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 (...) @getpid()
store i32 %5, i32* %3
%6 = call i32 (...) @pthread_self()
store i32 %6, i32* %4
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = call i32 @usleep(i32 %8)
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = load i32, i32* %4
%15 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11, i32 %12, i32 %13, i32 %14)
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@.str = [56 x i8] c"[%s], process_id = %d (0x%lx), thread_id = %lu (0x%lx)\0A\00"
define i8* @start_routine(i8* returned %0) {
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 (...) @pthread_self()
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = tail call i32 @usleep(i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %2, i32 %3, i32 %3)
ret i8* %0
}