#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_2__ TYPE_1__;

/* Type definitions */
struct sockaddr_storage {
  int ss_family;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int IN6_IS_ADDR_MULTICAST(int /*<<< orphan*/ *);
int IN_MULTICAST(int /*<<< orphan*/);
int /*<<< orphan*/ ntohl(int /*<<< orphan*/);
int isMulticast(struct sockaddr_storage *addr) {
  int ret;
  ret = -1;
  switch (addr->ss_family) {
  case AF_INET: {
    struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
    ret = IN_MULTICAST(ntohl(addr4->sin_addr.s_addr));
  } break;
  case AF_INET6: {
    struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
    ret = IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr);
  } break;
  default:;
  }
  return ret;
}


x86 assembly (clang, -O0):
<isMulticast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     1191 <isMulticast+0x61>
jmp    115c <isMulticast+0x2c>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
jne    11aa <isMulticast+0x7a>
jmp    116f <isMulticast+0x3f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
call   1030 <IN_MULTICAST@plt>
mov    %eax,-0xc(%rbp)
jmp    11af <isMulticast+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <IN6_IS_ADDR_MULTICAST@plt>
mov    %eax,-0xc(%rbp)
jmp    11af <isMulticast+0x7f>
jmp    11af <isMulticast+0x7f>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isMulticast>:
push   %rax
mov    (%rdi),%eax
cmp    $0x80,%eax
je     1153 <isMulticast+0x23>
cmp    $0x81,%eax
jne    1159 <isMulticast+0x29>
mov    $0x81,%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <IN_MULTICAST@plt>
pop    %rax
jmp    1040 <IN6_IS_ADDR_MULTICAST@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in6 = type { i32 }
define i32 @isMulticast(%struct.sockaddr_storage* %0) {
%2 = alloca %struct.sockaddr_storage*
%3 = alloca i32
%4 = alloca %struct.sockaddr_in*
%5 = alloca %struct.sockaddr_in6*
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %2
store i32 -1, i32* %3
%6 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%7 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %6, i32 0, i32 0
%8 = load i32, i32* %7
switch i32 %8, label %24 [
i32 129, label %9
i32 128, label %18
]
9: ; preds = %1
%10 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%11 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr_in*
store %struct.sockaddr_in* %11, %struct.sockaddr_in** %4
%12 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @ntohl(i32 %15)
%17 = call i32 @IN_MULTICAST(i32 %16)
store i32 %17, i32* %3
br label %25
18: ; preds = %1
%19 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%20 = bitcast %struct.sockaddr_storage* %19 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %20, %struct.sockaddr_in6** %5
%21 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %5
%22 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %21, i32 0, i32 0
%23 = call i32 @IN6_IS_ADDR_MULTICAST(i32* %22)
store i32 %23, i32* %3
br label %25
24: ; preds = %1
br label %25
25: ; preds = %24, %18, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
define i32 @isMulticast(%struct.sockaddr_storage* %0) {
%2 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%3 = load i32, i32* %2
switch i32 %3, label %9 [
i32 129, label %4
i32 128, label %7
]
4: ; preds = %1
%5 = tail call i32 @ntohl(i32 129)
%6 = tail call i32 @IN_MULTICAST(i32 %5)
br label %9
7: ; preds = %1
%8 = tail call i32 @IN6_IS_ADDR_MULTICAST(i32* %2)
br label %9
9: ; preds = %1, %7, %4
%10 = phi i32 [ -1, %1 ], [ %8, %7 ], [ %6, %4 ]
ret i32 %10
}