#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 *, int, int);
int /*<<< orphan*/ sleep(int);
int thread_self();
int Tc1ThreadProc(int param) {
  int tid = 0;
  int count = 0;
  tid = thread_self();
  count = 5;
  while (count > 0) {
    sleep(2);
    printf("Tc1ThreadProc: my thread id (%d), arg is (%d)\n", tid, param);
    count--;
  }
}


x86 assembly (clang, -O0):
<Tc1ThreadProc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <thread_self@plt>
mov    %eax,-0xc(%rbp)
movl   $0x5,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    118e <Tc1ThreadProc+0x5e>
mov    $0x2,%edi
call   1050 <sleep@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <Tc1ThreadProc+0x2a>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tc1ThreadProc>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <thread_self@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1050 <sleep@plt>
lea    0xeb0(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"Tc1ThreadProc: my thread id (%d), arg is (%d)\0A\00"
define i32 @Tc1ThreadProc(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (...) @thread_self()
store i32 %6, i32* %4
store i32 5, i32* %5
br label %7
7: ; preds = %10, %1
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = call i32 @sleep(i32 2)
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %5
%16 = add nsw i32 %15, -1
store i32 %16, i32* %5
br label %7
17: ; preds = %7
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [47 x i8] c"Tc1ThreadProc: my thread id (%d), arg is (%d)\0A\00"
define i32 @Tc1ThreadProc(i32 %0) {
%2 = tail call i32 (...) @thread_self()
%3 = tail call i32 @sleep(i32 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
%5 = tail call i32 @sleep(i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
%7 = tail call i32 @sleep(i32 2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
%9 = tail call i32 @sleep(i32 2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
%11 = tail call i32 @sleep(i32 2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %0)
ret i32 undef
}