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

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ LOG_ERR;
scalar_t__ errno;
int send(int, void const *, size_t, int);
int /*<<< orphan*/ strerror(scalar_t__);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
ssize_t Send(int fd, const void *buf, size_t len, int flags) {
  ssize_t ret;
restart_send:
  if ((ret = send(fd, buf, len, flags)) == -1) {
    if (errno == EINTR) {
      goto restart_send;
    }
    syslog(LOG_ERR, "send: %s", strerror(errno));
  }
  return ret;
}


x86 assembly (clang, -O0):
<Send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <send@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    11b0 <Send+0x80>
mov    0x2e74(%rip),%rax
mov    (%rax),%rax
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%rax
jne    1184 <Send+0x54>
jmp    1146 <Send+0x16>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%edx
lea    0xe55(%rip),%rsi
call   1040 <syslog@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Send>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x2e8b(%rip),%r13
nopl   (%rax)
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1030 <send@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1195 <Send+0x65>
mov    0x2e72(%rip),%rax
mov    (%rax),%rdi
cmp    0x0(%r13),%rdi
je     1150 <Send+0x20>
mov    0x2e4a(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe74(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <syslog@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@LOG_ERR = global i32 0
@.str = [9 x i8] c"send: %s\00"
define i32 @Send(i32 %0, i8* %1, i64 %2, i32 %3) {
br label %5
5: ; preds = %8, %4
%6 = tail call i32 @send(i32 %0, i8* %1, i64 %2, i32 %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i64, i64* @errno
%10 = load i64, i64* @EINTR
%11 = icmp eq i64 %9, %10
br i1 %11, label %5, label %12
12: ; preds = %8
%13 = load i32, i32* @LOG_ERR
%14 = tail call i32 @strerror(i64 %9)
%15 = tail call i32 @syslog(i32 %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %5, %12
ret i32 %6
}