#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ s_addr;
};
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct ip_mreq {
  TYPE_2__ imr_interface;
  TYPE_1__ imr_multiaddr;
};
typedef int /*<<< orphan*/ mcreq;

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int wfaSetSockMcastRecvOpt(int sockfd, char *mcastgroup) {
  struct ip_mreq mcreq;
  int so;
  mcreq.imr_multiaddr.s_addr = inet_addr(mcastgroup);
  mcreq.imr_interface.s_addr = htonl(INADDR_ANY);
  so = setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mcreq,
                  sizeof(mcreq));
  return so;
}


x86 assembly (clang, -O0):
<wfaSetSockMcastRecvOpt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2e79(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wfaSetSockMcastRecvOpt>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %rsi,%rdi
call   1050 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x8(%rsp)
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ip_mreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@INADDR_ANY = global i32 0
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
define i32 @wfaSetSockMcastRecvOpt(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.ip_mreq
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @inet_addr(i8* %7)
%9 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
store i32 %8, i32* %10
%11 = load i32, i32* @INADDR_ANY
%12 = call i32 @htonl(i32 %11)
%13 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 0
store i32 %12, i32* %14
%15 = load i32, i32* %3
%16 = load i32, i32* @IPPROTO_IP
%17 = load i32, i32* @IP_ADD_MEMBERSHIP
%18 = bitcast %struct.ip_mreq* %5 to i8*
%19 = call i32 @setsockopt(i32 %15, i32 %16, i32 %17, i8* %18, i32 8)
store i32 %19, i32* %6
%20 = load i32, i32* %6
ret i32 %20
}

LLVM IR (-O2):
%struct.ip_mreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@INADDR_ANY = global i32 0
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
define i32 @wfaSetSockMcastRecvOpt(i32 %0, i8* %1) {
%3 = alloca %struct.ip_mreq
%4 = bitcast %struct.ip_mreq* %3 to i8*
%5 = tail call i32 @inet_addr(i8* %1)
%6 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %3, i64 0, i32 1, i32 0
store i32 %5, i32* %6
%7 = load i32, i32* @INADDR_ANY
%8 = tail call i32 @htonl(i32 %7)
%9 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %3, i64 0, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* @IPPROTO_IP
%11 = load i32, i32* @IP_ADD_MEMBERSHIP
%12 = call i32 @setsockopt(i32 %0, i32 %10, i32 %11, i8* %4, i32 8)
ret i32 %12
}