#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
};
typedef int /*<<< orphan*/ ssize_t;
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ recvfrom(int, void *, size_t, int /*<<< orphan*/,
                            struct sockaddr_in *, int *);
ssize_t recvFromUDP(int fd, void *buf, size_t buflen, uint32_t *from_ip_buf,
                    uint16_t *from_port_buf) {
  struct sockaddr_in sa;
  socklen_t sa_len = sizeof sa;
  ssize_t res = recvfrom(fd, buf, buflen, 0, &sa, &sa_len);
  *from_ip_buf = ntohl(sa.sin_addr.s_addr);
  *from_port_buf = ntohs(sa.sin_port);
  return res;
}


x86 assembly (clang, -O0):
<recvFromUDP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x8,-0x34(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %ecx,%ecx
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
call   1030 <recvfrom@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <ntohl@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%edi
call   1040 <ntohs@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recvFromUDP>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
movl   $0x8,0x4(%rsp)
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
xor    %ecx,%ecx
call   1030 <recvfrom@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   1050 <ntohl@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%edi
call   1040 <ntohs@plt>
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @recvFromUDP(i32 %0, i8* %1, i64 %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
store i32 8, i32* %12
%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_in* %11, i32* %12)
store i32 %17, i32* %13
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @ntohl(i32 %20)
%22 = load i32*, i32** %9
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @ntohs(i32 %24)
%26 = load i32*, i32** %10
store i32 %25, i32* %26
%27 = load i32, i32* %13
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @recvFromUDP(i32 %0, i8* %1, i64 %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = bitcast %struct.sockaddr_in* %6 to i8*
%9 = bitcast i32* %7 to i8*
store i32 8, i32* %7
%10 = call i32 @recvfrom(i32 %0, i8* %1, i64 %2, i32 0, %struct.sockaddr_in* %6, i32* %7)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
%12 = load i32, i32* %11
%13 = call i32 @ntohl(i32 %12)
store i32 %13, i32* %3
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @ntohs(i32 %15)
store i32 %16, i32* %4
ret i32 %10
}