#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;
};

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ inet_addr(char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void const *, int);
int ohc_recv_add_membership(int sock, char *address) {
  struct ip_mreq imreq;
  imreq.imr_multiaddr.s_addr = inet_addr(address);
  imreq.imr_interface.s_addr = INADDR_ANY;
  return setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&imreq,
                    sizeof(struct ip_mreq));
}


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

x86 assembly (clang, -O2):
<ohc_recv_add_membership>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %rsi,%rdi
call   1040 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
mov    0x2e98(%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 @ohc_recv_add_membership(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.ip_mreq
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @inet_addr(i8* %6)
%8 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 1
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
store i32 %7, i32* %9
%10 = load i32, i32* @INADDR_ANY
%11 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
store i32 %10, i32* %12
%13 = load i32, i32* %3
%14 = load i32, i32* @IPPROTO_IP
%15 = load i32, i32* @IP_ADD_MEMBERSHIP
%16 = bitcast %struct.ip_mreq* %5 to i8*
%17 = call i32 @setsockopt(i32 %13, i32 %14, i32 %15, i8* %16, i32 8)
ret i32 %17
}

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 @ohc_recv_add_membership(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 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %3, i64 0, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* @IPPROTO_IP
%10 = load i32, i32* @IP_ADD_MEMBERSHIP
%11 = call i32 @setsockopt(i32 %0, i32 %9, i32 %10, i8* %4, i32 8)
ret i32 %11
}