#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
char *basic_send(int SD, char *request) {
  static char answer[1024];
  if (0)
    printf("Sending command: %s\n", request);
  memset(answer, 0, 1024);
  write(SD, request, strlen(request));
  write(SD, "\n", strlen("\n"));
  read(SD, answer, 1024);
  if (0)
    printf("Answer to command to LCDproc: %s\n", answer);
  return answer;
}


x86 assembly (clang, -O0):
<basic_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2efa(%rip),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xe6c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe5b(%rip),%rsi
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    0x2e9c(%rip),%rsi
mov    $0x400,%edx
call   1060 <read@plt>
lea    0x2e8b(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basic_send>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x2f00(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe86(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1060 <read@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@basic_send.answer = internal global [1024 x i8] zeroinitializer
@.str = [2 x i8] c"\0A\00"
define i8* @basic_send(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0), i32 0, i32 1024)
%6 = load i32, i32* %3
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @write(i32 %6, i8* %7, i32 %9)
%11 = load i32, i32* %3
%12 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @write(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = call i32 @read(i32 %14, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0), i32 1024)
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0)
}

LLVM IR (-O2):
@basic_send.answer = internal global [1024 x i8] zeroinitializer
@.str = [2 x i8] c"\0A\00"
define i8* @basic_send(i32 %0, i8* %1) {
%3 = tail call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0), i32 0, i32 1024)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @write(i32 %0, i8* %1, i32 %4)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @read(i32 %0, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0), i32 1024)
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @basic_send.answer, i64 0, i64 0)
}