#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 */
typedef int /*<<< orphan*/ reserved;
typedef int in_addr_t;
typedef int /*<<< orphan*/ ea1;

/* Variables and functions */
int ETHER_ADDR_LEN;
int /*<<< orphan*/ ether_mtoe(int, unsigned char *);
int htonl(int);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int reserved_mcast(in_addr_t group) {
  static const struct {
    in_addr_t addr;
    in_addr_t mask;
  } reserved[] = {{0xe0000000, 0xffffff00},
                  {0xe000ff87, 0xffffffff},
                  {0xeffffffa, 0xffffffff}};
  unsigned char ea1[ETHER_ADDR_LEN];
  unsigned char ea2[ETHER_ADDR_LEN];
  unsigned int i;
  for (i = 0; i < sizeof(reserved) / sizeof(reserved[0]); i++) {
    ether_mtoe(htonl(reserved[i].addr), ea1);
    ether_mtoe(htonl(reserved[i].mask) & group, ea2);
    if (memcmp(ea1, ea2, sizeof(ea1)) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<reserved_mcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x40(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    $0x3,%rax
jae    1222 <reserved_mcast+0xf2>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
lea    0xe57(%rip),%rax
mov    (%rax,%rcx,8),%edi
call   1040 <htonl@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edi
call   1030 <ether_mtoe@plt>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
lea    0xe38(%rip),%rax
mov    0x4(%rax,%rcx,8),%edi
call   1040 <htonl@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edi
and    -0x8(%rbp),%edi
call   1030 <ether_mtoe@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    120f <reserved_mcast+0xdf>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    1230 <reserved_mcast+0x100>
jmp    1214 <reserved_mcast+0xe4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1190 <reserved_mcast+0x60>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reserved_mcast>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
mov    0x2ea8(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r15
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    $0xe0000000,%edi
call   1040 <htonl@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <ether_mtoe@plt>
mov    $0xffffff00,%edi
call   1040 <htonl@plt>
and    %r12d,%eax
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <ether_mtoe@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcmp@plt>
mov    $0x1,%r13d
test   %rax,%rax
je     1228 <reserved_mcast+0xf8>
mov    $0xe000ff87,%edi
call   1040 <htonl@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <ether_mtoe@plt>
mov    $0xffffffff,%edi
call   1040 <htonl@plt>
mov    %r12d,%ecx
mov    %eax,%r12d
and    %ecx,%r12d
mov    %r12d,%edi
mov    %rbx,%rsi
call   1030 <ether_mtoe@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     1228 <reserved_mcast+0xf8>
mov    $0xeffffffa,%edi
call   1040 <htonl@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <ether_mtoe@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1030 <ether_mtoe@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcmp@plt>
xor    %r13d,%r13d
test   %rax,%rax
sete   %r13b
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i32, i32 }
@reserved_mcast.reserved = internal constant [3 x %struct.anon] [%struct.anon { i32 -536870912, i32 -256 }, %struct.anon { i32 -536805497, i32 -1 }, %struct.anon { i32 -268435462, i32 -1 }]
@ETHER_ADDR_LEN = global i32 0
define i32 @reserved_mcast(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = load i32, i32* @ETHER_ADDR_LEN
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = load i32, i32* @ETHER_ADDR_LEN
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
store i64 %14, i64* %6
store i32 0, i32* %7
br label %16
16: ; preds = %42, %1
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = icmp ult i64 %18, 3
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = load i32, i32* %7
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* @reserved_mcast.reserved, i64 0, i64 %22
%24 = getelementptr inbounds %struct.anon, %struct.anon* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @htonl(i32 %25)
%27 = call i32 @ether_mtoe(i32 %26, i8* %12)
%28 = load i32, i32* %7
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* @reserved_mcast.reserved, i64 0, i64 %29
%31 = getelementptr inbounds %struct.anon, %struct.anon* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = call i32 @htonl(i32 %32)
%34 = load i32, i32* %3
%35 = and i32 %33, %34
%36 = call i32 @ether_mtoe(i32 %35, i8* %15)
%37 = trunc i64 %10 to i32
%38 = call i64 @memcmp(i8* %12, i8* %15, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %20
store i32 1, i32* %2
store i32 1, i32* %8
br label %46
41: ; preds = %20
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add i32 %43, 1
store i32 %44, i32* %7
br label %16
45: ; preds = %16
store i32 0, i32* %2
store i32 1, i32* %8
br label %46
46: ; preds = %45, %40
%47 = load i8*, i8** %4
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@ETHER_ADDR_LEN = global i32 0
define i32 @reserved_mcast(i32 %0) {
%2 = load i32, i32* @ETHER_ADDR_LEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = alloca i8, i64 %3
%6 = call i32 @htonl(i32 -536870912)
%7 = call i32 @ether_mtoe(i32 %6, i8* %4)
%8 = call i32 @htonl(i32 -256)
%9 = and i32 %8, %0
%10 = call i32 @ether_mtoe(i32 %9, i8* %5)
%11 = call i64 @memcmp(i8* %4, i8* %5, i32 %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %28, label %13
13: ; preds = %1
%14 = call i32 @htonl(i32 -536805497)
%15 = call i32 @ether_mtoe(i32 %14, i8* %4)
%16 = call i32 @htonl(i32 -1)
%17 = and i32 %16, %0
%18 = call i32 @ether_mtoe(i32 %17, i8* %5)
%19 = call i64 @memcmp(i8* %4, i8* %5, i32 %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %13
%22 = call i32 @htonl(i32 -268435462)
%23 = call i32 @ether_mtoe(i32 %22, i8* %4)
%24 = call i32 @ether_mtoe(i32 %17, i8* %5)
%25 = call i64 @memcmp(i8* %4, i8* %5, i32 %2)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %21, %13, %1
%29 = phi i32 [ 1, %1 ], [ 1, %13 ], [ %27, %21 ]
ret i32 %29
}