#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*/ printf(char *);
int send(int, char *, int, int /*<<< orphan*/);
int enviar(int sock, char *buffer, int tamano) {
  int escritos;
  if ((escritos = send(sock, buffer, tamano, 0)) <= 0) {
    printf("Error en el send\n\n");
    return 2;
  } else if (escritos != tamano) {
    printf("La cantidad de bytes enviados es distinta de la que se quiere "
           "enviar\n\n");
    return 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<enviar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1030 <send@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jg     1167 <enviar+0x47>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1197 <enviar+0x77>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     118b <enviar+0x6b>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1197 <enviar+0x77>
jmp    1190 <enviar+0x70>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enviar>:
push   %rbx
mov    %edx,%ebx
xor    %ecx,%ecx
call   1040 <send@plt>
test   %eax,%eax
jle    1142 <enviar+0x22>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ebx,%ecx
je     1153 <enviar+0x33>
lea    0xec0(%rip),%rdi
jmp    1149 <enviar+0x29>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Error en el send\0A\0A\00"
@.str.1 = [71 x i8] c"La cantidad de bytes enviados es distinta de la que se quiere enviar\0A\0A\00"
define i32 @enviar(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i32 @send(i32 %9, i8* %10, i32 %11, i32 0)
store i32 %12, i32* %8
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %4
br label %24
16: ; preds = %3
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %4
br label %24
22: ; preds = %16
br label %23
23: ; preds = %22
store i32 1, i32* %4
br label %24
24: ; preds = %23, %20, %14
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@str = [70 x i8] c"La cantidad de bytes enviados es distinta de la que se quiere enviar\0A\00"
@str.2 = [18 x i8] c"Error en el send\0A\00"
define i32 @enviar(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @send(i32 %0, i8* %1, i32 %2, i32 0)
%5 = icmp slt i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = icmp eq i32 %4, %2
br i1 %7, label %11, label %8
8: ; preds = %6, %3
%9 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0), %6 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ 1, %6 ], [ 2, %8 ]
ret i32 %12
}