#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*/ printf(char *, long, long, long);
int rand();
int /*<<< orphan*/ usleep(int);
void *PrintHello(void *threadid) {
  long *tid = threadid;
  long t;
  long numprint = 3;
  for (t = 0; t < numprint; t++) {
    printf("Hello World! It's me, thread #%ld! "
           "This is printout %ld of %ld\n",
           *tid, (t + 1), numprint);
    usleep((rand() % 100) * 10000 + 1000000);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<PrintHello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x3,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11b2 <PrintHello+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
imul   $0x2710,%edx,%edi
add    $0xf4240,%edi
call   1050 <usleep@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1154 <PrintHello+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintHello>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rsi
lea    0xebf(%rip),%r14
mov    $0x1,%edx
mov    $0x3,%ecx
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
imul   $0x2710,%eax,%edi
add    $0xf4240,%edi
call   1050 <usleep@plt>
mov    (%rbx),%rsi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
imul   $0x2710,%eax,%edi
add    $0xf4240,%edi
call   1050 <usleep@plt>
mov    (%rbx),%rsi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
imul   $0x2710,%eax,%edi
add    $0xf4240,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Hello World! It's me, thread #%ld! This is printout %ld of %ld\0A\00"
define i8* @PrintHello(i8* %0) {
%2 = alloca i8*
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i64*
store i64* %7, i64** %3
store i64 3, i64* %5
store i64 0, i64* %4
br label %8
8: ; preds = %24, %1
%9 = load i64, i64* %4
%10 = load i64, i64* %5
%11 = icmp slt i64 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i64*, i64** %3
%14 = load i64, i64* %13
%15 = load i64, i64* %4
%16 = add nsw i64 %15, 1
%17 = load i64, i64* %5
%18 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %16, i64 %17)
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 100
%21 = mul nsw i32 %20, 10000
%22 = add nsw i32 %21, 1000000
%23 = call i32 @usleep(i32 %22)
br label %24
24: ; preds = %12
%25 = load i64, i64* %4
%26 = add nsw i64 %25, 1
store i64 %26, i64* %4
br label %8
27: ; preds = %8
ret i8* null
}

LLVM IR (-O2):
@.str = [64 x i8] c"Hello World! It's me, thread #%ld! This is printout %ld of %ld\0A\00"
define noalias i8* @PrintHello(i8* nocapture %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %3, i64 1, i64 3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = mul nsw i32 %6, 10000
%8 = add nsw i32 %7, 1000000
%9 = tail call i32 @usleep(i32 %8)
%10 = load i64, i64* %2
%11 = tail call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %10, i64 2, i64 3)
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 100
%14 = mul nsw i32 %13, 10000
%15 = add nsw i32 %14, 1000000
%16 = tail call i32 @usleep(i32 %15)
%17 = load i64, i64* %2
%18 = tail call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i64 %17, i64 3, i64 3)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 100
%21 = mul nsw i32 %20, 10000
%22 = add nsw i32 %21, 1000000
%23 = tail call i32 @usleep(i32 %22)
ret i8* null
}