#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*/ cleanup();
int /*<<< orphan*/ initComms(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recvString(char *, ...);
int /*<<< orphan*/ sendString(int, char *);
int main() {
  int x, y, z;
  char buffers[255];
  initComms("COM5", 300);
  recvString("x:%d, y:%d, z:%d", &x, &y, &z);
  sendString(0x41, "MORE");
  recvString("%s", buffers);
  printf("\n> I got the positions: x:%d, y:%d, z:%d\n", x, y, z);
  printf("\n> The remote client responded with the string: %s\n", buffers);
  cleanup();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x12c,%esi
call   1040 <initComms@plt>
lea    0xe8b(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1060 <recvString@plt>
mov    $0x41,%edi
lea    0xe7d(%rip),%rsi
call   1030 <sendString@plt>
lea    -0x110(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1060 <recvString@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <cleanup@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x110,%rsp
lea    0xea1(%rip),%rdi
mov    $0x12c,%esi
call   1040 <initComms@plt>
lea    0xe95(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %eax,%eax
call   1060 <recvString@plt>
lea    0xe89(%rip),%rsi
mov    $0x41,%edi
call   1030 <sendString@plt>
lea    0xe7d(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <recvString@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <cleanup@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"COM5\00"
@.str.1 = [17 x i8] c"x:%d, y:%d, z:%d\00"
@.str.2 = [5 x i8] c"MORE\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [42 x i8] c"\0A> I got the positions: x:%d, y:%d, z:%d\0A\00"
@.str.5 = [52 x i8] c"\0A> The remote client responded with the string: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [255 x i8]
store i32 0, i32* %1
%6 = call i32 @initComms(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 300)
%7 = call i32 (i8*, ...) @recvString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = call i32 @sendString(i32 65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%10 = call i32 (i8*, ...) @recvString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%17 = call i32 (...) @cleanup()
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"COM5\00"
@.str.1 = [17 x i8] c"x:%d, y:%d, z:%d\00"
@.str.2 = [5 x i8] c"MORE\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [42 x i8] c"\0A> I got the positions: x:%d, y:%d, z:%d\0A\00"
@.str.5 = [52 x i8] c"\0A> The remote client responded with the string: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [255 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @initComms(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 300)
%10 = call i32 (i8*, ...) @recvString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%11 = call i32 @sendString(i32 65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @recvString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%18 = call i32 (...) @cleanup()
ret i32 0
}