#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 /*<<< orphan*/ pthread_exit(char *);
int pthread_self();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
void *f2(void *p) {
  int i;
  printf("mytid=%u\n", pthread_self());
  for (i = 0; i < 5; i++) {
    write(1, "*", 1);
    sleep(1);
  }
  pthread_exit("Hello");
  puts("you cannot see me");
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <pthread_self@plt>
mov    %eax,%esi
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11bd <f2+0x5d>
mov    $0x1,%edx
lea    0xe6c(%rip),%rsi
mov    %edx,%edi
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <f2+0x28>
lea    0xe48(%rip),%rdi
call   1060 <pthread_exit@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %rbx
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
lea    0xe8d(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xdfc(%rip),%rdi
call   1060 <pthread_exit@plt>
lea    0xdf6(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"mytid=%u\0A\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [18 x i8] c"you cannot see me\00"
define i8* @f2(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (...) @pthread_self()
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 0, i32* %4
br label %7
7: ; preds = %13, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%12 = call i32 @sleep(i32 1)
br label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %7
16: ; preds = %7
%17 = call i32 @pthread_exit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [10 x i8] c"mytid=%u\0A\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [18 x i8] c"you cannot see me\00"
define noalias i8* @f2(i8* nocapture readnone %0) {
%2 = tail call i32 (...) @pthread_self()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = tail call i32 @sleep(i32 1)
%10 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = tail call i32 @sleep(i32 1)
%14 = tail call i32 @pthread_exit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
ret i8* undef
}