#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*/ net_close_connection(int);
int /*<<< orphan*/ printf(char *, char *);
int send(int, void *, int, int /*<<< orphan*/);
int net_send_data(int new_socket, void *data, int len) {
  int err = send(new_socket, data, len, 0);
  if (err < 0) {
    printf("%s \n", "Error, could not send data!");
    net_close_connection(new_socket);
    return -1;
  }
  return err;
}


x86 assembly (clang, -O0):
<net_send_data>:
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)
cmpl   $0x0,-0x18(%rbp)
jge    1187 <net_send_data+0x57>
lea    0xe99(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <net_close_connection@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <net_send_data+0x5d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<net_send_data>:
push   %rbx
mov    %edi,%ebx
xor    %ecx,%ecx
call   1030 <send@plt>
test   %eax,%eax
js     1140 <net_send_data+0x10>
pop    %rbx
ret
lea    0xeb9(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <net_close_connection@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s \0A\00"
@.str.1 = [28 x i8] c"Error, could not send data!\00"
define i32 @net_send_data(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 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %5
%18 = call i32 @net_close_connection(i32 %17)
store i32 -1, i32* %4
br label %21
19: ; preds = %3
%20 = load i32, i32* %8
store i32 %20, i32* %4
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s \0A\00"
@.str.1 = [28 x i8] c"Error, could not send data!\00"
define i32 @net_send_data(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @send(i32 %0, i8* %1, i32 %2, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @net_close_connection(i32 %0)
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ -1, %6 ], [ %4, %3 ]
ret i32 %10
}