#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*/ Exit();
int MyPriority();
int MyTid();
int Receive(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Reply(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Write(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ strLen(char *);
main() {
  int tid1, tid2;
  char strWrite[50];
  sprintf(strWrite, "I am TaskC[%d], priority[%d] \n", MyTid(), MyPriority());
  Write(strWrite, strLen(strWrite), 1);
  tid1 = Receive(0, 0);
  sprintf(strWrite, "Task C got msg from tid1[%d] \n", tid1);
  Write(strWrite, strLen(strWrite), 1);
  Reply(tid1, 0, 0);
  sprintf(strWrite, "Task C Replied to tid1[%d] \n", tid1);
  Write(strWrite, strLen(strWrite), 1);
  sprintf(strWrite, ">I am TaskC[%d], priority[%d] \n", MyTid(), MyPriority());
  Write(strWrite, strLen(strWrite), 1);
  tid2 = Receive(0, 0);
  sprintf(strWrite, "Task C got msg from tid2[%d] \n", tid2);
  Write(strWrite, strLen(strWrite), 1);
  Reply(tid2, 0, 0);
  sprintf(strWrite, "Task C Replied to tid2[%d] \n", tid2);
  Write(strWrite, strLen(strWrite), 1);
  sprintf(strWrite, ">>I am TaskC[%d], priority[%d] \n", MyTid(), MyPriority());
  Write(strWrite, strLen(strWrite), 1);
  Exit();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x40(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x0,%al
call   1040 <MyTid@plt>
mov    %eax,-0x9c(%rbp)
mov    $0x0,%al
call   1080 <MyPriority@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x9c(%rbp),%edx
mov    %eax,%ecx
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Receive@plt>
mov    %eax,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
mov    -0x4(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Reply@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    $0x0,%al
call   1040 <MyTid@plt>
mov    %eax,-0x74(%rbp)
mov    $0x0,%al
call   1080 <MyPriority@plt>
mov    -0x80(%rbp),%rdi
mov    -0x74(%rbp),%edx
mov    %eax,%ecx
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Receive@plt>
mov    %eax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
mov    -0x8(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Reply@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1040 <MyTid@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1080 <MyPriority@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%edx
mov    %eax,%ecx
lea    0xcfc(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <strLen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
mov    $0x0,%al
call   1090 <Exit@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1040 <MyTid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <MyPriority@plt>
lea    0xedd(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <Receive@plt>
mov    %eax,%ebp
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Reply@plt>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %eax,%eax
call   1040 <MyTid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <MyPriority@plt>
lea    0xe33(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <Receive@plt>
mov    %eax,%ebp
lea    0xdbf(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Reply@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %eax,%eax
call   1040 <MyTid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <MyPriority@plt>
lea    0xd8c(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <Write@plt>
xor    %eax,%eax
call   1090 <Exit@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"I am TaskC[%d], priority[%d] \0A\00"
@.str.1 = [31 x i8] c"Task C got msg from tid1[%d] \0A\00"
@.str.2 = [29 x i8] c"Task C Replied to tid1[%d] \0A\00"
@.str.3 = [32 x i8] c">I am TaskC[%d], priority[%d] \0A\00"
@.str.4 = [31 x i8] c"Task C got msg from tid2[%d] \0A\00"
@.str.5 = [29 x i8] c"Task C Replied to tid2[%d] \0A\00"
@.str.6 = [33 x i8] c">>I am TaskC[%d], priority[%d] \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = call i32 (...) @MyTid()
%6 = call i32 (...) @MyPriority()
%7 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%10 = call i32 @strLen(i8* %9)
%11 = call i32 @Write(i8* %8, i32 %10, i32 1)
%12 = call i32 @Receive(i32 0, i32 0)
store i32 %12, i32* %1
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %1
%15 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%18 = call i32 @strLen(i8* %17)
%19 = call i32 @Write(i8* %16, i32 %18, i32 1)
%20 = load i32, i32* %1
%21 = call i32 @Reply(i32 %20, i32 0, i32 0)
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %1
%24 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%27 = call i32 @strLen(i8* %26)
%28 = call i32 @Write(i8* %25, i32 %27, i32 1)
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%30 = call i32 (...) @MyTid()
%31 = call i32 (...) @MyPriority()
%32 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31)
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%34 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%35 = call i32 @strLen(i8* %34)
%36 = call i32 @Write(i8* %33, i32 %35, i32 1)
%37 = call i32 @Receive(i32 0, i32 0)
store i32 %37, i32* %2
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%39 = load i32, i32* %2
%40 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%43 = call i32 @strLen(i8* %42)
%44 = call i32 @Write(i8* %41, i32 %43, i32 1)
%45 = load i32, i32* %2
%46 = call i32 @Reply(i32 %45, i32 0, i32 0)
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%48 = load i32, i32* %2
%49 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%52 = call i32 @strLen(i8* %51)
%53 = call i32 @Write(i8* %50, i32 %52, i32 1)
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%55 = call i32 (...) @MyTid()
%56 = call i32 (...) @MyPriority()
%57 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %55, i32 %56)
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%59 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%60 = call i32 @strLen(i8* %59)
%61 = call i32 @Write(i8* %58, i32 %60, i32 1)
%62 = call i32 (...) @Exit()
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"I am TaskC[%d], priority[%d] \0A\00"
@.str.1 = [31 x i8] c"Task C got msg from tid1[%d] \0A\00"
@.str.2 = [29 x i8] c"Task C Replied to tid1[%d] \0A\00"
@.str.3 = [32 x i8] c">I am TaskC[%d], priority[%d] \0A\00"
@.str.4 = [31 x i8] c"Task C got msg from tid2[%d] \0A\00"
@.str.5 = [29 x i8] c"Task C Replied to tid2[%d] \0A\00"
@.str.6 = [33 x i8] c">>I am TaskC[%d], priority[%d] \0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @MyTid()
%4 = tail call i32 (...) @MyPriority()
%5 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = call i32 @strLen(i8* %2)
%7 = call i32 @Write(i8* %2, i32 %6, i32 1)
%8 = call i32 @Receive(i32 0, i32 0)
%9 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @strLen(i8* %2)
%11 = call i32 @Write(i8* %2, i32 %10, i32 1)
%12 = call i32 @Reply(i32 %8, i32 0, i32 0)
%13 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%14 = call i32 @strLen(i8* %2)
%15 = call i32 @Write(i8* %2, i32 %14, i32 1)
%16 = call i32 (...) @MyTid()
%17 = call i32 (...) @MyPriority()
%18 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %17)
%19 = call i32 @strLen(i8* %2)
%20 = call i32 @Write(i8* %2, i32 %19, i32 1)
%21 = call i32 @Receive(i32 0, i32 0)
%22 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = call i32 @strLen(i8* %2)
%24 = call i32 @Write(i8* %2, i32 %23, i32 1)
%25 = call i32 @Reply(i32 %21, i32 0, i32 0)
%26 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%27 = call i32 @strLen(i8* %2)
%28 = call i32 @Write(i8* %2, i32 %27, i32 1)
%29 = call i32 (...) @MyTid()
%30 = call i32 (...) @MyPriority()
%31 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %29, i32 %30)
%32 = call i32 @strLen(i8* %2)
%33 = call i32 @Write(i8* %2, i32 %32, i32 1)
%34 = call i32 (...) @Exit()
ret i32 0
}