#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 ssize_t;
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ eprintf(char *);
int /*<<< orphan*/ iptoaddr(struct sockaddr *, unsigned char *, int);
int recvfrom(int, void *, size_t, int /*<<< orphan*/, struct sockaddr *, int *);
ssize_t udprecv(unsigned char ip[4], int fd, void *data, size_t n) {
  struct sockaddr addr;
  socklen_t addrlen = sizeof addr;
  ssize_t r;
  iptoaddr(&addr, ip, 68);
  if ((r = recvfrom(fd, data, n, 0, &addr, &addrlen)) == -1)
    eprintf("recvfrom:");
  return r;
}


x86 assembly (clang, -O0):
<udprecv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x4,-0x2c(%rbp)
mov    -0x8(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x44,%edx
call   1040 <iptoaddr@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %ecx,%ecx
lea    -0x28(%rbp),%r8
lea    -0x2c(%rbp),%r9
call   1030 <recvfrom@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
jne    1192 <udprecv+0x62>
lea    0xe73(%rip),%rdi
call   1050 <eprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udprecv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%rsi
movl   $0x4,0xc(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x44,%edx
call   1040 <iptoaddr@plt>
lea    0xc(%rsp),%r9
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %r15,%r8
call   1030 <recvfrom@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1189 <udprecv+0x59>
lea    0xe7c(%rip),%rdi
call   1050 <eprintf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"recvfrom:\00"
define i32 @udprecv(i8* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.sockaddr
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i32 4, i32* %10
%12 = load i8*, i8** %5
%13 = call i32 @iptoaddr(%struct.sockaddr* %9, i8* %12, i32 68)
%14 = load i32, i32* %6
%15 = load i8*, i8** %7
%16 = load i64, i64* %8
%17 = call i32 @recvfrom(i32 %14, i8* %15, i64 %16, i32 0, %struct.sockaddr* %9, i32* %10)
store i32 %17, i32* %11
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @eprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = load i32, i32* %11
ret i32 %22
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"recvfrom:\00"
define i32 @udprecv(i8* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca %struct.sockaddr
%6 = alloca i32
%7 = bitcast %struct.sockaddr* %5 to i8*
%8 = bitcast i32* %6 to i8*
store i32 4, i32* %6
%9 = call i32 @iptoaddr(%struct.sockaddr* %5, i8* %0, i32 68)
%10 = call i32 @recvfrom(i32 %1, i8* %2, i64 %3, i32 0, %struct.sockaddr* %5, i32* %6)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call i32 @eprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %4
ret i32 %10
}