#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*/ errno;
int /*<<< orphan*/ logMessage(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int strlen(char *);
scalar_t__ write(int, char *, int);
int escribir_respuesta(char *respuesta, int cfd) {
  if (write(cfd, respuesta, strlen(respuesta)) < 0) {
    logMessage("Fallo al escribir en el Socket (%s)", strerror(errno));
    return -1;
  }
  if (write(cfd, "\n", 1) < 0) {
    logMessage("Fallo al escribir en el Socket un ENTER(%s)", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<escribir_respuesta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    11a6 <escribir_respuesta+0x66>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%esi
lea    0xe6b(%rip),%rdi
call   1030 <logMessage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f3 <escribir_respuesta+0xb3>
mov    -0x14(%rbp),%edi
lea    0xe74(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    11ec <escribir_respuesta+0xac>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%esi
lea    0xe4b(%rip),%rdi
call   1030 <logMessage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f3 <escribir_respuesta+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escribir_respuesta>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     1184 <escribir_respuesta+0x44>
lea    0xebf(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    11a8 <escribir_respuesta+0x68>
lea    0xea4(%rip),%rbx
jmp    118b <escribir_respuesta+0x4b>
lea    0xe75(%rip),%rbx
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <logMessage@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Fallo al escribir en el Socket (%s)\00"
@errno = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [44 x i8] c"Fallo al escribir en el Socket un ENTER(%s)\00"
define i32 @escribir_respuesta(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = call i64 @write(i32 %6, i8* %7, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = call i32 @strerror(i32 %13)
%15 = call i32 @logMessage(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 -1, i32* %3
br label %25
16: ; preds = %2
%17 = load i32, i32* %5
%18 = call i64 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @logMessage(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 -1, i32* %3
br label %25
24: ; preds = %16
store i32 0, i32* %3
br label %25
25: ; preds = %24, %20, %12
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [36 x i8] c"Fallo al escribir en el Socket (%s)\00"
@errno = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [44 x i8] c"Fallo al escribir en el Socket un ENTER(%s)\00"
define i32 @escribir_respuesta(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i64 @write(i32 %1, i8* %0, i32 %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 @write(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6, %2
%10 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), %6 ]
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @logMessage(i8* %10, i32 %12)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ 0, %6 ], [ -1, %9 ]
ret i32 %15
}