#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 in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ IP_DROP_MEMBERSHIP;
int set_multicast(int, struct in_addr const *, int /*<<< orphan*/);
int renew_multicast(int msockfd, const struct in_addr *mifaddr) {
  int rc = 0;
  rc = set_multicast(msockfd, mifaddr, IP_DROP_MEMBERSHIP);
  if (0 != rc)
    return rc;
  rc = set_multicast(msockfd, mifaddr, IP_ADD_MEMBERSHIP);
  return rc;
}


x86 assembly (clang, -O0):
<renew_multicast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2ea4(%rip),%rax
mov    (%rax),%edx
call   1030 <set_multicast@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
je     1154 <renew_multicast+0x44>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <renew_multicast+0x62>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
call   1030 <set_multicast@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<renew_multicast>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edx
call   1030 <set_multicast@plt>
test   %eax,%eax
je     1131 <renew_multicast+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2eb0(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <set_multicast@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@IP_DROP_MEMBERSHIP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
define i32 @renew_multicast(i32 %0, %struct.in_addr* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.in_addr*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.in_addr* %1, %struct.in_addr** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = load %struct.in_addr*, %struct.in_addr** %5
%9 = load i32, i32* @IP_DROP_MEMBERSHIP
%10 = call i32 @set_multicast(i32 %7, %struct.in_addr* %8, i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 0, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* %6
store i32 %14, i32* %3
br label %21
15: ; preds = %2
%16 = load i32, i32* %4
%17 = load %struct.in_addr*, %struct.in_addr** %5
%18 = load i32, i32* @IP_ADD_MEMBERSHIP
%19 = call i32 @set_multicast(i32 %16, %struct.in_addr* %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %21
21: ; preds = %15, %13
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@IP_DROP_MEMBERSHIP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
define i32 @renew_multicast(i32 %0, %struct.in_addr* %1) {
%3 = load i32, i32* @IP_DROP_MEMBERSHIP
%4 = tail call i32 @set_multicast(i32 %0, %struct.in_addr* %1, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @IP_ADD_MEMBERSHIP
%8 = tail call i32 @set_multicast(i32 %0, %struct.in_addr* %1, i32 %7)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ %8, %6 ], [ %4, %2 ]
ret i32 %10
}