#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 *, char *);
int /*<<< orphan*/ recvString(char *, char *);
int /*<<< orphan*/ sendString(int, char *, ...);
int main() {
  char buffers[255];
  int x = 100;
  int y = 200;
  int z = 300;
  initComms("COM4", 300);
  sendString(0x41, "x:%d, y:%d, z:%d", x, y, z);
  recvString("%s", buffers);
  printf("\n> I got the string: %s\n", buffers);
  sendString(0x41, "NO!");
  cleanup();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x114(%rbp)
movl   $0xc8,-0x118(%rbp)
movl   $0x12c,-0x11c(%rbp)
lea    0xe79(%rip),%rdi
mov    $0x12c,%esi
call   1040 <initComms@plt>
mov    -0x114(%rbp),%edx
mov    -0x118(%rbp),%ecx
mov    -0x11c(%rbp),%r8d
mov    $0x41,%edi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1030 <sendString@plt>
lea    -0x110(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1060 <recvString@plt>
lea    -0x110(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    $0x41,%edi
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <sendString@plt>
mov    $0x0,%al
call   1070 <cleanup@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xea1(%rip),%rdi
mov    $0x12c,%esi
call   1040 <initComms@plt>
lea    0xe95(%rip),%rsi
mov    $0x41,%edi
mov    $0x64,%edx
mov    $0xc8,%ecx
mov    $0x12c,%r8d
xor    %eax,%eax
call   1030 <sendString@plt>
lea    0xe83(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <recvString@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe7e(%rip),%rsi
mov    $0x41,%edi
xor    %eax,%eax
call   1030 <sendString@plt>
xor    %eax,%eax
call   1070 <cleanup@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"COM4\00"
@.str.1 = [17 x i8] c"x:%d, y:%d, z:%d\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [25 x i8] c"\0A> I got the string: %s\0A\00"
@.str.4 = [4 x i8] c"NO!\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @initComms(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 300)
%4 = tail call i32 (i32, i8*, ...) @sendString(i32 65, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 100, i32 200, i32 300)
%5 = call i32 @recvString(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%7 = call i32 (i32, i8*, ...) @sendString(i32 65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 (...) @cleanup()
ret i32 0
}