#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 */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int rpcbind_socket();
scalar_t__ sendto(int, void const *, size_t, int /*<<< orphan*/,
                  struct sockaddr const *, int /*<<< orphan*/);
int __rpcbind_send(const void *buffer, size_t len, const struct sockaddr *addr,
                   socklen_t alen) {
  int fd;
  printf("Sending... ");
  if ((fd = rpcbind_socket()) < 0)
    return 0;
  if (sendto(fd, buffer, len, 0, addr, alen) < 0) {
    perror("sendto failed");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<__rpcbind_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <rpcbind_socket@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1182 <__rpcbind_send+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <__rpcbind_send+0x85>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
xor    %ecx,%ecx
call   1050 <sendto@plt>
cmp    $0x0,%rax
jge    11be <__rpcbind_send+0x7e>
lea    0xe5f(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <__rpcbind_send+0x85>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__rpcbind_send>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <rpcbind_socket@plt>
test   %eax,%eax
js     118c <__rpcbind_send+0x4c>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r14d,%r9d
call   1050 <sendto@plt>
mov    $0x1,%ebp
test   %rax,%rax
js     1197 <__rpcbind_send+0x57>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe6e(%rip),%rdi
call   1060 <perror@plt>
xor    %ebp,%ebp
jmp    118c <__rpcbind_send+0x4c>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"Sending... \00"
@.str.1 = [14 x i8] c"sendto failed\00"
define i32 @__rpcbind_send(i8* %0, i64 %1, %struct.sockaddr* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.sockaddr*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store %struct.sockaddr* %2, %struct.sockaddr** %8
store i32 %3, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @rpcbind_socket()
store i32 %12, i32* %10
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 0, i32* %5
br label %26
15: ; preds = %4
%16 = load i32, i32* %10
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = load %struct.sockaddr*, %struct.sockaddr** %8
%20 = load i32, i32* %9
%21 = call i64 @sendto(i32 %16, i8* %17, i64 %18, i32 0, %struct.sockaddr* %19, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %26
25: ; preds = %15
store i32 1, i32* %5
br label %26
26: ; preds = %25, %23, %14
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"Sending... \00"
@.str.1 = [14 x i8] c"sendto failed\00"
define i32 @__rpcbind_send(i8* %0, i64 %1, %struct.sockaddr* %2, i32 %3) {
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @rpcbind_socket()
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = tail call i64 @sendto(i32 %6, i8* %0, i64 %1, i32 0, %struct.sockaddr* %2, i32 %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %8, %4, %11
%14 = phi i32 [ 0, %11 ], [ 0, %4 ], [ 1, %8 ]
ret i32 %14
}