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

/* Variables and functions */
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int /*<<< orphan*/);
scalar_t__ recvfrom(int, char *, size_t, int /*<<< orphan*/, struct sockaddr *,
                    int *);
int /*<<< orphan*/ strlen(char *);
int srcUdpSocket_receive(int socketFD, char *outData, int expectedLen,
                         char *remoteIP, int *remotePort) {
  struct sockaddr_in clientAddress;
  socklen_t clientLen = sizeof(clientAddress);
  bzero(&clientAddress, sizeof(struct sockaddr_in));
  int len = (int)recvfrom(socketFD, outData, (size_t)expectedLen, 0,
                          (struct sockaddr *)&clientAddress, &clientLen);
  char *clientIP = inet_ntoa(clientAddress.sin_addr);
  memcpy(remoteIP, clientIP, strlen(clientIP));
  *remotePort = clientAddress.sin_port;
  return len;
}


x86 assembly (clang, -O0):
<srcUdpSocket_receive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x8,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x8,%esi
call   1070 <bzero@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rdx
lea    -0x30(%rbp),%r8
xor    %ecx,%ecx
lea    -0x34(%rbp),%r9
call   1060 <recvfrom@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srcUdpSocket_receive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%r12
mov    %edi,%ebx
movl   $0x8,0xc(%rsp)
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    $0x8,%esi
call   1070 <bzero@plt>
movslq %ebp,%rdx
lea    0xc(%rsp),%r9
mov    %ebx,%edi
mov    %r12,%rsi
xor    %ecx,%ecx
mov    %r13,%r8
call   1060 <recvfrom@plt>
mov    %rax,%rbx
mov    0x14(%rsp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
define i32 @srcUdpSocket_receive(i32 %0, i8* %1, i32 %2, i8* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32* %4, i32** %10
store i32 8, i32* %12
%15 = call i32 @bzero(%struct.sockaddr_in* %11, i32 8)
%16 = load i32, i32* %6
%17 = load i8*, i8** %7
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%21 = call i64 @recvfrom(i32 %16, i8* %17, i64 %19, i32 0, %struct.sockaddr* %20, i32* %12)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %13
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i8* @inet_ntoa(i32 %24)
store i8* %25, i8** %14
%26 = load i8*, i8** %9
%27 = load i8*, i8** %14
%28 = load i8*, i8** %14
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @memcpy(i8* %26, i8* %27, i32 %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%32 = load i32, i32* %31
%33 = load i32*, i32** %10
store i32 %32, i32* %33
%34 = load i32, i32* %13
ret i32 %34
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
define i32 @srcUdpSocket_receive(i32 %0, i8* %1, i32 %2, i8* %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 @bzero(%struct.sockaddr_in* %6, i32 8)
%11 = sext i32 %2 to i64
%12 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%13 = call i64 @recvfrom(i32 %0, i8* %1, i64 %11, i32 0, %struct.sockaddr* %12, i32* %7)
%14 = trunc i64 %13 to i32
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
%16 = load i32, i32* %15
%17 = call i8* @inet_ntoa(i32 %16)
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @memcpy(i8* %3, i8* %17, i32 %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %4
ret i32 %14
}