#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 *, char *, int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
void *fonction_thread(void *arg) {
  int i;
  for (i = 0; i < 5; i++) {
    printf("%s thread: %d\n", (char *)arg, i);
    usleep(10);
  }
  pthread_exit(0);
}


x86 assembly (clang, -O0):
<fonction_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1178 <fonction_thread+0x48>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <fonction_thread+0x13>
xor    %edi,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fonction_thread>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <usleep@plt>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <pthread_exit@plt>

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

LLVM IR (-O2):
@.str = [15 x i8] c"%s thread: %d\0A\00"
define noalias i8* @fonction_thread(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 0)
%3 = tail call i32 @usleep(i32 10)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 1)
%5 = tail call i32 @usleep(i32 10)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 2)
%7 = tail call i32 @usleep(i32 10)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 3)
%9 = tail call i32 @usleep(i32 10)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 4)
%11 = tail call i32 @usleep(i32 10)
%12 = tail call i32 @pthread_exit(i32 0)
ret i8* undef
}