#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*/ ssize_t;

/* Variables and functions */
int MSG_NOSIGNAL;
int /*<<< orphan*/ real_send(int, void const *, size_t, int);
int /*<<< orphan*/ warn(char *);
int /*<<< orphan*/ write(int, void const *, size_t);
ssize_t send(int fd, const void *buffer, size_t length, int flags) {
  if (flags == 0 || flags == MSG_NOSIGNAL) {
    return write(fd, buffer, length);
  } else {
    warn("Routing send to socket (unsupported flags)");
    return real_send(fd, buffer, length, flags);
  }
}


x86 assembly (clang, -O0):
<send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1162 <send+0x32>
mov    -0x1c(%rbp),%eax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%eax
jne    117a <send+0x4a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <write@plt>
mov    %eax,-0x4(%rbp)
jmp    119c <send+0x6c>
lea    0xe7f(%rip),%rdi
call   1030 <warn@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1050 <real_send@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
test   %ecx,%ecx
je     1175 <send+0x45>
mov    %ecx,%ebp
mov    0x2e94(%rip),%rax
cmp    %ecx,(%rax)
je     1175 <send+0x45>
lea    0xea9(%rip),%rdi
call   1030 <warn@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <real_send@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <write@plt>

LLVM IR (-O0):
@MSG_NOSIGNAL = global i32 0
@.str = [43 x i8] c"Routing send to socket (unsupported flags)\00"
define i32 @send(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = load i32, i32* %9
%14 = load i32, i32* @MSG_NOSIGNAL
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12, %4
%17 = load i32, i32* %6
%18 = load i8*, i8** %7
%19 = load i64, i64* %8
%20 = call i32 @write(i32 %17, i8* %18, i64 %19)
store i32 %20, i32* %5
br label %28
21: ; preds = %12
%22 = call i32 @warn(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* %6
%24 = load i8*, i8** %7
%25 = load i64, i64* %8
%26 = load i32, i32* %9
%27 = call i32 @real_send(i32 %23, i8* %24, i64 %25, i32 %26)
store i32 %27, i32* %5
br label %28
28: ; preds = %21, %16
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
@MSG_NOSIGNAL = global i32 0
@.str = [43 x i8] c"Routing send to socket (unsupported flags)\00"
define i32 @send(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
%6 = load i32, i32* @MSG_NOSIGNAL
%7 = icmp eq i32 %6, %3
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @write(i32 %0, i8* %1, i64 %2)
br label %14
11: ; preds = %4
%12 = tail call i32 @warn(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @real_send(i32 %0, i8* %1, i64 %2, i32 %3)
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %10, %9 ], [ %13, %11 ]
ret i32 %15
}