#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*/ IPPROTO_IP;
int /*<<< orphan*/ IP_DROP_MEMBERSHIP;
int /*<<< orphan*/ byte_copy(int /*<<< orphan*/ *, int, char const *);
int /*<<< orphan*/ byte_zero(int /*<<< orphan*/ *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, struct ip_mreq *,
               int);
int socket_mcleave4(int s, const char ip[4]) {
  struct ip_mreq opt;
  byte_copy(&opt.imr_multiaddr.s_addr, 4, ip);
  byte_zero(&opt.imr_interface.s_addr, 4);
  return (setsockopt(s, IPPROTO_IP, IP_DROP_MEMBERSHIP, &opt, sizeof opt));
}


x86 assembly (clang, -O0):
<socket_mcleave4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4,%esi
call   1050 <byte_copy@plt>
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1040 <byte_zero@plt>
mov    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    0x2e62(%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):
<socket_mcleave4>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdx
mov    %edi,%ebx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
call   1050 <byte_copy@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x4,%esi
call   1040 <byte_zero@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r14,%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ip_mreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@IPPROTO_IP = global i32 0
@IP_DROP_MEMBERSHIP = global i32 0
define i32 @socket_mcleave4(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 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 1
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%8 = load i8*, i8** %4
%9 = call i32 @byte_copy(i32* %7, i32 4, i8* %8)
%10 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
%12 = call i32 @byte_zero(i32* %11, i32 4)
%13 = load i32, i32* %3
%14 = load i32, i32* @IPPROTO_IP
%15 = load i32, i32* @IP_DROP_MEMBERSHIP
%16 = call i32 @setsockopt(i32 %13, i32 %14, i32 %15, %struct.ip_mreq* %5, i32 8)
ret i32 %16
}

LLVM IR (-O2):
%struct.ip_mreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@IPPROTO_IP = global i32 0
@IP_DROP_MEMBERSHIP = global i32 0
define i32 @socket_mcleave4(i32 %0, i8* %1) {
%3 = alloca %struct.ip_mreq
%4 = bitcast %struct.ip_mreq* %3 to i8*
%5 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %3, i64 0, i32 1, i32 0
%6 = call i32 @byte_copy(i32* %5, i32 4, i8* %1)
%7 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %3, i64 0, i32 0, i32 0
%8 = call i32 @byte_zero(i32* %7, i32 4)
%9 = load i32, i32* @IPPROTO_IP
%10 = load i32, i32* @IP_DROP_MEMBERSHIP
%11 = call i32 @setsockopt(i32 %0, i32 %9, i32 %10, %struct.ip_mreq* %3, i32 8)
ret i32 %11
}