#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*/ closeYAUThread();
int getYAUThreadid();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
void testthread_other() {
  int i;
  for (i = 0; i < 3; i++) {
    printf("Hello from Other thread %d \n", getYAUThreadid());
    sleep(1);
  }
  printf("Goodbye from thread %d\n", getYAUThreadid());
  closeYAUThread();
}


x86 assembly (clang, -O0):
<testthread_other>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    1186 <testthread_other+0x46>
mov    $0x0,%al
call   1030 <getYAUThreadid@plt>
mov    %eax,%esi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <testthread_other+0xf>
mov    $0x0,%al
call   1030 <getYAUThreadid@plt>
mov    %eax,%esi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <closeYAUThread@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testthread_other>:
push   %rbx
xor    %eax,%eax
call   1030 <getYAUThreadid@plt>
lea    0xeb1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
call   1030 <getYAUThreadid@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
call   1030 <getYAUThreadid@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
call   1030 <getYAUThreadid@plt>
lea    0xe76(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <closeYAUThread@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Hello from Other thread %d \0A\00"
@.str.1 = [24 x i8] c"Goodbye from thread %d\0A\00"
define void @testthread_other() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %9, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 3
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = call i32 (...) @getYAUThreadid()
%7 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @sleep(i32 1)
br label %9
9: ; preds = %5
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
br label %2
12: ; preds = %2
%13 = call i32 (...) @getYAUThreadid()
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @closeYAUThread()
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Hello from Other thread %d \0A\00"
@.str.1 = [24 x i8] c"Goodbye from thread %d\0A\00"
define void @testthread_other() {
%1 = tail call i32 (...) @getYAUThreadid()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @sleep(i32 1)
%4 = tail call i32 (...) @getYAUThreadid()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @sleep(i32 1)
%7 = tail call i32 (...) @getYAUThreadid()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @sleep(i32 1)
%10 = tail call i32 (...) @getYAUThreadid()
%11 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i32 (...) @closeYAUThread()
ret void
}