#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*/ recvfrom(int, void *, size_t, int, struct sockaddr *,
                            int /*<<< orphan*/ *);
ssize_t Recvfrom(int sockfd, void *msg, size_t length, int flags,
                 struct sockaddr_in *from, socklen_t *addrlen) {
  ssize_t res;
  if ((res = recvfrom(sockfd, msg, length, flags, (struct sockaddr *)from,
                      addrlen)) < 0)
    err_quit("recvfrom error");
  return res;
}


x86 assembly (clang, -O0):
<Recvfrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <recvfrom@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1171 <Recvfrom+0x51>
lea    0xe94(%rip),%rdi
call   1030 <err_quit@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [15 x i8] c"recvfrom error\00"
define i32 @Recvfrom(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 @recvfrom(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 ([15 x i8], [15 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 = [15 x i8] c"recvfrom error\00"
define i32 @Recvfrom(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 @recvfrom(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 ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret i32 %8
}