#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 /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
void thread_1(void) {
  int i = 0;
  for (i = 0; i <= 6; i++) {
    printf("This is a pthread_1.\n");
    if (i == 2)
      pthread_exit(0);
    sleep(3);
  }
}


x86 assembly (clang, -O0):
<thread_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jg     1185 <thread_1+0x55>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
jne    116d <thread_1+0x3d>
xor    %edi,%edi
call   1040 <pthread_exit@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1146 <thread_1+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thread_1>:
push   %rbx
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <pthread_exit@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
pop    %rbx
jmp    1050 <sleep@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"This is a pthread_1.\0A\00"
define void @thread_1() {
%1 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %1
br label %2
2: ; preds = %13, %0
%3 = load i32, i32* %1
%4 = icmp sle i32 %3, 6
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @pthread_exit(i32 0)
br label %11
11: ; preds = %9, %5
%12 = call i32 @sleep(i32 3)
br label %13
13: ; preds = %11
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %2
16: ; preds = %2
ret void
}

LLVM IR (-O2):
@str = [21 x i8] c"This is a pthread_1.\00"
define void @thread_1() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @sleep(i32 3)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @sleep(i32 3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @pthread_exit(i32 0)
%7 = tail call i32 @sleep(i32 3)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @sleep(i32 3)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @sleep(i32 3)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @sleep(i32 3)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @sleep(i32 3)
ret void
}