#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 */
typedef int /*<<< orphan*/ len;

/* Variables and functions */
scalar_t__ escribe(int, char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int envia_mensaje(int s_cliente, char *datos, int len, int segundos) {
  int correcto = 1;
  if (escribe(s_cliente, (char *)&len, sizeof(len), segundos)) {
    if (!escribe(s_cliente, datos, len, segundos)) {
      fprintf(stderr, "Error enviando datos.\n");
      correcto = 0;
    }
  } else {
    fprintf(stderr, "Error enviando longitud.\n");
    correcto = 0;
  }
  return correcto;
}


x86 assembly (clang, -O0):
<envia_mensaje>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    -0x18(%rbp),%ecx
mov    $0x4,%edx
call   1040 <escribe@plt>
cmp    $0x0,%rax
je     1197 <envia_mensaje+0x77>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <escribe@plt>
cmp    $0x0,%rax
jne    1192 <envia_mensaje+0x72>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11b3 <envia_mensaje+0x93>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<envia_mensaje>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
mov    %rsi,%r14
mov    %edi,%ebp
mov    %edx,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1040 <escribe@plt>
test   %rax,%rax
je     116d <envia_mensaje+0x4d>
mov    0xc(%rsp),%edx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%ecx
call   1040 <escribe@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1184 <envia_mensaje+0x64>
lea    0xe95(%rip),%rsi
jmp    1174 <envia_mensaje+0x54>
lea    0xea3(%rip),%rsi
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Error enviando datos.\0A\00"
@.str.1 = [26 x i8] c"Error enviando longitud.\0A\00"
define i32 @envia_mensaje(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 1, i32* %9
%10 = load i32, i32* %5
%11 = bitcast i32* %7 to i8*
%12 = load i32, i32* %8
%13 = call i64 @escribe(i32 %10, i8* %11, i32 4, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %4
%16 = load i32, i32* %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = call i64 @escribe(i32 %16, i8* %17, i32 %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %25
25: ; preds = %22, %15
br label %29
26: ; preds = %4
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %9
br label %29
29: ; preds = %26, %25
%30 = load i32, i32* %9
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Error enviando datos.\0A\00"
@.str.1 = [26 x i8] c"Error enviando longitud.\0A\00"
define i32 @envia_mensaje(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
store i32 %2, i32* %5
%6 = bitcast i32* %5 to i8*
%7 = call i64 @escribe(i32 %0, i8* %6, i32 4, i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = load i32, i32* %5
%11 = call i64 @escribe(i32 %0, i8* %1, i32 %10, i32 %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4, %9
%14 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %9 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %4 ]
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* %14)
br label %17
17: ; preds = %13, %9
%18 = phi i32 [ 1, %9 ], [ 0, %13 ]
ret i32 %18
}