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

/* Variables and functions */
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ sendto(int, void const *, size_t, int, struct sockaddr *,
                          int /*<<< orphan*/);
ssize_t Sendto(int sockfd, const void *msg, size_t length, int flags,
               const struct sockaddr_in *to, socklen_t addrlen) {
  ssize_t res;
  if ((res = sendto(sockfd, msg, length, flags, (struct sockaddr *)to,
                    addrlen)) < 0)
    err_quit("sendto error");
  return res;
}


x86 assembly (clang, -O0):
<Sendto>:
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    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
call   1030 <sendto@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jge    1171 <Sendto+0x51>
lea    0xe94(%rip),%rdi
call   1040 <err_quit@plt>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sendto>:
push   %rbx
call   1030 <sendto@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1138 <Sendto+0x18>
lea    0xecd(%rip),%rdi
call   1040 <err_quit@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [13 x i8] c"sendto error\00"
define i32 @Sendto(i32 %0, i8* %1, i64 %2, i32 %3, %struct.sockaddr_in* %4, i32 %5) {
%7 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%8 = tail call i32 @sendto(i32 %0, i8* %1, i64 %2, i32 %3, %struct.sockaddr* %7, i32 %5)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @err_quit(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret i32 %8
}