#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 ifreq {
  int /*<<< orphan*/ ifr_flags;
  int /*<<< orphan*/ ifr_name;
};

/* Variables and functions */
int /*<<< orphan*/ IFF_MULTICAST;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char const *);
void set_multicast(int sockfd, const char *dev) {
  struct ifreq ifr;
  memset(&ifr, 0, sizeof(struct ifreq));
  strcpy(ifr.ifr_name, dev);
  if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
    return;
  }
  ifr.ifr_flags |= IFF_MULTICAST;
  ioctl(sockfd, SIOCSIFFLAGS, &ifr);
  return;
}


x86 assembly (clang, -O0):
<set_multicast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%edi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    117f <set_multicast+0x4f>
jmp    11a3 <set_multicast+0x73>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_multicast>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
js     1197 <set_multicast+0x67>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
or     %eax,0x8(%rsp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1050 <ioctl@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
@SIOCGIFFLAGS = global i32 0
@IFF_MULTICAST = global i32 0
@SIOCSIFFLAGS = global i32 0
define void @set_multicast(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.ifreq
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call i32 @memset(%struct.ifreq* %5, i32 0, i32 8)
%7 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %5, i32 0, i32 1
%8 = load i32, i32* %7
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i32 %8, i8* %9)
%11 = load i32, i32* %3
%12 = load i32, i32* @SIOCGIFFLAGS
%13 = call i64 @ioctl(i32 %11, i32 %12, %struct.ifreq* %5)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
br label %24
16: ; preds = %2
%17 = load i32, i32* @IFF_MULTICAST
%18 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %5, i32 0, i32 0
%19 = load i32, i32* %18
%20 = or i32 %19, %17
store i32 %20, i32* %18
%21 = load i32, i32* %3
%22 = load i32, i32* @SIOCSIFFLAGS
%23 = call i64 @ioctl(i32 %21, i32 %22, %struct.ifreq* %5)
br label %24
24: ; preds = %16, %15
ret void
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@SIOCGIFFLAGS = global i32 0
@IFF_MULTICAST = global i32 0
@SIOCSIFFLAGS = global i32 0
define void @set_multicast(i32 %0, i8* %1) {
%3 = alloca %struct.ifreq
%4 = bitcast %struct.ifreq* %3 to i8*
%5 = call i32 @memset(%struct.ifreq* %3, i32 0, i32 8)
%6 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 1
%7 = load i32, i32* %6
%8 = call i32 @strcpy(i32 %7, i8* %1)
%9 = load i32, i32* @SIOCGIFFLAGS
%10 = call i64 @ioctl(i32 %0, i32 %9, %struct.ifreq* %3)
%11 = icmp slt i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = load i32, i32* @IFF_MULTICAST
%14 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = or i32 %15, %13
store i32 %16, i32* %14
%17 = load i32, i32* @SIOCSIFFLAGS
%18 = call i64 @ioctl(i32 %0, i32 %17, %struct.ifreq* %3)
br label %19
19: ; preds = %2, %12
ret void
}