#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 Receive(char *, int);
int /*<<< orphan*/ Reply(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Send(int, char *, int, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int /*<<< orphan*/ console_xy(int, int);
int /*<<< orphan*/ cprintf(char *);
main() {
  int i;
  char data[11];
  char getData = 's';
  char sendData;
  int tid;
  data[10] = '\0';
  console_xy(0, 10);
  cprintf("Sensor Data : ");
  while (1) {
    tid = Receive(&getData, sizeof(char));
    Reply(tid, 0, 0);
    if (getData == 's') {
      console_xy(19, 10);
      cprintf("*");
      sendData = ',';
      Send(4, &sendData, sizeof(char), 0, 0);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x73,-0x14(%rbp)
movb   $0x0,-0x9(%rbp)
xor    %edi,%edi
mov    $0xa,%esi
call   1060 <console_xy@plt>
lea    0xe86(%rip),%rdi
call   1050 <cprintf@plt>
lea    -0x14(%rbp),%rdi
mov    $0x1,%esi
call   1030 <Receive@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <Reply@plt>
movsbl -0x14(%rbp),%eax
cmp    $0x73,%eax
jne    11e1 <main+0x91>
mov    $0x13,%edi
mov    $0xa,%esi
call   1060 <console_xy@plt>
lea    0xe50(%rip),%rdi
call   1050 <cprintf@plt>
movb   $0x2c,-0x15(%rbp)
mov    $0x4,%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1070 <Send@plt>
jmp    117f <main+0x2f>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x73,0xe(%rsp)
xor    %edi,%edi
mov    $0xa,%esi
call   1060 <console_xy@plt>
lea    0xe8f(%rip),%rdi
call   1050 <cprintf@plt>
lea    0xe(%rsp),%rbx
lea    0xe8d(%rip),%r14
lea    0xf(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <Receive@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <Reply@plt>
cmpb   $0x73,0xe(%rsp)
jne    1190 <main+0x40>
mov    $0x13,%edi
mov    $0xa,%esi
call   1060 <console_xy@plt>
mov    %r14,%rdi
call   1050 <cprintf@plt>
movb   $0x2c,0xf(%rsp)
mov    $0x4,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <Send@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [15 x i8] c"Sensor Data : \00"
@.str.1 = [2 x i8] c"*\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [11 x i8]
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
store i8 115, i8* %4
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 10
store i8 0, i8* %7
%8 = call i32 @console_xy(i32 0, i32 10)
%9 = call i32 @cprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %21
%11 = call i32 @Receive(i8* %4, i32 1)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 @Reply(i32 %12, i32 0, i32 0)
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 115
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = call i32 @console_xy(i32 19, i32 10)
%19 = call i32 @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8 44, i8* %5
%20 = call i32 @Send(i32 4, i8* %5, i32 1, i32 0, i32 0)
br label %21
21: ; preds = %17, %10
br label %10
}

LLVM IR (-O2):
@.str = [15 x i8] c"Sensor Data : \00"
@.str.1 = [2 x i8] c"*\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
store i8 115, i8* %1
%3 = tail call i32 @console_xy(i32 0, i32 10)
%4 = tail call i32 @cprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %14, %0
%6 = call i32 @Receive(i8* %1, i32 1)
%7 = call i32 @Reply(i32 %6, i32 0, i32 0)
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 115
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = call i32 @console_xy(i32 19, i32 10)
%12 = call i32 @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8 44, i8* %2
%13 = call i32 @Send(i32 4, i8* %2, i32 1, i32 0, i32 0)
br label %14
14: ; preds = %10, %5
br label %5
}