#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned short);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void initListener(unsigned short udpListenPort, int *p_socket,
                  struct sockaddr_in *p_addr) {
  *p_socket = socket(AF_INET, SOCK_DGRAM, 0);
  bzero(p_addr, sizeof(*p_addr));
  (*p_addr).sin_family = AF_INET;
  (*p_addr).sin_addr.s_addr = htonl(INADDR_ANY);
  (*p_addr).sin_port = htons(udpListenPort);
  bind(*p_socket, (struct sockaddr *)p_addr, sizeof(*p_addr));
}


x86 assembly (clang, -O0):
<initListener>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0xc,%esi
call   1060 <bzero@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
movzwl -0x2(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   1050 <bind@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initListener>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e82(%rip),%r15
mov    (%r15),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
mov    $0xc,%esi
call   1060 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rbx)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x4(%rbx)
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %eax,(%rbx)
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0xc,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <bind@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
define void @initListener(i16 zeroext %0, i32* %1, %struct.sockaddr_in* %2) {
%4 = alloca i16
%5 = alloca i32*
%6 = alloca %struct.sockaddr_in*
store i16 %0, i16* %4
store i32* %1, i32** %5
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %6
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = load i32*, i32** %5
store i32 %9, i32* %10
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%12 = call i32 @bzero(%struct.sockaddr_in* %11, i32 12)
%13 = load i32, i32* @AF_INET
%14 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %13, i32* %15
%16 = load i32, i32* @INADDR_ANY
%17 = call i32 @htonl(i32 %16)
%18 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i32 0, i32 0
store i32 %17, i32* %20
%21 = load i16, i16* %4
%22 = call i32 @htons(i16 zeroext %21)
%23 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%28 = bitcast %struct.sockaddr_in* %27 to %struct.sockaddr*
%29 = call i32 @bind(i32 %26, %struct.sockaddr* %28, i32 12)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
define void @initListener(i16 zeroext %0, i32* nocapture %1, %struct.sockaddr_in* %2) {
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_DGRAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %1
%7 = tail call i32 @bzero(%struct.sockaddr_in* %2, i32 12)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %8, i32* %9
%10 = load i32, i32* @INADDR_ANY
%11 = tail call i32 @htonl(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %11, i32* %12
%13 = tail call i32 @htons(i16 zeroext %0)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* %1
%16 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%17 = tail call i32 @bind(i32 %15, %struct.sockaddr* %16, i32 12)
ret void
}