#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*/ Delay(int);
int /*<<< orphan*/ RegisterAs(char *);
int /*<<< orphan*/ Send(int, int /*<<< orphan*/, int /*<<< orphan*/,
                        unsigned char **, int);
int WhoIs(char *);
int /*<<< orphan*/ Write(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, unsigned char);
int /*<<< orphan*/ strLen(char *);
main() {
  char sendData = 's';
  char strWrite[20];
  int tid_sensorSrv;
  unsigned char sensorSendData[5], sensor;
  RegisterAs("SensorReporter");
  Delay(10);
  tid_sensorSrv = WhoIs("SensorSrv");
  while (1) {
    Send(tid_sensorSrv, 0, 0, &sensorSendData, 5 * sizeof(char));
    sensor = sensorSendData[0];
    sprintf(strWrite, "se %c %d\n", (((sensor & 0xf0) >> 4) + 'a'),
            ((sensor & 0x0f) + 1));
    Write(strWrite, strLen(strWrite), 1);
    Delay(5);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x73,-0x5(%rbp)
lea    0xe76(%rip),%rdi
call   1080 <RegisterAs@plt>
mov    $0xa,%edi
call   1030 <Delay@plt>
lea    0xe6f(%rip),%rdi
call   1050 <WhoIs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x29(%rbp),%rcx
xor    %edx,%edx
mov    $0x5,%r8d
mov    %edx,%esi
call   1070 <Send@plt>
mov    -0x29(%rbp),%al
mov    %al,-0x2a(%rbp)
lea    -0x20(%rbp),%rdi
movzbl -0x2a(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0x4c(%rbp)
sar    $0x4,%eax
mov    %eax,-0x48(%rbp)
add    $0x61,%eax
mov    %eax,-0x44(%rbp)
mov    %al,%cl
movzbl -0x2a(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x40(%rbp)
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    0xe20(%rip),%rsi
movzbl %cl,%edx
movzbl %al,%ecx
call   1090 <sprintf@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <strLen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <Write@plt>
mov    $0x5,%edi
call   1030 <Delay@plt>
jmp    11a8 <main+0x38>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xe7f(%rip),%rdi
call   1080 <RegisterAs@plt>
mov    $0xa,%edi
call   1030 <Delay@plt>
lea    0xe78(%rip),%rdi
call   1050 <WhoIs@plt>
mov    %eax,%ebp
lea    0xb(%rsp),%r14
lea    0xe6f(%rip),%r15
lea    0x10(%rsp),%rbx
nop
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %r14,%rcx
mov    $0x5,%r8d
call   1070 <Send@plt>
movzbl 0xb(%rsp),%eax
mov    %eax,%ecx
shr    $0x4,%cl
add    $0x61,%cl
and    $0xf,%al
add    $0x1,%al
movzbl %cl,%edx
movzbl %al,%ecx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strLen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <Write@plt>
mov    $0x5,%edi
call   1030 <Delay@plt>
jmp    11b0 <main+0x40>

LLVM IR (-O0):
@.str = [15 x i8] c"SensorReporter\00"
@.str.1 = [10 x i8] c"SensorSrv\00"
@.str.2 = [10 x i8] c"se %c %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca i8
store i32 0, i32* %1
store i8 115, i8* %2
%7 = call i32 @RegisterAs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @Delay(i32 10)
%9 = call i32 @WhoIs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %9, i32* %4
br label %10
10: ; preds = %0, %10
%11 = load i32, i32* %4
%12 = bitcast [5 x i8]* %5 to i8**
%13 = call i32 @Send(i32 %11, i32 0, i32 0, i8** %12, i32 5)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%15 = load i8, i8* %14
store i8 %15, i8* %6
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = and i32 %18, 240
%20 = ashr i32 %19, 4
%21 = add nsw i32 %20, 97
%22 = trunc i32 %21 to i8
%23 = load i8, i8* %6
%24 = zext i8 %23 to i32
%25 = and i32 %24, 15
%26 = add nsw i32 %25, 1
%27 = trunc i32 %26 to i8
%28 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %22, i8 zeroext %27)
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%31 = call i32 @strLen(i8* %30)
%32 = call i32 @Write(i8* %29, i32 %31, i32 1)
%33 = call i32 @Delay(i32 5)
br label %10
}

LLVM IR (-O2):
@.str = [15 x i8] c"SensorReporter\00"
@.str.1 = [10 x i8] c"SensorSrv\00"
@.str.2 = [10 x i8] c"se %c %d\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @RegisterAs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @Delay(i32 10)
%7 = tail call i32 @WhoIs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%8 = bitcast [5 x i8]* %2 to i8**
br label %9
9: ; preds = %9, %0
%10 = call i32 @Send(i32 %7, i32 0, i32 0, i8** %8, i32 5)
%11 = load i8, i8* %4
%12 = lshr i8 %11, 4
%13 = add nuw nsw i8 %12, 97
%14 = and i8 %11, 15
%15 = add nuw nsw i8 %14, 1
%16 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %13, i8 zeroext %15)
%17 = call i32 @strLen(i8* %3)
%18 = call i32 @Write(i8* %3, i32 %17, i32 1)
%19 = call i32 @Delay(i32 5)
br label %9
}